Skip to main content

Module model3d

Module model3d 

Source
Expand description

3D models: readers for the formats falcon can show itself (OBJ with MTL colours, STL, PLY, GLB, 3MF, FBX, COLLADA, 3DS and IFC), the triangle model they produce, the measurements Eagle’s model viewer shows, and the geometry the viewer and the thumbnail renderer share (normals, feature edges, shading).

IFC geometry comes from web-ifc when falcon is built with it; without it only tessellated IFC geometry is read, and IFC files without any keep their QuickLook still.

Modules§

dae
COLLADA (.dae), versions 1.4.1 and 1.5: XML read with roxmltree.
earclip
Triangulating flat polygons, concave ones and ones with holes, by ear clipping: each hole is joined to the outer loop by a bridge to a vertex it can see, then ears (convex corners with no other vertex inside) are cut off one by one. A 3D polygon is first projected onto the axis plane it faces most. Used by the IFC reader for faceted faces.
export
Writing a model back out, for the viewer’s Export: Wavefront OBJ (with an MTL of the material colours), binary STL, glTF 2.0 (binary GLB, or a .gltf with its buffer embedded), binary PLY and ASCII OFF. Only what falcon holds is written: positions, normals where the file had them, vertex colours, triangles and material colours (OFF keeps positions and triangles only). 3DM, which Eagle’s viewer also writes, is not.
fbx
FBX, binary and ASCII, read with ufbx (MIT, https://github.com/ufbx/ufbx).
geom
Geometry shared by the viewer and the thumbnail renderer: welding duplicate vertices, face and smooth normals, feature edges, the measurements Eagle’s viewer lists, and the lighting both draw with.
gltf
glTF 2.0: binary .glb and JSON .gltf with its buffers.
ifc
IFC (.ifc, the STEP text form). Geometry comes from web-ifc, the engine Eagle’s viewer uses, when falcon is built with it (scripts/fetch-web-ifc.sh; see [super::ifc_native]): extruded, revolved and swept solids, booleans and openings, CSG primitives, advanced breps and everything tessellated.
math
Small vector and matrix helpers for the 3D viewer and the thumbnail renderer. Vectors are [f32; 3]; matrices are column-major [[f32; 4]; 4] (m[column][row]), as WGSL reads them. The camera space is right-handed (the camera looks down −Z) and clip depth runs from 0 (near) to 1 (far), as wgpu expects.
obj
Wavefront OBJ, with colours and diffuse textures from its MTL library.
off
OFF (Object File Format), ASCII: an OFF line, <vertices> <faces> <edges>, one x y z line per vertex and one n a b c … line per face.
ply
PLY, ASCII and binary little-endian, with vertex colours.
raster
A software rasterizer for 3D model thumbnails, as Eagle makes them at import: the model is drawn in the viewer’s home view on a 1080 square with a transparent background, the empty border is cropped away and 40 transparent pixels are added on every side.
step
A reader for STEP physical files (ISO 10303-21, the text form IFC files use): the header’s schema name and the DATA; section’s instances, #id = ENTITY(args);, with nested lists, strings, enums, $, *, references and typed values such as IFCLABEL('x').
stl
STL, ASCII and binary.
texture
Textures of 3D models: the pictures a model’s materials map onto its surfaces, decoded to RGBA within a memory bound, and how the viewer and the thumbnail renderer sample them.
threeds
Autodesk 3D Studio .3ds files (binary, little-endian chunks).
threemf
3MF: a zip holding the model as XML.

Structs§

Material
A material as far as the viewer uses it: a name and a base colour.
Mesh
One part of a model: triangles over shared vertices, drawn in one material.
Model
A whole model: its meshes in file order.
ParseError
Why a file could not be read as a model.
Surface
What a material adds to its colour and picture, as far as Eagle’s viewer draws it. The maps are read with the mesh’s one set of coordinates (uvs) and are not drawn without them. A map that is missing or can’t be decoded is None and the surface draws as if the file had none.

Constants§

DEFAULT_COLOR
The colour a mesh without a material is drawn in, as in Eagle’s viewer (200, 200, 200), in 0..1.
EXTENSIONS
Extensions read here, lower case: Eagle’s model formats. A .gltf is a plain item with a QuickLook thumbnail, as in Eagle.

Functions§

is_supported
Whether files with extension ext (any case) are read here.
load
Reads the model at path, picking the reader by ext. Files a model refers to (an OBJ’s MTL, a GLB’s external buffers) are looked up next to it.
parse
Reads a model from bytes by extension. side fetches a file the model refers to by its relative name.

Type Aliases§

Result