Skip to main content

Module assets

Module assets 

Source
Expand description

Asset import: OBJ / STL / GLB → Mesh + semantic NQuins (Phase 1.3). Asset-import bridge — OBJ / STL mesh → NQuin stream (Phase 1.3, RENDERER_IMPLEMENTATION_PLAN.md).

Pure &[u8] → (geometry, semantic NQuins). No std::fs — wasm-safe (migration review §2.1): the shell / CLI reads the file (or runs the OS picker) and hands the bytes down. This is the ingest path (not a hot path), so Vec / HashMap are fine — the same convention as kml_bridge.

Two layers, per STELLAR §E (“artefacts carry their geometry, and are semantically known”):

  • Mesh — raw geometry (vertex positions + triangle indices + bounding box): the data the GPU vertex/index buffers (Phase 1.2) will consume.
  • mesh_to_nquins — the semantic layer: the asset is known (type, counts, bounding box, centroid, source format) as NQuins in the one identity space — not just points/pixels.

Hot-path rendering (depth-stencil, mesh buffers, projection) is the GPU half of Phase 1 and is verified on hardware; this module is the CPU half and is unit-tested here.

Re-exports§

pub use glb_skins_anims::matrix4_to_motor_and_scale;
pub use glb_skins_anims::parse_glb_living_scene;
pub use glb_skins_anims::GlbInterpolation;
pub use glb_skins_anims::GlbLivingScene;
pub use glb_skins_anims::GlbMorphWeightTrack;
pub use glb_skins_anims::GlbNodeRecord;
pub use glb_skins_anims::KhrMaterialExtensions;
pub use glb_skins_anims::KhrPunctualLight;

Modules§

glb_skins_anims
Rigid glTF 2.0 / GLB → .10d Living Container Compiler (SKL1, MRP1, PROC1, EONT1, KHR Material Extensions & KHR_lights_punctual).

Structs§

ImportedMesh
Mesh plus optional normal and tangent streams. Tangents may be authored or generated from TEXCOORD_0; importers without the required data leave a stream empty for renderer fallback.
Mesh
Raw triangle-mesh geometry. The hot-path GPU buffers (Phase 1.2) consume positions + triangles; the bounding box is precomputed for the projection / culling layer (§E §4).
TextureDependency
Immutable image asset discovered while importing an embedded glTF image.

Enums§

AssetError
Error type for asset import.

Constants§

GEOMETRY_CONTEXT

Functions§

import_asset
Import a mesh, sniffing the format from the bytes (or trusting an explicit lowercase extension hint like "obj" / "stl").
import_asset_with_normals
Import a mesh and preserve authored normals when the source format provides them. Missing normals in individual primitives are generated from the primitive’s triangle geometry.
import_glb
Parse a binary glTF (.glb): the 12-byte header, JSON chunk, and BIN chunk, then walk meshes[].primitives[], reading POSITION (FLOAT VEC3), optional NORMAL (FLOAT VEC3), optional TANGENT (FLOAT VEC4), optional TEXCOORD_0 VEC2, and optional index accessors (u8/u16/u32 SCALAR) out of the BIN buffer. Triangle primitives only (mode 4); other modes are skipped (a faithful first cut). Embedded/external-URI buffers are not handled here — self-contained GLB binary only.
import_glb_static_scene
Import the selected static scene, baking each node instance and its frames. The caller supplies hard output limits before instances are expanded.
import_glb_with_normals
GLB importer variant that retains NORMAL VEC3 and TANGENT VEC4 attributes, generates fallback normals where needed, and uses MikkTSpace with deterministic corner splitting when UV0 is available but authored tangents are absent. Authored tangent directions are orthogonalized before returning GPU streams.
import_obj
Parse a Wavefront .obj: v x y z vertices and f faces (polygons fan-triangulated). Face tokens may be v, v/vt, v//vn, or v/vt/vn; indices are 1-based and may be negative (relative to the current vertex count). vt / vn / vp / groups are ignored for geometry.
import_stl
Parse a .stl (auto-detects binary vs ASCII). Each STL triangle contributes 3 fresh vertices (no welding) — a faithful, lossless first cut; vertex de-duplication is a later optimisation.
mesh_to_nquins
Emit the semantic quins for a mesh asset (the asset is known, not just drawn): its type, vertex/triangle counts, bounding box, centroid, and source format — all in GEOMETRY_CONTEXT, in the one identity space. Floats use the inline-float object tag (ADR 0008); counts are raw integers. The returned lexicon maps the asset-URI / format hashes back to their strings.
mesh_to_nquins_with_dev
Like mesh_to_nquins_with_digests but for a developmental body: also asserts the gestational t-axis coordinate — gestationalAgeDays (postfertilization) and carnegieStage. This is what makes a fetal .10d a slice of a 4-D developmental body: consecutive stages, ordered by gestational age, are the same body along the t-axis (reproductive-continuum plan §2). Both are plain u64 objects.
mesh_to_nquins_with_digests
Like mesh_to_nquins but also asserts the immutable sourceDigest and the .10d compiledDigest — the manifest→container join (geometry-asset-ontology §4). Both are CRC-32C u32 content hashes stored as u64 objects: sourceDigest over the immutable source asset bytes, compiledDigest the whole-file CRC of the .10d container this manifest describes.
mesh_to_nquins_with_meta
Like mesh_to_nquins_with_digests but also asserts the anatomy binding for a 3D-body organ: bodySystem (which of the 17 body systems this organ belongs to — which system’s burden colours it) and anatomyModel ("male" / "female" — the reference model whose set it is part of, chosen from the user’s declared XY/XX chromosomal basis). Both are string facts carried in the lexicon, like sourceFormat; a None field is simply not asserted.