@@ -7,15 +7,17 @@ import {
|
||||
RenderArgs,
|
||||
DefaultKernelExport,
|
||||
splitGziped,
|
||||
} from './common'
|
||||
} from '../common'
|
||||
import { CadQueryToCadhubParams } from './cadQueryParams'
|
||||
|
||||
export const render: DefaultKernelExport['render'] = async ({
|
||||
code,
|
||||
settings: { quality = 'low' },
|
||||
settings: { quality = 'low', parameters },
|
||||
}: RenderArgs) => {
|
||||
const body = JSON.stringify({
|
||||
settings: {
|
||||
deflection: quality === 'low' ? 0.35 : 0.11,
|
||||
parameters,
|
||||
},
|
||||
file: code,
|
||||
})
|
||||
@@ -49,16 +51,15 @@ export const render: DefaultKernelExport['render'] = async ({
|
||||
data: await stlToGeometry(window.URL.createObjectURL(blob)),
|
||||
consoleMessage,
|
||||
date: new Date(),
|
||||
customizerParams: customizerParams,
|
||||
customizerParams: CadQueryToCadhubParams([customizerParams]), // TODO, should already be an array and not need to be wrapped in one.
|
||||
})
|
||||
} catch (e) {
|
||||
return createUnhealthyResponse(new Date())
|
||||
}
|
||||
}
|
||||
|
||||
const openscad: DefaultKernelExport = {
|
||||
const cadQuery: DefaultKernelExport = {
|
||||
render,
|
||||
// more functions to come
|
||||
}
|
||||
|
||||
export default openscad
|
||||
export default cadQuery
|
||||
49
app/web/src/helpers/cadPackages/cadQuery/cadQueryParams.ts
Normal file
49
app/web/src/helpers/cadPackages/cadQuery/cadQueryParams.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { CadhubParams } from 'src/components/Customizer/customizerConverter'
|
||||
|
||||
interface CadQueryParamsBase {
|
||||
name: string
|
||||
initial: number | string
|
||||
type?: 'number'
|
||||
}
|
||||
|
||||
interface CadQueryNumberParam extends CadQueryParamsBase {
|
||||
type: 'number'
|
||||
initial: number
|
||||
}
|
||||
|
||||
interface CadQueryStringParam extends CadQueryParamsBase {
|
||||
initial: string
|
||||
}
|
||||
|
||||
export type CadQueryStringParams =
|
||||
| CadQueryNumberParam
|
||||
| CadQueryStringParam
|
||||
|
||||
|
||||
export function CadQueryToCadhubParams(
|
||||
input: CadQueryStringParams[]
|
||||
): CadhubParams[] {
|
||||
return input
|
||||
.map((param): CadhubParams => {
|
||||
const common: { caption: string; name: string } = {
|
||||
caption: '',
|
||||
name: param.name,
|
||||
}
|
||||
if(param.type === 'number') {
|
||||
return {
|
||||
type: 'number',
|
||||
input: 'default-number',
|
||||
...common,
|
||||
initial: Number(param.initial),
|
||||
}
|
||||
}
|
||||
return {
|
||||
type: 'string',
|
||||
input: 'default-string',
|
||||
...common,
|
||||
initial: String(param.initial),
|
||||
}
|
||||
})
|
||||
.filter((a) => a)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import openscad from './openScad/openScadController'
|
||||
import openScadGuide from 'src/helpers/cadPackages/openScad/userGuide.md'
|
||||
import openScadInitialCode from 'src/helpers/cadPackages/openScad/initialCode.scad'
|
||||
|
||||
import cadquery from './cadQueryController'
|
||||
import cadquery from './cadQuery/cadQueryController'
|
||||
import cadQueryGuide from 'src/helpers/cadPackages/cadQuery/userGuide.md'
|
||||
import cadQueryInitialCode from 'src/helpers/cadPackages/cadQuery/initialCode.py'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user