CadQuery MVP integration #281
@@ -50,7 +50,7 @@ const IdeToolbarNew = ({ cadPackage }) => {
|
||||
}
|
||||
|
||||
return (
|
||||
<IdeContext.Provider value={{ state, thunkDispatch: thunkDispatch }}>
|
||||
<IdeContext.Provider value={{ state, thunkDispatch }}>
|
||||
<div className="h-full flex flex-col">
|
||||
<nav className="flex">
|
||||
<button
|
||||
|
||||
@@ -14,19 +14,19 @@ import { requestRender } from 'src/helpers/hooks/useIdeState'
|
||||
|
|
||||
|
||||
extend({ OrbitControls })
|
||||
|
||||
function Asset({ url }) {
|
||||
|
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
|
||||
function Asset({ stlData }) {
|
||||
|
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
|
||||
const [loadedGeometry, setLoadedGeometry] = useState()
|
||||
const mesh = useRef()
|
||||
const ref = useUpdate((geometry) => {
|
||||
geometry.attributes = loadedGeometry.attributes
|
||||
})
|
||||
useEffect(() => {
|
||||
if (url) {
|
||||
|
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
|
||||
const decoded = atob(url)
|
||||
|
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
|
||||
if (stlData) {
|
||||
|
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
|
||||
const decoded = atob(stlData)
|
||||
|
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
|
||||
const loader = new STLLoader()
|
||||
setLoadedGeometry(loader.parse(decoded))
|
||||
}
|
||||
}, [url])
|
||||
|
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
|
||||
}, [stlData])
|
||||
|
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
|
||||
if (!loadedGeometry) return null
|
||||
return (
|
||||
<mesh ref={mesh} scale={[1, 1, 1]}>
|
||||
@@ -228,7 +228,11 @@ const IdeViewer = () => {
|
||||
|
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
|
||||
</>
|
||||
)}
|
||||
{state.ideType === 'cadQuery' && (
|
||||
<Asset url={state.objectData?.data} />
|
||||
|
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
|
||||
<Asset
|
||||
|
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
|
||||
stlData={
|
||||
|
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
|
||||
state.objectData?.type === 'stl' && state.objectData?.data
|
||||
|
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
|
||||
}
|
||||
|
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
|
||||
/>
|
||||
|
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
|
||||
)}
|
||||
</Canvas>
|
||||
</div>
|
||||
|
||||
|
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
This is where the stl is loaded in for CadQuery. This is where the stl is loaded in for CadQuery.
|
||||
This is where the stl is loaded in for CadQuery.
This is where the stl is loaded in for CadQuery.