Demo branch adding JSCAD type, without implementing the render
Related to #411
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import { DefaultKernelExport } from './common'
|
||||
import type { CadPackage } from 'src/helpers/hooks/useIdeState'
|
||||
|
||||
import openscad from './openScadController'
|
||||
import cadquery from './cadQueryController'
|
||||
import jscad from './jsCadController'
|
||||
|
||||
export const cadPackages = {
|
||||
export const cadPackages: {[key in CadPackage]: DefaultKernelExport} = {
|
||||
openscad,
|
||||
cadquery,
|
||||
jscad,
|
||||
}
|
||||
|
||||
15
app/web/src/helpers/cadPackages/jsCadController.ts
Normal file
15
app/web/src/helpers/cadPackages/jsCadController.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { RenderArgs, DefaultKernelExport, createUnhealthyResponse } from './common'
|
||||
|
||||
export const render: DefaultKernelExport['render'] = async ({
|
||||
code,
|
||||
settings,
|
||||
}: RenderArgs) => {
|
||||
// do your magic
|
||||
return createUnhealthyResponse( new Date(), 'JSCAD controller not implemented yet')
|
||||
}
|
||||
|
||||
const jsCadController: DefaultKernelExport = {
|
||||
render,
|
||||
}
|
||||
|
||||
export default jsCadController
|
||||
@@ -9,7 +9,9 @@ function withThunk(dispatch, getState) {
|
||||
: dispatch(actionOrThunk)
|
||||
}
|
||||
|
||||
const initCodeMap = {
|
||||
export type CadPackage = 'openscad' | 'cadquery' | 'jscad'
|
||||
|
||||
const initCodeMap: {[key in CadPackage]: string} = {
|
||||
openscad: `// involute donut
|
||||
|
||||
// ^ first comment is used for download title (i.e "involute-donut.stl")
|
||||
@@ -40,6 +42,9 @@ result = (cq.Workplane().circle(diam).extrude(20.0)
|
||||
|
||||
show_object(result)
|
||||
`,
|
||||
jscad: `
|
||||
// TODO implement example JSCAD code.
|
||||
`
|
||||
}
|
||||
|
||||
const codeStorageKey = 'Last-editor-code'
|
||||
@@ -53,7 +58,7 @@ interface XYZ {
|
||||
}
|
||||
|
||||
export interface State {
|
||||
ideType: 'INIT' | 'openscad' | 'cadquery'
|
||||
ideType: 'INIT' | CadPackage
|
||||
consoleMessages: { type: 'message' | 'error'; message: string; time: Date }[]
|
||||
code: string
|
||||
objectData: {
|
||||
|
||||
Reference in New Issue
Block a user