Skip to main content

Crate oxihuman_wasm

Crate oxihuman_wasm 

Source
Expand description

WebAssembly (and native) bindings for the OxiHuman morph engine.

The main type is WasmEngine, a thin wrapper around oxihuman_morph::engine::HumanEngine that exposes a flat, JavaScript- friendly API. In native builds it works exactly the same way — useful for server-side rendering or CLI tools that embed the WASM surface.

§Buffer protocol

WasmEngine::build_mesh_bytes returns a compact binary buffer. The layout is described by BUFFER_FORMAT_VERSION:

[version: u32 LE]
[n_verts: u32 LE]
[n_idx:   u32 LE]
[positions: f32 * 3 * n_verts]
[normals:   f32 * 3 * n_verts]
[uvs:       f32 * 2 * n_verts]
[indices:   u32 * n_idx]

§JavaScript usage example

import init, { WasmEngine } from './oxihuman_wasm.js';

await init();
const engine = WasmEngine.new_from_obj_bytes(objBytes);
engine.set_height(0.8);
engine.set_weight(0.4);
const buf = engine.build_mesh_bytes();          // Uint8Array
const view = new DataView(buf.buffer);
const nVerts = view.getUint32(4, true);         // little-endian
// upload positions starting at byte offset 12 to WebGL / WebGPU

Re-exports§

pub use buffer::parse_mesh_bytes_header;
pub use engine::Particle;
pub use engine::ParticleSystem;
pub use engine::WasmEngine;

Modules§

buffer
Buffer serialization and parsing utilities for mesh data transfer.
buffer_transfer
Zero-copy buffer management between Rust/WASM and JavaScript.
compressed_target
Compressed morph target loading — pure Rust, no C/Fortran dependencies.
engine
Core engine logic: WasmEngine struct and its implementation. The implementation is split into focused sub-modules declared in lib.rs.
error
Error types for the oxihuman-wasm crate.
memory_profile
Memory pressure profiling for the OxiHuman WASM runtime.
pack
ZIP pack scanning utilities for loading asset packs in-memory.
service_worker
Offline asset caching strategy and service-worker code generation.

Constants§

BUFFER_FORMAT_VERSION
Buffer format tag for the raw mesh bytes returned by build_mesh_bytes(). Layout: [n_verts: u32 LE][n_idx: u32 LE][positions: f323n][normals: f323n][uvs: f322n][indices: u32*m]