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.

Structs§

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

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_glb
Parse a binary glTF (.glb): the 12-byte header, JSON chunk, and BIN chunk, then walk meshes[].primitives[], reading each POSITION accessor (FLOAT VEC3) and the optional index accessor (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_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.