Skip to main content

Module anatomy_assets

Module anatomy_assets 

Source
Expand description

S5.8 — the asset cache + real-mesh acquisition path (user-triggered).

The interim visual (anatomy_render.rs) renders a coloured silhouette because the real 3D body needs ~200–290 MB of CCF/HRA GLB downloads with no cache. This module is the user-triggered acquisition + cache: when the person clicks “Download body assets” in the Studio UI, the host discovers the reference-organ manifest from the HRA SPARQL endpoint, fetches each GLB from its CDN URL, compiles it to a sealed .10d (via anatomy_body::compile_body), and writes both the raw GLB and the compiled .10d to a gitignored cache under {storage_root}/assets/ccf/{model}/. Subsequent runs load the cached .10d directly — no re-download. The cache is the person’s own, generated on demand.

The discover/fetch are blocking network I/O (reqwest blocking, off the async runtime via spawn_blocking in the desktop command). The compile is pure CPU. Progress is reported per organ so the UI can show a real progress bar. Everything is honest about what did and did not cache — failed fetches/compiles are reported, never silently dropped.

Structs§

AcquireProgress
Per-organ progress reported during acquisition — drives the UI progress bar.
AcquireReport
The final report from an acquisition run — honest about what did and did not cache.
BodyAssetsStatus
The status of a model’s cache — what the UI shows to decide “download” vs “view”.
CacheManifest
The cache manifest — records what was acquired, when, and from where.
CachedOrganEntry
One entry in the cache manifest — a cached organ with its source URL + sizes.

Functions§

acquire_body_assets
Acquire + cache the body assets for a model — user-triggered, blocking network I/O. Discovers the reference-organ manifest from the HRA SPARQL endpoint, fetches each GLB, compiles it to .10d, and writes both + a manifest to the cache. Progress is reported via progress per organ. Failed fetches/compiles are reported in the result, never silently dropped. The cache directory is created on demand; an existing cache is refreshed (re-fetched + re-compiled) so the person can update.
acquire_body_assets_controlled
Cancellable form used by the desktop job centre. Cancellation is checked between remote fetches and before/after the bounded compile phase, so a request never leaves a half-written manifest.
cache_dir
The cache root for a model: {storage_root}/assets/ccf/{model}/.
cached_organ_keys
The cached organ keys for a model (empty if not cached).
clear_cache
Delete the cache for a model (idempotent — no-op if not cached).
glb_path
Where a raw GLB is cached: {cache_dir}/glb/{organ_key}.
is_cached
Whether the cache is present and complete (manifest exists + every referenced .10d is on disk).
load_cached_10d
Load a cached .10d for one organ. Returns Err if not cached or the file is unreadable.
load_manifest
Load the cache manifest, or None if not cached.
manifest_path
Where the cache manifest lives: {cache_dir}/manifest.json.
status
The status of a model’s cache (cached = manifest present + every referenced .10d on disk).
ten_d_path
Where a compiled .10d is cached: {cache_dir}/10d/{organ_key}.10d.