Skip to main content

Format

Enum Format 

Source
#[non_exhaustive]
pub enum Format {
Show 57 variants Stl, Ply, Vox, Obj, Fbx, ThreeDs, ThreeMf, Usd, Gltf, Vrm, SketchUp, Bvh, Collada, Off, X3d, Dxf, Splat, Spz, Sog, Las, Pcd, Xyz, Pts, Ptx, Asc, E57, Amf, Lwo, Ac3d, Pmx, Pmd, Vmd, DirectX, Md2, Md3, Md5Mesh, Md5Anim, Iqm, Smd, Vta, Ms3d, B3d, Asf, Amc, C3d, Trc, Htr, Ogre, Flt, Ogex, IrrMesh, Irr, Xgl, Vtk, Tiles, Gmsh, Medit,
}
Expand description

A model format Polysmelt reads, whether or not this build has its cargo feature.

open and read tell a model’s format from its extension and then from its first bytes; Loader::format names it outright.

use polysmelt::Format;
assert_eq!(Format::from_extension("GLB"), Some(Format::Gltf));
assert_eq!(Format::detect(b"Kaydara FBX Binary  \0"), Some(Format::Fbx));
assert_eq!(Format::Collada.extensions(), ["dae", "zae", "kmz"]);
assert_eq!(Format::Collada.name(), "COLLADA");

Each is behind a cargo feature of its name: 3ds and 3mf for those two, dae for COLLADA, xyz for the text point clouds, ac3d for .ac, mmd for PMX, PMD and VMD, directx for .x, asf for ASF and AMC, irr for Irrlicht’s two, md5 for MD5’s two, smd for SMD and VTA, gltf for glTF and VRM, las for LAS and LAZ (laz adds LAZ’s decompression), vtk for VTK’s legacy and XML files, tiles for 3D Tiles, msh for Gmsh, medit for Medit’s text and binary meshes.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Stl

STL, binary and ASCII (.stl).

§

Ply

PLY, ASCII and binary, with gaussian splats, plain or compressed (.ply).

§

Vox

MagicaVoxel (.vox).

§

Obj

Wavefront OBJ, with its MTL materials (.obj).

§

Fbx

FBX, binary and ASCII (.fbx).

§

ThreeDs

3D Studio (.3ds).

§

ThreeMf

3D Manufacturing Format (.3mf).

§

Usd

Universal Scene Description: text, binary and zipped (.usd, .usda, .usdc, .usdz).

§

Gltf

glTF 2.0 (and 1.0), JSON and binary (.gltf, .glb).

§

Vrm

VRM avatars and their animations (.vrm, .vrma).

§

SketchUp

SketchUp (.skp).

§

Bvh

BVH motion capture (.bvh).

§

Collada

COLLADA, and the .zae and .kmz archives that hold it (.dae, .zae, .kmz).

§

Off

Object File Format, ASCII and binary (.off).

§

X3d

X3D and VRML97, and their gzipped forms (.x3d, .x3dv, .x3dz, .wrl, .wrz).

§

Dxf

DXF meshes (.dxf).

§

Splat

Gaussian splats in the 32-byte layout (.splat).

§

Spz

Gaussian splats, gzipped (.spz).

§

Sog

SOG gaussian splats: a zip of a meta.json and its WebP images, or that meta.json beside them (.sog).

§

Las

LAS and LAZ lidar point clouds (.las, .laz).

§

Pcd

PCD point clouds (.pcd).

§

Xyz

Text point clouds, a point per line (.xyz).

§

Pts

Text point clouds, a point per line (.pts).

§

Ptx

Text point clouds of scans, each placed by its pose (.ptx).

§

Asc

Text point clouds, a point per line, or ESRI ASCII grids (.asc).

§

E57

E57 3D scans (.e57).

§

Amf

Additive Manufacturing File Format (.amf).

§

Lwo

LightWave objects (.lwo).

§

Ac3d

AC3D (.ac).

§

Pmx

MikuMikuDance PMX models (.pmx).

§

Pmd

MikuMikuDance PMD models (.pmd).

§

Vmd

MikuMikuDance VMD motions (.vmd).

§

DirectX

DirectX .x: text, binary and compressed (.x).

§

Md2

Quake II models (.md2).

§

Md3

Quake III models (.md3).

§

Md5Mesh

Doom 3 skeletal meshes (.md5mesh).

§

Md5Anim

Doom 3 skeletal animations (.md5anim).

§

Iqm

Inter-Quake Model (.iqm).

§

Smd

Valve SMD reference and animation files (.smd).

§

Vta

Valve VTA vertex animation (.vta).

§

Ms3d

MilkShape 3D (.ms3d).

§

B3d

Blitz3D (.b3d).

§

Asf

Acclaim ASF skeletons (.asf).

§

Amc

Acclaim AMC motions (.amc).

§

C3d

C3D motion capture (.c3d).

§

Trc

TRC marker motion capture (.trc).

§

Htr

HTR motion capture (.htr).

§

Ogre

OGRE meshes and skeletons, binary and XML, with .material scripts (.mesh, .skeleton; .mesh.xml and .skeleton.xml are told from their root element).

§

Flt

OpenFlight (.flt).

§

Ogex

OpenGEX (.ogex).

§

IrrMesh

Irrlicht meshes (.irrmesh).

§

Irr

Irrlicht scenes (.irr).

§

Xgl

XGL, and zipped ZGL (.xgl, .zgl).

§

Vtk

VTK: legacy files, and XML poly data and unstructured grids (.vtk, .vtp, .vtu).

§

Tiles

OGC 3D Tiles: batched, instanced, point cloud and composite tiles (.b3dm, .i3dm, .pnts, .cmpt), and a tileset.json of them, which has no extension of its own and is told by its content.

§

Gmsh

Gmsh meshes, ASCII and binary (.msh).

§

Medit

Medit (INRIA) meshes: binary .meshb, and text .mesh, an extension OGRE’s meshes have too, so those are told by their first bytes.

Implementations§

Source§

impl Format

Source

pub fn all() -> impl ExactSizeIterator<Item = Format> + Clone

Every format, in the order they’re listed here.

Source

pub fn from_extension(ext: &str) -> Option<Format>

The format whose extension is ext (in any case, with or without its dot); None for one that names none, xml among them: an .xml file is told by its root element.

Source

pub fn detect(bytes: &[u8]) -> Option<Format>

The format of a model whose bytes (all of them, or its start) are bytes, told from its signature or first words; None when they don’t say. A binary STL, which has no signature, is told only from all of its bytes.

Source

pub fn extensions(self) -> &'static [&'static str]

The format’s extensions, without their dots, the usual one first.

Source

pub fn name(self) -> &'static str

The format’s name, as people write it: "glTF", "COLLADA", "MagicaVoxel".

Trait Implementations§

Source§

impl Clone for Format

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Format

Source§

impl Debug for Format

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Format

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Format

Source§

impl Hash for Format

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Format

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for Format

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Format

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Format

Auto Trait Implementations§

§

impl Forget for Format

§

impl Freeze for Format

§

impl Move for Format

§

impl RefUnwindSafe for Format

§

impl Send for Format

§

impl Sync for Format

§

impl Unpin for Format

§

impl UnsafeUnpin for Format

§

impl UnwindSafe for Format

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.