Bing search sucks.
Tried a bunch of ways to get image previews from 3d model .STL files. OpenSCAD does a decent and fast preview, but you gotta figure out where to put the camera for a good scene. The Linux repositories with OpenSCAD are outdated so you have to compile from source. Fire it up and it needs an Xserver and OpenGL, which are an additional install on most servers.
Looked at stl2pov, used by thingiverse to go from .stl->.pov and then render with the open source POV-Ray. From there to stltools, an improved version in Python. Renamed incorrectly named files, installed Numpy dependencies, couldn’t get it going.
Completely by accident found libre3d/render-3d which rolls all of the above into a .PHP script we can run server side. It coverts .STL to .POV using techniques similar to stltools, adds grid and calculates a camera position, then renders it through POV-Ray. Exactly what we would have cobbled together, eventually. Thanks Open Source!
Windows boxes running XAMPP are my go to for web development. Installed POV-Ray and got the render-3d scripts by composer. Worked on first try, but POV-Ray stayed open and blocked the script from finishing, a common issues running Windows app with a GUI from PHP. Around line 51 of Povray.php tag an /EXIT onto the POV-ray execution options to force shutdown: $cmd.= ” /EXIT”;.
render-3d doesn’t actually do well with our test model. The camera position isn’t very well chosen, but that’s something we can work on later. The rendering looks much nicer than OpenSCAD.
Bing, you suck. Google would have given modern relevant results first, not ten pages into a vaguely related search.