@@ -10,9 +10,10 @@ app.use(cors())
|
|||||||
const invocationURL = (port) =>
|
const invocationURL = (port) =>
|
||||||
`http://localhost:${port}/2015-03-31/functions/function/invocations`
|
`http://localhost:${port}/2015-03-31/functions/function/invocations`
|
||||||
|
|
||||||
app.post('/openscad/preview', async (req, res) => {
|
const makeRequest = (route, port) => [route, async (req, res) => {
|
||||||
|
console.log(`making post request to ${port}, ${route}`)
|
||||||
try {
|
try {
|
||||||
const { data } = await axios.post(invocationURL(5052), {
|
const { data } = await axios.post(invocationURL(port), {
|
||||||
body: JSON.stringify(req.body),
|
body: JSON.stringify(req.body),
|
||||||
})
|
})
|
||||||
res.status(data.statusCode)
|
res.status(data.statusCode)
|
||||||
@@ -21,20 +22,11 @@ app.post('/openscad/preview', async (req, res) => {
|
|||||||
res.status(500)
|
res.status(500)
|
||||||
res.send()
|
res.send()
|
||||||
}
|
}
|
||||||
})
|
}]
|
||||||
app.post('/cadquery/stl', async (req, res) => {
|
|
||||||
console.log('making post request to 5060')
|
app.post(...makeRequest('/openscad/preview', 5052))
|
||||||
try {
|
app.post(...makeRequest('/openscad/stl', 5053))
|
||||||
const { data } = await axios.post(invocationURL(5060), {
|
app.post(...makeRequest('/cadquery/stl', 5060))
|
||||||
body: JSON.stringify(req.body),
|
|
||||||
})
|
|
||||||
res.status(data.statusCode)
|
|
||||||
res.send(data.body)
|
|
||||||
} catch (e) {
|
|
||||||
res.status(500)
|
|
||||||
res.send()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
app.listen(port, () => {
|
app.listen(port, () => {
|
||||||
console.log(`Example app listening at http://localhost:${port}`)
|
console.log(`Example app listening at http://localhost:${port}`)
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ import {
|
|||||||
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
|
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
|
||||||
import { Vector3 } from 'three'
|
import { Vector3 } from 'three'
|
||||||
import { requestRender } from 'src/helpers/hooks/useIdeState'
|
import { requestRender } from 'src/helpers/hooks/useIdeState'
|
||||||
|
import texture from './dullFrontLitMetal.png'
|
||||||
|
import { TextureLoader } from 'three/src/loaders/TextureLoader'
|
||||||
|
|
||||||
|
const loader = new TextureLoader
|
||||||
|
const colorMap = loader.load(texture)
|
||||||
|
|
||||||
extend({ OrbitControls })
|
extend({ OrbitControls })
|
||||||
|
|
||||||
@@ -22,7 +27,7 @@ function Asset({ geometry: incomingGeo }) {
|
|||||||
return (
|
return (
|
||||||
<mesh ref={mesh} scale={[1, 1, 1]}>
|
<mesh ref={mesh} scale={[1, 1, 1]}>
|
||||||
<bufferGeometry attach="geometry" ref={ref} />
|
<bufferGeometry attach="geometry" ref={ref} />
|
||||||
<meshStandardMaterial color="#F472B6" />
|
<meshStandardMaterial map={colorMap} color="#F472B6" />
|
||||||
</mesh>
|
</mesh>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -193,8 +198,10 @@ const IdeViewer = ({ Loading }) => {
|
|||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ambientLight />
|
<ambientLight intensity={1} />
|
||||||
<pointLight position={[15, 5, 10]} />
|
<pointLight position={[15, 5, 10]} intensity={4} />
|
||||||
|
<pointLight position={[-1000, -1000, -1000]} intensity={1}/>
|
||||||
|
<pointLight position={[-1000, 0, 1000]} intensity={1}/>
|
||||||
{state.objectData?.type === 'png' && (
|
{state.objectData?.type === 'png' && (
|
||||||
<>
|
<>
|
||||||
<Sphere position={[0, 0, 0]} color={pink400} />
|
<Sphere position={[0, 0, 0]} color={pink400} />
|
||||||
|
|||||||
Reference in New Issue
Block a user