Format project

This commit is contained in:
Kurt Hutten
2021-11-30 15:23:16 +11:00
parent 172e19165f
commit fac1968a74
9 changed files with 28 additions and 19 deletions

View File

@@ -9,13 +9,16 @@ const stl = async (req, _context, callback) => {
console.log('eventBody', eventBody) console.log('eventBody', eventBody)
const { file, settings } = JSON.parse(eventBody) const { file, settings } = JSON.parse(eventBody)
const { error, consoleMessage, fullPath, tempFile } = await runCQ({ file, settings }) const { error, consoleMessage, fullPath, tempFile } = await runCQ({
file,
settings,
})
await storeAssetAndReturnUrl({ await storeAssetAndReturnUrl({
error, error,
callback, callback,
fullPath, fullPath,
consoleMessage, consoleMessage,
tempFile tempFile,
}) })
} }

View File

@@ -104,7 +104,7 @@ export async function storeAssetAndReturnUrl({
callback, callback,
fullPath, fullPath,
consoleMessage, consoleMessage,
tempFile tempFile,
}: { }: {
error: string error: string
callback: Function callback: Function

View File

@@ -3,10 +3,7 @@ import { nanoid } from 'nanoid'
export const runCurv = async ({ export const runCurv = async ({
file, file,
settings: { settings: { size: { x = 500, y = 500 } = {}, parameters } = {}, // TODO add view settings
size: { x = 500, y = 500 } = {},
parameters,
} = {}, // TODO add view settings
} = {}): Promise<{ } = {}): Promise<{
error?: string error?: string
consoleMessage?: string consoleMessage?: string
@@ -83,7 +80,8 @@ export const stlExport = async ({ file, settings: { parameters } } = {}) => {
const stlPath = `/tmp/${tempFile}/output.stl` const stlPath = `/tmp/${tempFile}/output.stl`
const command = [ const command = [
'(cd /tmp && curv', '(cd /tmp && curv',
'-o', stlPath, '-o',
stlPath,
'-O jit', '-O jit',
'-O vcount=350000', '-O vcount=350000',
`/tmp/${tempFile}/main.curv`, `/tmp/${tempFile}/main.curv`,

View File

@@ -19,7 +19,7 @@ export const schema = gql`
childForks: [Project]! childForks: [Project]!
} }
# should match enum in api/db/schema.prisma # should match enum in api/db/schema.prisma
enum CadPackage { enum CadPackage {
openscad openscad
cadquery cadquery

View File

@@ -69,7 +69,8 @@ export const makeStlDownloadHandler =
} else { } else {
thunkDispatch((dispatch, getState) => { thunkDispatch((dispatch, getState) => {
const state = getState() const state = getState()
const specialCadProcess = (ideType === 'openscad' || ideType === 'curv') && 'stl' const specialCadProcess =
(ideType === 'openscad' || ideType === 'curv') && 'stl'
dispatch({ type: 'setLoading' }) dispatch({ type: 'setLoading' })
requestRender({ requestRender({
state, state,

View File

@@ -351,7 +351,7 @@ function ChooseYourCharacter() {
{ {
cadPackage: 'curv', cadPackage: 'curv',
desc: "Curv is a programming language for creating art using mathematics. It's a 2D and 3D geometric modelling tool.", desc: "Curv is a programming language for creating art using mathematics. It's a 2D and 3D geometric modelling tool.",
} },
].map( ].map(
({ ({
cadPackage, cadPackage,

View File

@@ -25,7 +25,12 @@ const IdeViewer = ({
}) })
thunkDispatch((dispatch, getState) => { thunkDispatch((dispatch, getState) => {
const state = getState() const state = getState()
if (['png', 'INIT'].includes(state?.objectData?.type) && (ideType === 'openscad' || state?.objectData?.type === 'INIT' || !state?.objectData?.type)) { if (
['png', 'INIT'].includes(state?.objectData?.type) &&
(ideType === 'openscad' ||
state?.objectData?.type === 'INIT' ||
!state?.objectData?.type)
) {
dispatch({ type: 'setLoading' }) dispatch({ type: 'setLoading' })
requestRender({ requestRender({
state, state,

View File

@@ -169,7 +169,7 @@ export function PureIdeViewer({
isMinimal = false, isMinimal = false,
scadRatio = 1, scadRatio = 1,
camera, camera,
ideType ideType,
}: { }: {
dataType: 'INIT' | ArtifactTypes dataType: 'INIT' | ArtifactTypes
artifact: any artifact: any
@@ -218,9 +218,9 @@ export function PureIdeViewer({
)} )}
<div // eslint-disable-line jsx-a11y/no-static-element-interactions <div // eslint-disable-line jsx-a11y/no-static-element-interactions
className={`opacity-0 absolute inset-0 transition-opacity duration-500 ${ className={`opacity-0 absolute inset-0 transition-opacity duration-500 ${
ideType === 'curv' && dataType === 'png' ? // TODO hide axes while curve doesn't have a controllable camera ideType === 'curv' && dataType === 'png' // TODO hide axes while curve doesn't have a controllable camera
'opacity-0' : ? 'opacity-0'
!(isDragging || dataType !== 'png') : !(isDragging || dataType !== 'png')
? 'hover:opacity-50' ? 'hover:opacity-50'
: 'opacity-100' : 'opacity-100'
}`} }`}
@@ -230,7 +230,10 @@ export function PureIdeViewer({
<Controls <Controls
onDragStart={() => setIsDragging(true)} onDragStart={() => setIsDragging(true)}
onInit={onInit} onInit={onInit}
onCameraChange={(...args) => {onCameraChange(...args); setIsDragging(false)}} onCameraChange={(...args) => {
onCameraChange(...args)
setIsDragging(false)
}}
controlsRef={controlsRef} controlsRef={controlsRef}
camera={camera} camera={camera}
/> />

View File

@@ -38,8 +38,7 @@ export const render = async ({ code, settings }: RenderArgs) => {
} }
const blob = await response.blob() const blob = await response.blob()
const text = await new Response(blob).text() const text = await new Response(blob).text()
const { consoleMessage, type } = const { consoleMessage, type } = splitGziped(text)
splitGziped(text)
return createHealthyResponse({ return createHealthyResponse({
type: type !== 'stl' ? 'png' : 'geometry', type: type !== 'stl' ? 'png' : 'geometry',
data: data: