Summary.
STL, OBJ, VTK and GLTF Viewer.
For educational purposes only.
Uses Three.js to load, display, and manipulate a model read from a
file.
The center of the model bounding box
is translated to the origin so an arcball like
controller can rotate the model.
The app interface was designed for mobile devices,
and the whole (vastly commented) code is only about a thousand lines of
Vanilla JS code.
I am not a designer, and none of the models used here were made by me.
The sources of the models
are in the links below, and I would like to thank their authors.
Four file formats are currently supported:
- STL
is a file format commonly used for 3D printing and computer-aided design (CAD).
The name STL is an acronym that stands for stereolithography — a popular 3D printing technology.
You might also hear it referred to as Standard Triangle Language or Standard Tessellation Language.
STL does not support an indexed geometry. That is why it has multiple
duplicate vertices on all triangles (explicit representation),
and each vertex borrows its normal from the triangle it belongs to.
As a consequence, at the same position,
there are multiple normal vectors. This leads to a non-smooth surface
when using the normal attribute for lighting calculation.
Therefore, some magical code is necessary to
smooth
the model by
applying mergeVertices
to its BufferGeometry
followed by a
recalculation
of their normals.
- OBJ
(or .OBJ) is a geometry definition file format first developed by Wavefront Technologies
for its Advanced Visualizer animation package.
The file format is open and has been adopted by other 3D graphics application vendors.
MTL file, short for Material Template Library, is companion file format used in 3D computer graphics and modeling.
It is often associated with Wavefront OBJ file format,
which is common format for storing 3D models and their associated materials and textures.
- VTK
provides a number of source and writer objects to read and write popular data file formats.
The Visualization Toolkit also provides some of its own file formats.
The main reason for creating yet another data file format is to offer a consistent data representation scheme
for a variety of dataset types, and to provide a simple method to communicate data between software.
- GLTF
glTF (Graphics Library Transmission Format or GL Transmission Format and formerly known as WebGL Transmissions Format or WebGL TF)
is a standard file format for three-dimensional scenes and models.
A glTF file uses one of two possible file extensions: .gltf (JSON/ASCII) or .glb (binary).
Both .gltf and .glb files may reference external binary and texture resources.
Notes:
- Since:
- Author:
-
- Copyright:
- © 2024 Paulo R Cavalcanti.
- License:
- Source:
- See:
-