Reference · Build a mesh and a drawing
toGlbfunction
Writes parts into one small binary glTF file, in Node or a browser, with no dependency: one node for each part and one primitive for each material. The same parts always give the same bytes.
Import it
import { toGlb } from "@johnmorrisdotca/uchusen-rockets/build";
Definition
function toGlb(parts: readonly GlbPart[]): Glb
Parameters
| Name | Type | Description |
|---|---|---|
parts | readonly GlbPart[] | The parts to write: each has a node name, its mesh and where it stands in metres. |
Returns
Glb
The file's bytes and its triangle count.
Examples
import { build, toGlb } from "@johnmorrisdotca/uchusen-rockets/build";
const rocket = build({ rocket: "falcon-9", variant: "block-5" });
const glb = toGlb(rocket.parts.map((part) => ({ name: part.slot, mesh: part.mesh, at: [0, 0, 0] as const })));
console.log(glb.bytes.length > 1000, glb.triangles > 0);true trueWhat it prints (run when this page was built)