gizlang/models
the meshes of model files of other formats than glTF, in glTF's frame (Y up, meters, right-handed), so that gizlang/gltf reads them and a game draws them the same way as a glTF file. A binary FBX file (version 7.x, as Autodesk tools and game engines export it) is placed by its models' transforms; ASCII FBX, skins and animation are not read. A Wavefront OBJ file (as survey scans and modeling tools write it) is taken as meters with Y up, and its MTL library names its maps. Its files are named without case, as on Windows where they are made: it asks for each in lower case.
import * as Models from "gizlang/models";Types
Mesh
type Mesh = { name: string; positions: Vec<f32>; normals: Vec<f32>; uvs: Vec<f32>; triangles: Vec<i64>; color: string; normal: string; roughness: string; }One material's part of a model: its corners' positions (x, y, z), normals and texture coordinates (u, v; v grows down the image, as in glTF), its triangles, and the files of its color, normal and roughness maps that the model names ("": none).
name:stringpositions:Vec<f32>normals:Vec<f32>uvs:Vec<f32>triangles:Vec<i64>color:stringnormal:stringroughness:string
Model
type Model = { meshes: Vec<Mesh>; files: Map<string, bytes>; }A model file read: its meshes, and the files it holds in itself (an FBX file's embedded maps) by the names its meshes give them.
meshes:Vec<gizlang_models.Mesh>files:_gizlang_sdk_collections.Map<string, bytes>
Property
type Property = { kind: string; number: f64; text: string; data: bytes; }A property of a record: KIND is its FBX type code (Y C I F D L S R, or f d i l b for arrays). A scalar is in NUMBER, a string or raw data in TEXT and DATA; an array's count is in NUMBER and its values, little endian, in DATA (item).
kind:stringnumber:f64text:stringdata:bytes
Record
type Record = { name: string; properties: Vec<Property>; children: Vec<Record>; }A record of the file's tree.
name:stringproperties:Vec<gizlang_models.Property>children:Vec<gizlang_models.Record>
Functions
is
function is(data: bytes): boolWhether DATA is a model file of a format this module reads.
Effects: fail, alloc.
read
function read(data: bytes, resolve: (uri: string) => bytes throws string): Model throws stringThe model file DATA; RESOLVE reads a file it names (an OBJ file's MTL library) by its name.
Effects: fail, read, write, console, io, alloc.
records
function records(data: bytes): Vec<Record> throws stringThe top records of the binary FBX file DATA.
Effects: fail, alloc.
item
function item(p: Property, k: i64): f64Value K of the array property P. An array stays in its bytes: a scan's arrays are hundreds of megabytes.
Effects: fail.
child
function child(r: Record, name: string): Record | undefinedThe first child of R named NAME.
Effects: fail.