Fix bug where images was being converted to stl and erroring
This commit is contained in:
@@ -50,7 +50,7 @@ const IdeToolbarNew = ({ cadPackage }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IdeContext.Provider value={{ state, thunkDispatch: thunkDispatch }}>
|
<IdeContext.Provider value={{ state, thunkDispatch }}>
|
||||||
<div className="h-full flex flex-col">
|
<div className="h-full flex flex-col">
|
||||||
<nav className="flex">
|
<nav className="flex">
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -14,19 +14,19 @@ import { requestRender } from 'src/helpers/hooks/useIdeState'
|
|||||||
|
|
||||||
extend({ OrbitControls })
|
extend({ OrbitControls })
|
||||||
|
|
||||||
function Asset({ url }) {
|
function Asset({ stlData }) {
|
||||||
const [loadedGeometry, setLoadedGeometry] = useState()
|
const [loadedGeometry, setLoadedGeometry] = useState()
|
||||||
const mesh = useRef()
|
const mesh = useRef()
|
||||||
const ref = useUpdate((geometry) => {
|
const ref = useUpdate((geometry) => {
|
||||||
geometry.attributes = loadedGeometry.attributes
|
geometry.attributes = loadedGeometry.attributes
|
||||||
})
|
})
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (url) {
|
if (stlData) {
|
||||||
const decoded = atob(url)
|
const decoded = atob(stlData)
|
||||||
const loader = new STLLoader()
|
const loader = new STLLoader()
|
||||||
setLoadedGeometry(loader.parse(decoded))
|
setLoadedGeometry(loader.parse(decoded))
|
||||||
}
|
}
|
||||||
}, [url])
|
}, [stlData])
|
||||||
if (!loadedGeometry) return null
|
if (!loadedGeometry) return null
|
||||||
return (
|
return (
|
||||||
<mesh ref={mesh} scale={[1, 1, 1]}>
|
<mesh ref={mesh} scale={[1, 1, 1]}>
|
||||||
@@ -228,7 +228,11 @@ const IdeViewer = () => {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{state.ideType === 'cadQuery' && (
|
{state.ideType === 'cadQuery' && (
|
||||||
<Asset url={state.objectData?.data} />
|
<Asset
|
||||||
|
stlData={
|
||||||
|
state.objectData?.type === 'stl' && state.objectData?.data
|
||||||
|
}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</Canvas>
|
</Canvas>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user