set up local development for openscad lamdas

and make a start on combining with Three.js IdeViewer
Resolves #227

related #231
This commit is contained in:
Kurt Hutten
2021-03-10 08:14:32 +11:00
parent 384d8231e8
commit 10062513fd
13 changed files with 4613 additions and 3490 deletions

View File

@@ -1,19 +1,24 @@
// const openScadBaseURL = 'http://localhost:8080' // for local development
const openScadBaseURL =
'https://x2wvhihk56.execute-api.us-east-1.amazonaws.com/dev'
export const render = async ({ code, settings }) => {
const body = JSON.stringify({
settings: {
size: {
x: 500,
y: 500,
},
camera: settings.camera,
},
file: code,
})
const response = await fetch(openScadBaseURL + '/render', {
method: 'POST',
headers: new Headers().append('Content-Type', 'application/json'),
body: JSON.stringify({
settings: {
size: {
x: 700,
y: 300,
},
},
file: code,
}),
headers: {
'Content-Type': 'application/json',
},
body,
})
if (response.status === 400) {
const { error } = await response.json()

View File

@@ -22,7 +22,7 @@ export const useIdeState = () => {
second: 'Console',
splitPercentage: 70,
},
}
},
}
const reducer = (state, { type, payload }) => {
switch (type) {
@@ -56,6 +56,8 @@ export const useIdeState = () => {
...state,
layout: payload.message,
}
default:
return state
}
}
@@ -64,7 +66,10 @@ export const useIdeState = () => {
switch (type) {
case 'render':
cadPackages[state.ideType]
.render({ code: payload.code })
.render({
code: payload.code,
settings: { camera: payload.camera },
})
.then(({ objectData, message, isError }) => {
if (isError) {
dispatch({