Skip to main content

SourceInfo

Struct SourceInfo 

Source
#[non_exhaustive]
pub struct SourceInfo {
Show 20 fields pub format: Option<String>, pub version: Option<String>, pub meters_per_unit: Fact<f64>, pub unit: Option<String>, pub up_axis: Fact<Axis>, pub forward_axis: Fact<Axis>, pub handedness: Fact<Handedness>, pub frame_rate: Fact<f64>, pub converted: Converted, pub tool: Option<String>, pub author: Option<String>, pub title: Option<String>, pub description: Option<String>, pub copyright: Option<String>, pub license: Option<String>, pub created: Option<String>, pub modified: Option<String>, pub keywords: Vec<String>, pub comments: Vec<String>, pub georeference: Option<Value>,
}
Expand description

What a model’s file says about itself (see the module docs, which read one).

Non-exhaustive, so that more of what files say can be added: read its fields, or, to write one with SourceInfo::write, start from SourceInfo::default (nothing known) and set them.

use polysmelt::source::{Fact, SourceInfo};

let mut info = SourceInfo::default();
info.tool = Some("my exporter".into());
info.meters_per_unit = Fact::Declared(0.001);
let mut source = serde_json::Map::new();
info.write(&mut source);
assert_eq!(source["metersPerUnit"], 0.001);
assert_eq!(SourceInfo::from_json(&source), info);

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§format: Option<String>

The format’s name: "FBX", "COLLADA", "Wavefront OBJ".

§version: Option<String>

The file’s version of its format, as it gives it.

§meters_per_unit: Fact<f64>

The length of the file’s unit, in meters.

§unit: Option<String>

The unit’s name, as the file or its format calls it ("millimeter", "inch").

§up_axis: Fact<Axis>

The file’s up axis.

§forward_axis: Fact<Axis>

The file’s forward axis, where it has one.

§handedness: Fact<Handedness>

The file’s handedness.

§frame_rate: Fact<f64>

Frames (or keys, or ticks) per second.

§converted: Converted

What the reader converted to glTF’s conventions.

§tool: Option<String>

The program that wrote the file.

§author: Option<String>

Who made it.

§title: Option<String>

Its title or name.

§description: Option<String>

A description or subject.

§copyright: Option<String>

Its copyright notice.

§license: Option<String>

Its license terms.

§created: Option<String>

When it was made: ISO 8601 when the file’s date can be read as one, else as written.

§modified: Option<String>

When it was last changed, likewise.

§keywords: Vec<String>

Keywords or tags.

§comments: Vec<String>

Comments the file holds, in order.

§georeference: Option<Value>

Where a scan or survey sits on Earth.

Implementations§

Source§

impl SourceInfo

Source

pub fn from_json(source: &Map<String, Value>) -> SourceInfo

Reads the keys of asset.extras.source it knows; the rest are ignored.

Source

pub fn write(&self, source: &mut Map<String, Value>)

Writes what’s known into source (as asset.extras.source), over what those keys held, leaving the rest: the format’s own keys, and any of these that are unknown here.

Source

pub fn output_meters_per_unit(&self) -> Fact<f64>

The length of a unit of the geometry as read, in meters: 1 when the reader converted the file’s units, else the file’s own unit (known, assumed or not).

Trait Implementations§

Source§

impl Clone for SourceInfo

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 Debug for SourceInfo

Source§

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

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

impl Default for SourceInfo

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for SourceInfo

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 StructuralPartialEq for SourceInfo

Auto Trait Implementations§

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<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, 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.