entelechy-import自动生成
层:接口层 · 代码行数:3,016 · 集成测试文件:0
导入器:把模型、声音等导入为 Host 文件。
The importer: brings models and sounds in as the Host’s files, from outside the runtime
The importer’s readers (glTF/GLB, symphonia audio, standard MIDI, SVG,
TrueType and OpenType fonts), a library so the exporter’s tests can
read back what it wrote. The font reader is always there; the rest
are the audio, models and vector features, on by default.
| 内部依赖 | entelechy-formats, entelechy-host |
| 外部依赖 | serde_json, symphonia, ttf-parser, usvg |
| 源码 | crates/interface/import |
| 名称 | 简述 |
|---|---|
audio |
Compressed sound (MP3, OGG Vorbis, FLAC, AAC in MP4, …) decoded by symphonia into a 16-bit PCM WAV at the file’s own rate, one or two channels, which input reads. |
font |
A TrueType or OpenType font as Fields a scene’s Kernels lay out and draw: each glyph’s outline flattened to line segments in ems, y up, filled by the nonzero rule. ttf-parser reads the font (quadratic and cubic outlines, the character map). What is left out is named in the notes. |
font::sample |
A small TrueType font built from the format’s tables, so tests read a font without carrying one: 1000 units an em, a box for a missing character, a space, I, l, and an o of two loops of quadratic curves that dips just below the baseline. |
gltf |
glTF 2.0 as Fields: vertices as rows of {position, normal, uv}, triangles as rows of three indices, the base color texture as a PNG, and a skin’s weights, skeleton and clips. Node transforms are baked in; every mesh of the scene lands in one pair of rows, each triangle’s part (a node’s primitive) in a row of its own and the parts named by their node, mesh and material. What is left out is named in the notes. |
midi |
A MIDI file as a notes .field, read by entelechy_formats::midi, with what was left out named. |
svg |
An SVG document as the Fields the vector package draws: its paths, each fill and each stroke a shape in paint order, flattened to line segments in document units. usvg resolves the document (CSS, units, the viewBox, basic shapes, use, transforms, gradient units); a stroke becomes the outline it paints. What is left out is named in the notes. |
| 名称 | 简述 |
|---|---|
audio::Imported |
What an audio import produced. |
font::Imported |
What a font import produced. |
font::Fields |
The three Fields of a font. |
gltf::Imported |
What an import produced. |
midi::Imported |
What a MIDI import produced. |
svg::Imported |
What an SVG import produced. |
svg::Fields |
The four Fields of a drawing. |
| 函数 | 简述 |
|---|---|
fn import(path: &Path, out_dir: &Path) -> Result<Imported, String> |
Decodes path and writes <stem>.wav into out_dir. |
fn latin() -> Vec<u8> |
The font. |
fn import(path: &Path, out_dir: &Path, chars: Option<&str>) -> Result<Imported, String> |
Reads the font at path and writes the Fields of chars, or of every character it maps when none are given, into out_dir. |
fn read(bytes: &[u8], chars: Option<&str>) -> Result<(Fields, Imported), String> |
Reads a font into the Fields of chars (every mapped character when None) and what was left out. |
fn glyphs_of(bytes: &[u8], codes: &[i32]) -> Result<Fields, String> |
The Fields of the characters codes asks for, a glyph row each in the order asked (row k codes[k]’s), for a scene’s font node: a code the font lacks, or none (zero or below), is the missing glyph’s row with its code -1 and no outline; no codes, one such row. |
fn placeholder() -> Fields |
A font node’s Fields before its font is read, or when it cannot be: one row of the missing glyph’s (code -1, no outline), one segment of zeros, and zero measures. |
fn import(path: &Path, out_dir: &Path, rate: f32) -> Result<Imported, String> |
Reads path and writes into out_dir: <stem>.vertices.field, <stem>.triangles.field, and <stem>.albedo.png for a PNG texture. |
fn import(path: &Path, out_dir: &Path) -> Result<Imported, String> |
Reads path and writes <stem>.notes.field into out_dir. |
fn shape_schema() -> Schema |
A shape’s layout, as the vector package declares it: color: Vec4; first: Int; count: Int; rule: Int; paint: Int; lo: Vec2; hi: Vec2; gradient: Vec4; inverse: Vec4; shift: Vec2; stops: Int; stop_count: Int; spread: Int. |
fn stop_schema() -> Schema |
A stop’s layout: offset: Float; color: Vec4. |
fn import(path: &Path, out_dir: &Path) -> Result<Imported, String> |
Reads the SVG at path and writes its Fields into out_dir. |
fn read(bytes: &[u8]) -> Result<(Fields, Imported), String> |
Reads an SVG document into its Fields and what was left out. |
glyph_schema, metrics_schema, segment_schema, Note, Song, read, schema
audio::Imported
Section titled “audio::Imported”crates/interface/import/src/audio.rs#L16
What an audio import produced.
属性
| 名称 | 类型 | 说明 |
|---|---|---|
file |
PathBuf |
The WAV written. |
rate |
u32 |
Frames per second of the source. |
channels |
usize |
Channels kept: 1 or 2. |
frames |
usize |
Frames written. |
font::Imported
Section titled “font::Imported”crates/interface/import/src/font.rs#L27
What a font import produced.
属性
| 名称 | 类型 | 说明 |
|---|---|---|
files |
Vec<PathBuf> |
The files written. |
glyphs |
usize |
Characters imported, the missing glyph not counted. |
segments |
usize |
Segments over all glyphs. |
missing |
Vec<char> |
Characters asked for that the font lacks. |
notes |
Vec<String> |
What was left out, in words. |
实现的 Trait: Debug
font::Fields
Section titled “font::Fields”crates/interface/import/src/font.rs#L42
The three Fields of a font.
属性
| 名称 | 类型 | 说明 |
|---|---|---|
glyphs |
FieldData |
A row a glyph, in order of code. |
segments |
FieldData |
Rows<Vec4>, the segments. |
metrics |
FieldData |
Rows<Metrics>, the font’s measures. |
实现的 Trait: Debug
gltf::Imported
Section titled “gltf::Imported”crates/interface/import/src/gltf.rs#L18
What an import produced.
属性
| 名称 | 类型 | 说明 |
|---|---|---|
vertices |
usize |
Rows of vertices written. |
triangles |
usize |
Rows of triangles written. |
parts |
usize |
Parts the triangles came from: each node’s primitives, in the order their triangles are. |
texture |
Option<PathBuf> |
The texture file, when the model has a base color texture in PNG. |
notes |
Vec<String> |
Notes about what was left out. |
bounds |
([f32; 3], [f32; 3]) |
Corners of the model’s bounding box after transforms. |
joints |
usize |
Joints of the skin, when the model has one. |
clips |
Vec<(String, usize)> |
Each animation’s clip name and frame count. |
rate |
f32 |
Frames a second the clips were sampled at. |
files |
Vec<PathBuf> |
Every file written. |
midi::Imported
Section titled “midi::Imported”crates/interface/import/src/midi.rs#L9
What a MIDI import produced.
属性
| 名称 | 类型 | 说明 |
|---|---|---|
file |
PathBuf |
The Field written. |
notes |
Vec<Note> |
The notes, in order of when they start. |
seconds |
f32 |
How long the song is, in seconds. |
tracks |
usize |
The tracks the file holds. |
left_out |
Vec<String> |
What was left out, in words. |
svg::Imported
Section titled “svg::Imported”crates/interface/import/src/svg.rs#L45
What an SVG import produced.
属性
| 名称 | 类型 | 说明 |
|---|---|---|
files |
Vec<PathBuf> |
The files written. |
size |
(f32, f32) |
The document’s size in its own units. |
shapes |
usize |
Shapes drawn. |
segments |
usize |
Segments over all shapes. |
notes |
Vec<String> |
What was left out, in words. |
实现的 Trait: Debug
svg::Fields
Section titled “svg::Fields”crates/interface/import/src/svg.rs#L115
The four Fields of a drawing.
属性
| 名称 | 类型 | 说明 |
|---|---|---|
segments |
FieldData |
Rows<Vec4>, the segments. |
shapes |
FieldData |
Rows<Shape>, the shapes in paint order. |
stops |
FieldData |
Rows<Stop>, the gradients’ stops. |
view |
FieldData |
Rows<Vec2>, the document’s size. |
实现的 Trait: Debug

