bryan wong
bryan wong

Reputation: 239

Rendering large STL files in threejs

I have this stl model that has >3 million vertices and have to render it on screen. Right now, loading the model using a Threejs STL loader crashes the browser. Based on some research, I'm considering doing some of the following:

  1. Stream the STL file to the client and have the STL loader load the model in 1mb chunks

  2. Every time a chunk gets loaded, I can create a buffer geometry and construct a mesh from it. I can do this for every chunk and add all the meshes to the scene. Thus the scene will have multiple meshes in it, but look like it's the original model.

I have a pretty good idea of how to do step 2, but is the first part possible? Can a three.js STL loader load an STL in chunks (assuming it's being delivered to the client in chunks) as I've described?

Upvotes: 0

Views: 795

Answers (1)

griffin2000
griffin2000

Reputation: 779

The Three.js STL loader won't do that for you (it will always load the whole file and then parse).

You'd have to load and parse the file in chunks yourself. It is a pretty straightforward file format (https://en.wikipedia.org/wiki/STL_(file_format) ), you'd have to handle the case where a STL triangle structure spans chunks, however.

Another option, if it makes sense for your application, is to read and preprocess the file into a format that can be read in chunks in the browser.

Upvotes: 1

Related Questions