Skip to content

Instantly share code, notes, and snippets.

@yaeda
Last active February 8, 2022 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaeda/27a51bc95cfd41a0c33a25d28f72ddae to your computer and use it in GitHub Desktop.
Save yaeda/27a51bc95cfd41a0c33a25d28f72ddae to your computer and use it in GitHub Desktop.
useSTL
const useSTL = (path) => {
return useLoader(STLLoader, path)
}
useSTL.preload = (path) => useLoader.preload(STLLoader, path)
useSTL.clear = (input) => useLoader.clear(STLLoader, input)
const ModelSTL = () => {
const stl = useSTL(stlPath)
return (
<mesh>
<primitive object={stl} attach="geometry" />
<meshStandardMaterial
attach="material"
color="#fff"
transparent
roughness={0}
metalness={0}
/>
</mesh>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment