Format project
This commit is contained in:
@@ -9,13 +9,16 @@ const stl = async (req, _context, callback) => {
|
||||
console.log('eventBody', 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({
|
||||
error,
|
||||
callback,
|
||||
fullPath,
|
||||
consoleMessage,
|
||||
tempFile
|
||||
tempFile,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ export async function storeAssetAndReturnUrl({
|
||||
callback,
|
||||
fullPath,
|
||||
consoleMessage,
|
||||
tempFile
|
||||
tempFile,
|
||||
}: {
|
||||
error: string
|
||||
callback: Function
|
||||
|
||||
@@ -3,10 +3,7 @@ import { nanoid } from 'nanoid'
|
||||
|
||||
export const runCurv = async ({
|
||||
file,
|
||||
settings: {
|
||||
size: { x = 500, y = 500 } = {},
|
||||
parameters,
|
||||
} = {}, // TODO add view settings
|
||||
settings: { size: { x = 500, y = 500 } = {}, parameters } = {}, // TODO add view settings
|
||||
} = {}): Promise<{
|
||||
error?: string
|
||||
consoleMessage?: string
|
||||
@@ -83,7 +80,8 @@ export const stlExport = async ({ file, settings: { parameters } } = {}) => {
|
||||
const stlPath = `/tmp/${tempFile}/output.stl`
|
||||
const command = [
|
||||
'(cd /tmp && curv',
|
||||
'-o', stlPath,
|
||||
'-o',
|
||||
stlPath,
|
||||
'-O jit',
|
||||
'-O vcount=350000',
|
||||
`/tmp/${tempFile}/main.curv`,
|
||||
|
||||
@@ -19,7 +19,7 @@ export const schema = gql`
|
||||
childForks: [Project]!
|
||||
}
|
||||
|
||||
# should match enum in api/db/schema.prisma
|
||||
# should match enum in api/db/schema.prisma
|
||||
enum CadPackage {
|
||||
openscad
|
||||
cadquery
|
||||
|
||||
@@ -69,7 +69,8 @@ export const makeStlDownloadHandler =
|
||||
} else {
|
||||
thunkDispatch((dispatch, getState) => {
|
||||
const state = getState()
|
||||
const specialCadProcess = (ideType === 'openscad' || ideType === 'curv') && 'stl'
|
||||
const specialCadProcess =
|
||||
(ideType === 'openscad' || ideType === 'curv') && 'stl'
|
||||
dispatch({ type: 'setLoading' })
|
||||
requestRender({
|
||||
state,
|
||||
|
||||
@@ -351,7 +351,7 @@ function ChooseYourCharacter() {
|
||||
{
|
||||
cadPackage: 'curv',
|
||||
desc: "Curv is a programming language for creating art using mathematics. It's a 2D and 3D geometric modelling tool.",
|
||||
}
|
||||
},
|
||||
].map(
|
||||
({
|
||||
cadPackage,
|
||||
|
||||
@@ -25,7 +25,12 @@ const IdeViewer = ({
|
||||
})
|
||||
thunkDispatch((dispatch, 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' })
|
||||
requestRender({
|
||||
state,
|
||||
|
||||
@@ -169,7 +169,7 @@ export function PureIdeViewer({
|
||||
isMinimal = false,
|
||||
scadRatio = 1,
|
||||
camera,
|
||||
ideType
|
||||
ideType,
|
||||
}: {
|
||||
dataType: 'INIT' | ArtifactTypes
|
||||
artifact: any
|
||||
@@ -218,9 +218,9 @@ export function PureIdeViewer({
|
||||
)}
|
||||
<div // eslint-disable-line jsx-a11y/no-static-element-interactions
|
||||
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
|
||||
'opacity-0' :
|
||||
!(isDragging || dataType !== 'png')
|
||||
ideType === 'curv' && dataType === 'png' // TODO hide axes while curve doesn't have a controllable camera
|
||||
? 'opacity-0'
|
||||
: !(isDragging || dataType !== 'png')
|
||||
? 'hover:opacity-50'
|
||||
: 'opacity-100'
|
||||
}`}
|
||||
@@ -230,7 +230,10 @@ export function PureIdeViewer({
|
||||
<Controls
|
||||
onDragStart={() => setIsDragging(true)}
|
||||
onInit={onInit}
|
||||
onCameraChange={(...args) => {onCameraChange(...args); setIsDragging(false)}}
|
||||
onCameraChange={(...args) => {
|
||||
onCameraChange(...args)
|
||||
setIsDragging(false)
|
||||
}}
|
||||
controlsRef={controlsRef}
|
||||
camera={camera}
|
||||
/>
|
||||
|
||||
@@ -38,8 +38,7 @@ export const render = async ({ code, settings }: RenderArgs) => {
|
||||
}
|
||||
const blob = await response.blob()
|
||||
const text = await new Response(blob).text()
|
||||
const { consoleMessage, type } =
|
||||
splitGziped(text)
|
||||
const { consoleMessage, type } = splitGziped(text)
|
||||
return createHealthyResponse({
|
||||
type: type !== 'stl' ? 'png' : 'geometry',
|
||||
data:
|
||||
|
||||
Reference in New Issue
Block a user