#[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
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: ConvertedWhat the reader converted to glTF’s conventions.
tool: Option<String>The program that wrote the file.
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
impl SourceInfo
Sourcepub fn from_json(source: &Map<String, Value>) -> SourceInfo
pub fn from_json(source: &Map<String, Value>) -> SourceInfo
Reads the keys of asset.extras.source it knows; the rest are ignored.
Sourcepub fn write(&self, source: &mut Map<String, Value>)
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.
Sourcepub fn output_meters_per_unit(&self) -> Fact<f64>
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).