Skip to content

How to load STL file #1267

Answered by drcmda
mic-tientpn asked this question in Q&A
Apr 22, 2021 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

stlloader is not part of objloader

import { STLLoader } from 'three/examples/jsm/loaders/STLLoader'

the error message tells you what you did TypeError: Proto is not a constructor you give it undefined as the loader.

return gltf ? : null

you don't need to check against null, it will never be null, and you can't just return the output.

import scene = useLoader(STLLoader, url)
return <primitive object={scene} />

that is ... if STLLoader really gives you a scene, i have never used it. but if you want to dump an existing object into the scene then you do that with primitive.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mic-tientpn
Comment options

@drcmda
Comment options

@mic-tientpn
Comment options

Answer selected by mic-tientpn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1265 on April 22, 2021 12:22.