HxSTLParser
HxSTLParser copied to clipboard
Binary STL support
Your project is wonderful!
As I know, stl file have Binary and Ascii two type , does your parser support both of them?
Glad to know it is useful for someone else. Currently, this library only supports ASCII-based STL files, although the binary version can be easily implemented using a simple finite state machine.
I'll try to add support to the binary format in the next week or so.
Here too: cudos on the project!
I was wondering if there's anything we can do to help with the binary format? Cheers, EP
Hi @epologee! Sorry taking so long to answer your question.
Implementing the binary format should be quite straightforward, and you can even reuse the current implementation. A simple finite state machine should be enough to parse the structure documented here and here. After reading the normal vector, vertexes, and discarding any defined attributes1, it would then just be a matter of instantiating SCNVector3
s and dealing with SceneKit's oddities (SCNGeometrySource
& friends).
Sadly I don't have enough time to work on this right now. PRs are super welcome! ✨
Best wishes!
[1] - No one should be using it, but we might want to be extra-cautious with binary formats.
Thanks for the links, @victorgama! The binary STL spec looks easier than the ascii one :)
I can't really make a PR on your repository, because I decided to parse the binary STL with Swift. Your HxSTLParser code was very essential in recreating this with Swift, even though I didn't go the state machine way for simplicity. Let me at least share it here, so maybe @tanqci can benefit from it as well:
https://gist.github.com/epologee/7373ea371812e8facd5a7a00e6b80d70