STL support in FreeX3D

Last update: 21 July 2013


FreeX3D presents your STL images in different ways; you are free to choose an STL loading scheme that best suits what you want to do.


FreeX3D can read both ASCII and Binary STL formats; here is a Wikipedia entry that describes very well the STL format.

All Binary and almost all ASCII STL files can be loaded. Binary files load very fast; ASCII files are slower; there is a lot of computing going on to read the ASCII data. Almost all ASCII files found on the Internet (or, generated by your programs) use three vertices per face; FreeX3D assumes that all ASCII STL files use this 3-vertices scheme.

The Info screen will show the progress of ASCII STL parsing, and will give some statistics based on which loading option is chosen.

"Original", "Check", "Nicest" Preference Setting

Original rendering shows the model as received, with normal facets in grey, and backward-facing facets drawn in red. Facets are drawn creased, even if the facets make up a smoothly curved surface. No run-time optimizations are done on this setting, so the option can have a slower (not as silky smooth) frame rate, and can use more battery power to render. This is how many STL renderer programs render your models.

Check rendering looks for Watertight and Manifold issues, and tries to optimize the model for rendering speed and visual niceness. Some examples of incorrect manifold or watertight are shown on the Examples page.

Nicest tries very hard to optimize the model for fastest, most efficient rendering. It will not perform the Watertight and Manifold checks. Nicest rendering can make a big difference - the "Love" model mentioned below runs 37 frames per sec on an Acer Iconia tablet, the "Original" form of the model renders at 3fps; That makes a huge difference when viewing the model.

Samples of STL Rendering

Model memory usage and renderability are closely tied on all computers, but especially on mobile devices. FreeX3D takes an unstructured STL file, sorts vertices, and identifies shared vertices, or ones close. It also removes degenerate triangles (which by definition can not be a "face" or "facet").

Image Description
first image The "Love" model. This is rendered in "Original" mode, as described in the STL format.

This is how simplistic STL renderers would display this model.

Note that you can see creases on curved surfaces; compare this to the next screenshot.

This is 1,762 triangles, 5,286 vertices.

It renders at 3 fps on an Acer Iconia tablet, making for a very jerky viewing experience.

first image vertex reduction "Nicest" rendering. Normals generated; vertices in close proximity found and tagged. Note how curved surfaces are visually smooth.

3 degenerate triangles found, reduction from 5,286 vertices down to 877 - a huge savings on memory, and visually better.

It renders at 37 fps on an Acer Iconia tablet - over 10x faster than the "Original" rendering.

Crease Angle

For determining proper lighting (and, good CAM generation) vertices shared between facets have their normals averaged.

However, sometimes, hard angles (non-smoothed normals) are required, to show creases and corners, much like the "Love" example, above.

At the moment, the crease angle is fixed in FreeX3D, but expect it to be a user-settable preference in a future version of FreeX3D.

Image Description
first image "F16" model. Crease angle set to 0. No smoothing of normals; the rendering is "chunky". This is the rendering method used in "Original" STL rendering.
first image "F16" model. Crease angle set appropriately. Model looks much smoother than the image above.

This is the current "default" value for crease angles in FreeX3D when using the "Check" or "Nicest" STL rendering option.

first image The "Love" model with crease angle too high. This is included to show you what can happen visually when the crease angle is set incorrectly.

Vertex Proximity

We can also see which vertices are "close" to each other, and if close, only keep 1 of these. For on-screen rendering, this approach is fine, although one can create holes in the geometry.

The "closeness-factor" is determined by the STL loading setting, "Original" does not group vertices, "Check" does some vertex reduction, while "Nicest" tries to be quite agressive in its vertex reduction.

Below are three examples of vertex reduction; you can see that if FreeX3D is too agressive, viewing issues appear.

Image Description
first image Rocket model. Vertices have to be really close to be considered duplicate. This model looks ok when enlarged.

97,890 vertices read from original model; 15,877 vertices written, 6,488 degenerate triangles found.

This is the current "default" value for Vertex Proximity in FreeX3D.

first image Vertices that are "kind of" close have been combined; if you click on the image, you can see some holes starting to appear, but the small image looks fine.

97,890 vertices read from original model; 12,477 vertices written, 15,422 degenerate triangles found.

first image Needless to say, our vertex reduction here went too far...

97,890 vertices read from original model; 2,740 vertices written, 29,911 degenerate triangles found.

FreeX3D History

FreeX3D is a value-added version of FreeWRL. STL layering and model manipulation has been overlaid on the FreeWRL X3D engine.

From circa 1999 to April 2010, the FreeWRL project was managed by John A. Stewart.

There is absolutely no warranty, express or implied for this software. For details on the conditions of use, see the FreeWRL distribution.

FreeWRL is Copyright (C) 1998, 1999...2009 Tuomas J. Lukka, John Stewart and others.

The FreeWRL library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

The FreeWRL library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. Logo