X-Ray.3D
26.10.7528
dotnet add package X-Ray.3D --version 26.10.7528
NuGet\Install-Package X-Ray.3D -Version 26.10.7528
<PackageReference Include="X-Ray.3D" Version="26.10.7528" />
<PackageVersion Include="X-Ray.3D" Version="26.10.7528" />
<PackageReference Include="X-Ray.3D" />
paket add X-Ray.3D --version 26.10.7528
#r "nuget: X-Ray.3D, 26.10.7528"
#:package X-Ray.3D@26.10.7528
#addin nuget:?package=X-Ray.3D&version=26.10.7528
#tool nuget:?package=X-Ray.3D&version=26.10.7528
X-Ray.3D: 3D and CAD files for .NET
X-Ray.3D (assembly and namespace XRay.ThreeD, identifies 3D and CAD
files, extracts their metadata (part and assembly names, component files, layers, units, document properties,
previews) and converts their geometry to binary glTF (.glb), the format browsers load directly. Pure managed
code, no dependencies beyond the BCL, no native binaries.
using XRay.ThreeD;
// Metadata only: cheap, no mesh is built.
ModelMetadata meta = ModelLoader.ReadMetadata("gearbox.sldasm");
Console.WriteLine($"{meta.Format.Name} {meta.DocumentKind}, {meta.Application}");
foreach (var file in meta.ComponentFiles) Console.WriteLine($"needs {file}");
foreach (var p in meta.Properties) Console.WriteLine($"{p.Name} = {p.Value}");
// Convert: bytes in, GLB bytes out.
byte[] glb = ModelLoader.ConvertToGlb(File.ReadAllBytes("gearbox.sldasm"), "gearbox.sldasm");
// Or keep the scene graph and inspect it first.
Model3D model = ModelLoader.Load("gearbox.sldasm");
foreach (var node in model.Nodes()) Console.WriteLine(node.Name);
File.WriteAllBytes("gearbox.glb", GlbWriter.ToArray(model));
A command line tool lives in tools/XRay.ThreeD.Cli: xray3d info <file> [--json], xray3d convert <file> [out.glb],
xray3d formats.
Formats
| Format | Extensions | Metadata | Geometry |
|---|---|---|---|
| SolidWorks (2015+, and 2014 and earlier) | .sldprt .sldasm .slddrw |
document and custom properties, configurations, features, part names, component files, preview | the display mesh SolidWorks saved, assemblies as instances placed by their transforms (external component files through LoadOptions.ResolveCompanion), drawings as their sheet images at paper size (SVG output); ReadMetadata does not inflate the display lists. SolidWorks 2014 and earlier (an OLE compound file with __ZLB zlib chunks, read through Internal/CompoundFile) load the same way: metadata from the OLE property sets and the XML streams, the display mesh from the same payload; 77 real files from public repositories (2012 to 2014 saves: parts and assemblies) match an independent scan on vertex counts and bounds. Drawings of that era were not available to check |
| STL | .stl (binary, ASCII) |
solid name | welded triangles |
| Wavefront OBJ | .obj |
objects, material names, mtllib |
objects as nodes, material groups, normals, texture coordinates; with companions the MTL's map_Kd image (options -s, -o, -clamp; BMP and TGA converted to PNG) |
| PLY | .ply (ASCII, binary LE/BE) |
comments | triangles, vertex colours, normals; no faces = point cloud |
| glTF 2.0 | .glb .gltf |
scene, node names, extras, materials, generator | node tree, shared meshes, PBR base colours, TEXCOORD_0 and base-colour textures (samplers, KHR_texture_transform; images from buffer views, data URIs or companions); EXT_meshopt_compression and KHR_draco_mesh_compression (EdgeBreaker and sequential, all attribute codings) decoded; external .bin files through companions |
| 3MF | .3mf |
title, designer, units, materials | objects, components, build transforms, base-material colours, texture2d/texture2dgroup textures |
| AutoCAD DXF | .dxf (ASCII) |
version, units, layers (colour, visibility), blocks, text, entity counts, dates | one node per layer; lines, polylines, arcs, splines, hatch outlines as lines; 3D faces, polyface meshes, MESH, solids as triangles; blocks and arrays expanded; TEXT/MTEXT/ATTRIB as positioned text and SOLID/solid HATCH as filled areas (Model3D.Texts, Fills); drawings are flagged Is2D and convert to SVG |
| STEP | .step .stp .p21 |
header, product tree, descriptions, versions, materials, layers, units | B-rep faces triangulated (planes, quadrics, tori, B-spline, revolution, extrusion; faceted B-reps), AP242 tessellated solids, shells and faces (triangles, strips, fans, point indexes, normals), NAUO assembly instances and MAPPED_ITEM/REPRESENTATION_MAP instances (nested, one shared mesh), STYLED_ITEM colours, presentation layers on nodes (layer); area and volume match OpenCASCADE within 0.3% |
| IFC | .ifc .ifczip (STEP physical file), .ifcxml (XML encoding) |
header, schema, units, project/site/building/storey tree, GlobalIds, property sets and quantities (node extras), materials | face sets (triangulated, polygonal), faceted B-reps and surface models, extruded solids (rectangle, circle, hollow, polyline and indexed-curve profiles with voids), mapped items, local placement chains; other representations leave a node and a warning. The XML encoding is converted back to STEP entities with embedded schema tables (IFC2X3, IFC4, IFC4X3: attribute order, inverse nesting such as IsDecomposedBy, selects, defined types, href references) and read by the same builder; checked against the STEP twin of a buildingSMART sample and a hand-written pair |
| Rhino 3DM | .3dm |
version (50 and later: Rhino 5 to 8), application, author, dates, revision, notes, units and tolerances, layers (paths, visibility, colours), materials, block names, user strings, object counts | points, point clouds, lines, polylines, arcs and NURBS curves sampled to line segments, meshes (vertex colours, normals, 16 and 32 bit faces, deflated buffers), B-reps and extrusions through the display meshes the file saved with them, block definitions and references as shared meshes under transforms, per-object colour, layer colour and material; counts and extents match rhino3dm on every fixture and on real Rhino 7 and 8 files. Not read (counted in a warning): B-reps saved without display meshes, surfaces, extrusions without meshes, poly-curves, SubD, text, hatches, lights |
| ACIS SAT / SAB | .sat .sab |
save version (105 to 700 and the Autodesk ShapeManager binary 21800/22300), producer, units, body and face counts | bodies, faces and their loops, coedges and edges tessellated with the STEP machinery: planes, cylinders and cones, spheres, tori, straight and elliptical edges; transforms (row-vector) as node transforms, colours (rgb_color attributes); polyhedra match ezdxf's loader exactly, curved solids match closed forms, and real NIST saves are watertight with every face meshed. Not read (warned): spline surfaces and intersection/interpolated curves, cone half-angle sign conventions are unverified (all cones in the samples are cylinders), wires, subshells, names |
| Autodesk DWF / DWFx | .dwf .dwfx |
version, manifest sections, sheet titles, paper size and units, preview image when present, 3D sections listed | 2D drawings: DWF 6 W2D text streams (colours, polylines, text with font height and rotation, the descriptor's scale and extents) and DWFx/XPS pages (paths with M/L/H/V/C/Q/Z, strokes and fills, glyph runs, canvas transforms), several sheets side by side; written as SVG or drawn as line meshes. Counts, extents, texts and paper size match a second parse of every dataset stream. Not decoded (warned): binary W2D streams, W3D 3D sections, bitmaps and signatures, XPS arcs (drawn as chords), brushes other than solid colours |
| Siemens NX, Solid Edge | .prt (SPLMSSTR), .par .psm .asm |
none beyond the B-rep | the largest Parasolid transmit stream in the file (stored raw or zlib-compressed; Solid Edge's OLE streams are searched too, untested for lack of a sample), read by the Parasolid reader; checked on two NIST NX parts (one gives geometry); assemblies, feature bodies and metadata are not read |
| Parasolid | .x_t .x_b .xmt_txt .xmt_bin |
transmit header: modeller version, schema key, encoding, application, user, dates and the **PART1 fields |
text transmit files (.x_t) of the schemas 10xxx (Parasolid 10, checked on a real SolidWorks 98Plus file: an assembly of four bars, bounds and volume in closed form), 12006 to 13006, the plain schemas 15003 to 35102 (the base with the edits of each revision) and files that embed their schema as edits to the 13006 base (checked on real Ansys Electronics Desktop exports of schemas 32001 and 35102) (field lists written from the public XT format reference, Siemens April 2008, and cross-checked against the V30 tables of the MIT-licensed parasolid-kit): assemblies with instance transforms, bodies, regions, shells, faces, loops, fins, edges (lines, circles, ellipses, B-curves, intersection charts, ring edges without vertices), vertices, planes, cylinders, cones, spheres, tori and B-surfaces (NURBS, rational and periodic), colour (SDL/TYSA_COLOUR) and name attributes, units (metres). Binary transmit files (.x_b, .xmt_bin; big-endian, optionally behind the text preamble) are read with the same layouts (the primitives from the MIT-licensed parasolid-kit's description of the encoding; checked by writing the nodes of the real files above in binary and loading both). Not decoded: Parasolid 11 and 9 files (11: both known layouts are tried, none was seen), blended surfaces (the face is flat-filled when its boundary is planar, otherwise skipped with a warning); swept (extrusion), spun (revolution) and offset surfaces are tessellated through their definition curves, and SP-curves (a spline in the parameter space of a surface) through the surface; these are refused with UnsupportedModelFormatException naming the schema |
| OpenSCAD | .scad |
title (first comment), Customizer parameters (grouped literals), colours | the program is evaluated: cube, sphere, cylinder, polyhedron, square, circle, polygon, translate/rotate/scale/mirror/multmatrix/resize, color, for/if/let, modules with children, functions, list comprehensions, linear_extrude (twist, scale, slices), rotate_extrude, offset (mitred), hull; difference and intersection are computed by a BSP-tree boolean (area and volume of the rook and bracket within 0.1% of a sampled estimate; union combines operands without merging). Not computed, with a warning: minkowski (drawn as a union), projection, text, import/surface, 2D intersections and 2D cuts that cross an outline, rounded offsets. Very curved twisted booleans fragment heavily |
| IGES | .igs .iges |
start and global sections (names, units, author, dates, version), entity counts by type | lines, arcs, copious-data paths and rational B-spline curves sampled as line meshes by level and colour, placed by transformation matrices; surfaces tessellated with the STEP reader's machinery: rational B-spline surfaces (128), planes (108, 190), revolution (120), tabulated cylinders (122), cylinders, cones, spheres and tori (192 to 198), trimmed (144) and bounded (143) surfaces with their 142/141 boundaries, B-rep faces, loops and shells (510, 508, 514) and manifold solids (186) with colours and levels; area, volume and bounds match OpenCASCADE's IGES reader within 0.6% / 1.2% on real exports and OpenCASCADE-written files. Also 114 parametric spline surfaces (bicubic patches as one cubic B-spline surface), 118 ruled surfaces (twisted strips subdivided), free-standing 108 planes bounded by a curve, and 112 parametric spline curves, checked against OpenCASCADE on synthetic files. Open: ruled and spline surfaces as trimming targets (118), unbounded planes |
| FreeCAD | .FCStd |
document properties, every object (label, type, properties), Group/Links/origin tree, placements, colours, preview thumbnail | objects with meshes embedded as STL, OBJ, PLY, OFF or 3MF; B-rep shapes (.brp) and .bms meshes are listed, not drawn |
| G-code | .gcode .gco .nc .ngc |
slicer and header values, layer count and height, units, move and arc counts | G0/G1/G2/G3 (centre and radius arcs, three planes, helical), absolute/relative, G20/G21, G92; line meshes: extrusion and travel (printer) or cut and rapid (CNC) |
| ZIP packages | .zip |
the primary model's metadata, plus container, entry and the other models in the package (ComponentFiles) |
the model with the best extension (glb, gltf, 3mf, usdz, fbx, dae, obj, ply, stl, step, ... last gcode; largest of a kind) is loaded with the package as its companions: an OBJ finds its .mtl (diffuse colour, opacity, shininess) by relative path or file name; a model that fails falls through to the next; LoadOptions.ResolveCompanion does the same for loose files |
| Sweet Home 3D | .sh3d (Home.xml) |
name, version, levels, walls, rooms, the furniture list with catalogue ids, sizes, prices | furniture from its embedded OBJ model fitted to width, depth and height (shared meshes), a box when the model is missing; walls as boxes, rooms as floors; levels as layered nodes |
| FBX | .fbx (binary, ASCII) |
scene, node and material names | meshes, node transforms, materials |
| COLLADA | .dae |
asset, units, up axis, node names | geometry, scene graph, effect colours |
| X3D / VRML | .x3d .x3dv .wrl |
titles, meta, DEF names | shapes, transforms, colours |
| USD | .usda, .usdc, .usdz |
stage metadata, prim names, units | meshes, xforms (matrix, translate, Euler, scale, orient), display colours, materials and geom subsets, primitives, same-file references. The binary crate (versions 0.4 and later: LZ4, compressed integer and float arrays) is read from the public format description and checked against pxr; a USDZ's root layer may be text or crate. References and payloads to other layers (loose files through LoadOptions.ResolveCompanion, members of a USDZ), sublayers, authored variant selections and the first time sample (text layers), and UsdUVTexture diffuse textures with primvars:st (text layers) match pxr's composition on a multi-layer fixture. Open: payloads, variants, time samples and texture connections in crate layers, variant selections by fallback, inherits/specializes, instancing |
| Blitz3D | .b3d (BB3D) |
version, brush names | node tree, meshes, per-triangle brushes (colour, shininess, first texture via companions), normals, vertex colours, first UV set; mirrored from the left-handed source on Z; bones and animation skipped. The Bazis furniture container (also .b3d, BZ85) gives its title only |
| Blender | .blend |
version, scene name and unit scale, collections (as layers), object and material names; gzip (before 3.0) and Zstandard (3.0 and later) containers | the file's own SDNA catalogue drives the read, so Blender 2.81 to 5.2 files open (checked against Blender's Python module on real 2.81, 2.90, 2.93, 3.3, 3.4, 4.4 files and a synthetic 5.2 one): first scene's collection tree (excluded and hidden collections and objects left out), parent hierarchy with parent-inverse matrices, location/rotation (all Euler orders, quaternion, axis-angle)/scale, collection instances with their offset; meshes from the legacy layout (2.8 to 3.4) and the attribute layouts (3.5 to 4.x, and 5.x attribute storage) with n-gons triangulated, flat/smooth shading, UV set 0, per-material groups, Principled BSDF colour/metallic/roughness/alpha. Not applied: modifiers, geometry nodes, shape keys, armatures, constraints, animation (base mesh in rest pose); textures, curves, lights and cameras are reported, not exported |
| Archicad | .gsm (library parts; .pln and .pla project files are recognised by extension only) |
GUID and revision GUID, author and licence, parameter list with defaults, preview image, every GDL script as text | the 3D geometry from running the master and 3D scripts through a GDL interpreter: BLOCK, CYLIND, CONE, SPHERE, PRISM and PRISM_ (arcs), BASE/VERT/EDGE/PGON/BODY polyhedra, materials, loops, branches, subroutines and the transformation stack. Statements not interpreted (REVOLVE, EXTRUDE, SWEEP, TUBE, RULED, text, 2D scripts) are listed as warnings. Checked on the two real library parts of the dataset against a separate parse and closed forms, and on a synthetic part |
| SketchUp | .skp (SketchUp 3 to 26) |
version and release year, thumbnail PNG (ReadPreview), for 2021+ the package structure: materials with colour, opacity and texture, tags, styles; geometry (Load; 2021+ from model.dat, 2013 to 2020 from the MFC object stream): vertices, edges, faces with holes (triangulated), groups and components with transforms (shared meshes), material colours, textures with UV mapping, tags |
back-face materials, edge display, section planes, text and dimensions are not read. Checked on 55 real public files against an independent reader (metadata) and all 54 with geometry (24 of 2021+, 30 of 2013 to 2020; counts and bounds) |
| JT | .jt (JT 8.0 to 10.5, ISO 14306) |
version, segment table; the logical scene graph (assemblies of parts and instances with transforms, names, materials, per-part meta data properties), shape geometry of triangle-strip-set LODs (finest level of a range LOD): topologically compressed meshes of JT 9 and 10 with vertices and normals, JT 8 quantised and lossless strips; zlib and xz segments | B-rep (XT) segments, PMI, polyline and point set shapes, JT 10.5 segments with the newer integer codec ("mark 2 codec 5"), external part files of assemblies, units (not stored in the format), textures. Checked on 16 real files against the JT Open toolkit's own JSON (counts and coordinate sums of every shape of five files; local samples) |
| 3DXML | .3dxml (ZIP package or a single XML document) |
header, product structure (references, instances with relative matrices, names, PLM_ExternalID, V_* attributes), tessellated representations (vertex buffer, triangles, strips, fans, RGBA colours; levels of detail skipped), shared references share one mesh |
binary CGR, exact (B-rep) representations, material domains, textures and edges are not read. Checked on the public CATIA quad example (local) and committed synthetic files |
| CATIA V5 | .CATPart, .CATProduct, .CATDrawing, .CATShape, .cgr |
container and stream directory; save version (LastSaveVersion, minimal version to read), document kind, product and part names, document links (the files a product or part refers to, the path it was saved at), instance names, JPEG preview; geometry: the display tessellation a part stores (vertex table, per-face triangle lists and strips, per-face RGBA colours), one body per table, faces kept, units mm, Z up |
a .CATProduct loads as an assembly when its component files are supplied through LoadOptions.ResolveCompanion (instances with stored placements, nested products; names that cannot be matched to a file give a warning); the exact B-rep, assembly constraints, feature tree, parameters and mass properties are not read; a .cgr file and a .CATShape were not available, so those are untested; CATIA V4 .model is not attempted. Checked on 75 real files R18 to R32 (seven MIT-licensed ones committed) and synthetic files: every tessellation is a closed oriented surface, a part and its mirror enclose the same volume. See docs/catia-format.md |
| Fusion 360 | .f3d, .f3z |
manifest: document type, display name, description, GUIDs, asset folders, lineage URN, asset type and revision, capabilities; part or assembly (Properties.dat), configuration names, B-rep stream inventory, archive members and design description of .f3z; previews when the package has them |
the exact B-rep: the ASM binary streams of Breps.BlobParts (.smbh, else .smb) through the ACIS reader and tessellator, centimetres; .f3z loads its root document. Not decoded: display buffers (OGS), design records (timeline, sketches, parameters, body map), spline-type faces the ACIS tessellator skips. Zstandard (ZIP method 93) entries are read through the RFC 8878 decoder. Checked on a real CC0 file and synthetic packages |
| Unity package | .unitypackage |
asset list with paths and kinds (ComponentFiles, PartNames, per-kind counts), project folder as title |
prefabs and scenes saved as text YAML (GameObject/Transform tree, MeshFilter, MeshRenderer, nested prefab instances with transform overrides, material colour and main texture), text-serialised Mesh assets (vertex channels, sub-meshes), model files in the package (FBX, OBJ, COLLADA, glTF, ...) loaded by their readers, mirrored from Unity's left-handed space. Binary-serialised assets, compressed or skinned meshes, terrain and the sub-mesh a model-file reference selects are not read |
| PlayStation 2 save | .psu |
save directory, title and icon names from icon.sys (Shift-JIS), file list, creation and modification times |
the icon models (.ico): triangles with normals, texture coordinates, vertex colours (first animation shape) and the 128 x 128 RGB555 texture (raw or run-length coded), flipped from the console's y-down 4.12 fixed point; animation keys are counted, not applied |
| Relief height map | .rlf |
the banner: name, date, size in pixels and millimetres, height range, position, vertical resolution, pixel size | none: the raster uses a proprietary compression without public description; Load throws UnsupportedModelFormatException |
| 3DS, AMF, OFF | .3ds .amf .off |
names, units, materials | triangles, colours |
| ASTM E57 | .e57 |
file and scan GUIDs, names, descriptions, sensor fields, scan poses, creation time, point counts, CRC-32C page check (Notes), CRS string, embedded JPEG/PNG image as preview |
points of every scan with points coded by the default bit-pack codec: Cartesian or spherical coordinates (Float, ScaledInteger, Integer fields), colour (limits applied) or intensity as grey, invalid-state points dropped, poses applied; counts, bounds and coordinate sums match pye57 (libE57Format) on a two-scan fixture and on real exports (a Cartesian scan with pose, a spherical scanner export). Other codecs, normals, point groupings and 2D image projections are not read |
| Point clouds | .las .laz .pcd .xyz .pts |
header, point counts, bounds, CRS where given | points with colours. LAZ (LASzip) is decoded by a pure C# range decoder: chunked, unchunked and layered coding, point types 0 to 3 (POINT10, GPS time, RGB, extra bytes) written from the public LASzip description and types 6 to 10 (the layered 1.4 coding with its four scanner-channel contexts: POINT14, RGB14, RGBNIR14, WAVEPACKET14, extra bytes) ported from laz-rs (Apache-2.0, see THIRD_PARTY_NOTICES.md); decoded records are byte-identical to the C++ LASzip and lazrs on the fixtures. Uncompressed LAS 1.4 formats 6 to 10 are read too. PLY gaussian splats: colour from the spherical-harmonic DC term, opacity as alpha, extents in MeshData.SplatScales |
| Unreal Engine package | .uasset .umap |
package summary (legacy, UE4/UE5 file versions, saved-by engine, flags), name, import and export tables with class names, outers and paths (nodes), tagged properties of each export (ints, floats, bools, names, strings, objects, enums; the rest listed by type and size), saved thumbnail | StaticMesh exports of editor-saved UE4 packages: the raw mesh bulk data (positions, wedge indices, normals, UV set 0, per-face materials) as an unwelded triangle mesh, mirrored from the left-handed centimetre space; volume and bounds match an independent parse. Cooked render data (vertex and index buffers of cooked LODs), UE5 bulk layouts, compressed bulk data, skeletal meshes and other asset classes are not decoded |
| DWG | .dwg |
release (AC1012 to AC1032), code page, section table, preview image (ModelLoader.ReadPreview; DIB converted to PNG, WMF, PNG; for AC1018 and later from the preview page), the object count, the layer names and $INSUNITS (AC1015 and later; the header variables are decoded one by one in release order, checked against the DXF twins) |
AC1015, AC1018, AC1021, AC1024, AC1027 and AC1032 (AutoCAD 2000, 2004, 2007, 2010, 2013, 2018). AC1021 keeps its sections in Reed-Solomon coded pages with an LZ77 variant of its own (ported opcode table, see THIRD_PARTY_NOTICES.md); the objects then follow the AC1018 decoders with UTF-16 strings. AC1018 and its successors keep their sections in numbered pages (encrypted header block, LZ77 compressed page map and section map, masked data page headers); the objects are decoded from those sections into the tables and entities of a DXF file and built by the DXF reader, so lines, circles, arcs, ellipses, splines, 2D/3D/mesh polylines, LWPOLYLINE, points, 3DFACE, SOLID/TRACE, TEXT, MTEXT, attributes, hatches (outlines, solid fills), dimensions (as the anonymous block each draws), inserts and blocks, rays and construction lines come with their layers, colours (by layer, by block, index and true colour) and units. Checked entity by entity (type, handle, coordinates, layer) against the DXF twin of one Autodesk-exported drawing in each release read with ezdxf: all lines, points, circles, arcs, polylines, hatches, MTEXT and SOLIDs match in every release. Not decoded: ACIS solids and regions, leaders and multileaders, MLINE, viewports and paper space, images/wipeouts, AC1012/AC1014 geometry; Text of AC1015 and AC1018 is read in the code page of the file header (a table of 44 Windows and ISO pages; untested beyond 1252, 1251, 1255 and Shift-JIS decoding of known bytes); splines stored by fit points only get their control points and knots computed (cubic, chord length, checked against AutoCAD's own dump) |
| Inventor, Revit | .ipt .iam .idw, .rvt .rfa .rft |
OLE compound file (a small CFB reader: FAT, DIFAT, mini stream, bounded chains). Property sets are found by format id (Inventor names its streams after hashes): summary and document summary (title, author, dates, application, company), thumbnail (PNG behind Inventor's 8-byte header, or PNG/DIB, via ModelLoader.ReadPreview); Inventor also design tracking (part number, description, material, appearance, designer, document subtype, build), the last save, the user-defined parameters by name, and the documents an assembly refers to (UTF-16 paths in UFRxDoc). Revit: the BasicFileInfo text (also the Revit 2019+ layout, where binary fields leave the text on an odd offset), the zipped Atom ProjectInformation (title, save time, project fields), TransmissionData (linked files into ComponentFiles), the Revit builds that saved it (Global/Latest, gzip) and the PNG in RevitPreview* |
none: proprietary geometry is not decoded. Checked against an independent reader (olefile, zipfile, zlib) on real Revit 2015, 2017, 2021 and Inventor 2021 to 2023 files (not redistributable; local samples, golden values committed) and on committed synthetic files in the same layouts |
| Recognised only | 3DM, ... | the format is named | UnsupportedModelFormatException |
ModelFormats.All lists everything the library can name. Detection looks at the content first (magic bytes, ZIP
entry names) and the file name second.
Drawings as SVG
A model whose content is a drawing (Model3D.Is2D: a DXF with nothing out of its plane, a SolidWorks drawing, planar curve-only
IGES) can be written as SVG instead of GLB: ModelLoader.ConvertToSvg(bytes, name) or SvgWriter.ToString(model). One <g> per layer
(id, data-name, hidden layers display="none"), strokes with the layer or entity colour and a constant pixel width, real
<text> (height, rotation, anchor; multi-line as <tspan>), filled areas (even-odd, so hatch holes work), meshes that several nodes
share defined once in <defs> and placed with <use>, Y flipped to screen space, a viewBox from the drawing's bounds, and the
model's metadata in <metadata> and data-* attributes. GLB stays the output for 3D: a 3D model is refused unless
SvgWriteOptions.ProjectFlat asks for its top view. The CLI writes .svg for drawings (xray3d convert part.dxf).
Why GLB
glTF 2.0 carries a node hierarchy with names, shared meshes (instancing), PBR materials, and arbitrary extras
for per-node and per-model metadata; every web 3D engine loads it, and the reference viewer's own exporter and
HTML export use it. Other targets lose the assembly structure (STL, OBJ, PLY are flat) or are print- or AR-oriented
(3MF, USDZ). The writer puts the source's units and up axis in asset.extras, and normalises to meters and Y-up
with a root node transform, so vertex data stays as stored.
What goes where in the GLB:
asset.extras: format, document kind, application, title, author, dates,sourceUnits,sourceUpAxis,partNames,layers,configurations,materials,componentFiles,properties[].node.extras: per-node properties (SolidWorks:instancePath,file; 3MF:partNumber; glTF: the source extras),layer.- An instanced part is one glTF mesh referenced by several nodes.
Output profile for a renderer
GlbWriteOptions selects what the GLB carries; the defaults suit CAD:
| Feature | How | Option |
|---|---|---|
| Assembly structure | one node per component instance with its transform and properties; one mesh per unique part shared by its instances | always |
| Face identity (picking, highlighting) | mesh.extras.faceRanges: (first index, index count) per source face, indices in primitive order |
IncludeMetadata |
| Colours and materials | one primitive per material, PBR base colour, metallic/roughness (SolidWorks: from the saved appearance, metals detected by family) | always |
| Textures | TEXCOORD_0, one embedded PNG/JPEG/WebP image per used texture, samplers (wrap, filter), KHR_texture_transform when a transform is set (glTF convention: v grows downwards; OBJ and 3MF readers flip v) |
always |
| Edges | a LINES primitive per CAD mesh (extras.role = "edges"): face boundaries, open borders, creases over the crease angle |
Edges (Auto, None, All) |
| Size | Quantize: 16-bit positions with the dequantisation folded into the node matrices (a node that has both a mesh and children gets the mesh on an extra child node carrying the frame, so the children do not inherit it), 8-bit normals and colours. Meshopt: also meshopt-compressed vertices and indices with octahedral normals (about 4x smaller than plain for the sample assembly) |
Compression |
| Draw calls | Gpu: sibling instances of one mesh merged with EXT_mesh_gpu_instancing; names and properties move to extras.instances |
Instancing (uncompressed output only) |
| Normals | for triangle meshes without any (welded STL, bare PLY; CAD meshes with source faces are left alone): Smooth (area weighted, over the welded vertices) or Flat (per triangle, unwelded); default none |
Normals |
| Far-from-origin meshes | a mesh far from the origin compared with its size is stored around its own centre (float32 precision); the centre goes into the nodes and into mesh.extras.origin |
RecentreFarModels (on) |
| Lazy loading | AssemblyPackage: assembly.json (instance tree, metadata) plus one GLB per unique part |
AssemblyPackage.Create |
ConvertToGlb of a GLB input returns it unchanged (after it loaded cleanly) unless options are given.
Units
ModelMetadata.Units is the unit of the stored coordinates; the writer scales to meters exactly once, with the root node. A scale that is not a named
unit (a Blender scene at 0.0125, an FBX with UnitScaleFactor 0.5, an IFC project that defines its own conversion-based unit, an X3D UNIT length
statement) is reported as meters plus a scaling root node and a note. What each format says:
| Format | Unit | Source of the unit |
|---|---|---|
| STL, OBJ, PLY, OFF, 3DS, XYZ, PTS, OpenSCAD (mm by convention), Blitz3D, PSU | none stated (OpenSCAD: mm) | LoadOptions.AssumedUnits |
| glTF, GLB, X3D, VRML | meters (an X3D unit element or x3dv UNIT length rescales) |
the specification |
| 3MF, AMF | unit attribute (3MF: micron, millimeter, centimeter, inch, foot, meter; AMF: inch, millimeter, meter, feet, micrometer; both default to millimeter) |
the file |
| COLLADA | <unit meter=...> |
the file |
| FBX | GlobalSettings.UnitScaleFactor is centimetres per unit (default 1 = cm, 100 = m) |
the file |
| USD | metersPerUnit (the schema's fallback, when it is not authored, is centimetres) |
the file |
| DXF, DWG | $INSUNITS (the AutoCAD table; angstrom, decametre, hectometre and larger have no LengthUnit); for a DXF with $INSUNITS 0, $MEASUREMENT picks inches (0) or millimetres (1). A DWG with $INSUNITS 0 states nothing |
the file |
| IGES | global section unit flag and name | the file |
| STEP | SI_UNIT with prefix, CONVERSION_BASED_UNIT (inch, foot) |
the file (default mm with a note) |
| IFC | IfcSIUnit prefix, IfcConversionBasedUnit through its IfcMeasureWithUnit factor |
the file (default meters with a note) |
| SolidWorks, Parasolid | meters | the format |
| CATIA, 3DXML, FreeCAD | millimetres | the format |
| Fusion (ASM streams) | centimetres | the format |
| ACIS SAT/SAB | millimetres per unit from the header; a save before version 2 has no unit line and is left unknown | the file |
| Rhino | the document's unit system | the file |
| SketchUp | inches | the format |
| Blender | one Blender unit is scene.unit_settings.scale_length metres (the length unit the interface shows only changes how numbers are printed); unit system None ignores the scale |
the file |
| Unity | meters (FBX inside a package: its own scale) | the format |
| Unreal | centimetres | the format |
| Sweet Home 3D | centimetres | the format |
| G-code | G20 inches, G21 millimetres | the file |
| LAS, LAZ, E57 | meters nominally; the CRS property says what the units really are | the file |
| DWF | descriptor units | the file |
| JT | not stored | LoadOptions.AssumedUnits |
LoadOptions.AssumedUnits and AssumedUpAxis fill in what a file does not say: always for STL, OBJ, PLY, OFF, 3DS, XYZ, PTS and OpenSCAD, and for any other format
only when the file gave none (an ACIS save before version 2, a DWG with $INSUNITS 0, a JT, a Blitz3D model). A unit the file states is never overridden. An unknown unit is
written as meters (nothing is scaled) and carries no sourceUnits.
Solids, open surfaces and the volume
ModelStatistics.Volume is the volume of the closed, outward-facing meshes only (instances counted per use, a mirrored instance positive). A mesh encloses space
when, after welding its vertices by position (1e-5 of its bounding box diagonal), every edge is used equally often in both directions: no border, no edge wound
against its neighbour. Two solids that touch along an edge share a non-manifold edge and still count. MeshData.AnalyzeTopology() returns the
MeshTopology of one mesh (IsClosed, IsSolid, IsInsideOut, OpenEdges, NonManifoldEdges, InconsistentEdges, SignedVolume); ModelStatistics
adds ClosedMeshes, OpenMeshes, InsideOutMeshes, OpenEdges, NonManifoldEdges, InconsistentEdges, VolumeIsComplete (every mesh is a solid) and
SignedVolume (the old figure: the signed sum over every mesh, meaningless for an open surface). Each triangle mesh's GLB mesh.extras carries the same verdict
(closed, openEdges, nonManifoldEdges, inconsistentEdges, insideOut) for the whole mesh: a closed solid with two materials is two glTF primitives, each open on
its own, so a viewer that tests primitives one by one calls it open; test the glTF mesh, or read these extras.
Openness that is the source's, not a defect of the readers (ClosedSolidsTests lists every dataset file with the number of open meshes and why): sheets and
surfaces (quads, floors, planes, IGES bounded, ruled and spline surfaces, Parasolid sheet bodies, terrain and height fields, flat polygons), tubes and boxes left open by
their artist (tentacle, forest arena boxes, character meshes, the faucet's holes), meshes with overlapping or zero-area triangles (the Unity key meshes: 48 edges of
the key ring are used twice in one direction in the asset itself, read independently of the reader), point clouds and line drawings (no triangles), and display tessellations whose
faces are meshed independently (SolidWorks parts keep the file's T-junctions: the reference reader's counts are the specification). Known reader defects still open: spherical fillet
faces of Fusion/ASM bodies, one missing triangle at the pole of an IGES sphere cap, trimmed IGES faces whose senses disagree.
Quantize, Meshopt and Gpu files declare their extensions as required (three.js loads them with the meshopt decoder set).
Reading handles them all, so ModelLoader.Load accepts what GlbWriter writes.
Robustness
Every reader takes hostile input: bounds-checked reads, limits on size and triangle count (LoadOptions),
cancellation, and nothing but ModelFormatException escapes a load. Non-finite coordinates are repaired.
Truncation and mutation tests run over every loadable fixture.
Layout
| Path | What |
|---|---|
src/XRay.ThreeD/ |
the library: Model/ scene model, Formats/ readers, Output/GlbWriter, ModelLoader |
tests/XRay.ThreeD.Tests/ |
xUnit v3 on Microsoft.Testing.Platform |
tools/XRay.ThreeD.Cli/ |
xray3d |
tools/fixtures/, tools/oracle/ |
fixture generator; golden-value generator for the SolidWorks tests |
dataset/ |
test files with licences, see dataset/README.md |
docs/ |
solidworks-format.md and research/ (notes on the reference viewer) |
Licence: MIT. Dataset files keep their own licences (dataset/manifest.json).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 26.10.7528 | 785 | 10/30/2026 |
| 26.10.7520 | 94 | 10/30/2026 |
| 26.10.7519 | 93 | 10/30/2026 |