Skip to content
Shapemetry

glTF, USD, and Drawing Export

Beyond faceted mesh formats, @huukhanhnguyen/io carries presentation-grade writers: glTF/GLB and USD for scenes, DXF/SVG/PDF for drawings. This page is the map — signatures and options live in the generated Io reference.

glTF / GLB

Two doors per direction. The geometry door round-trips one document:

import { writeGlb, readGlb } from '@huukhanhnguyen/io'
import { Brep } from '@huukhanhnguyen/geometry'

const glb: Uint8Array = writeGlb(Brep.box(10, 10, 10)) // POSITION + NORMAL + indices, no materials
const back = readGlb(glb)                                // faceted B-Rep document

The scene door writes a real glTF scene — Z-up millimeters → Y-up meters, PBR materials, hierarchy, skins, morphs, animations, lights, cameras:

import { tessellationToGlb, tessellationToGltfZip, entitiesFromGlb } from '@huukhanhnguyen/io'

const glb = tessellationToGlb(entities, { materials })
const zip = tessellationToGltfZip(entities, { materials }) // model.gltf + buffer.bin + PNGs

const { entities: imported, materials: mats, triangleCount } = entitiesFromGlb(glb)

USD

Writers only, and deliberately tessellated mesh only — exact B-Rep interchange stays on STEP/IGES:

import { tessellationToUsda, tessellationToUsdz, buildUsdDocument } from '@huukhanhnguyen/io'

const usda: string = tessellationToUsda(entities, options)    // primary layer text
const usdz: Uint8Array = tessellationToUsdz(entities, options) // zipped model.usda + textures

Drawings: DXF / SVG / PDF

Three levels of 2D output over entities and paper-space sheets:

import { entitiesToDxf, entitiesFromDxf, sheetToSvg, sheetsToPdf } from '@huukhanhnguyen/io'

const dxf = entitiesToDxf(entities)            // DXF R12, world-space leaf entities
const back = entitiesFromDxf(dxf)              // R12/LWPOLYLINE/HATCH in; ARC/INSERT/DIM skipped fail-soft

const svg = sheetToSvg({ entities, width: 297, height: 210, scaleLabel: '1:100' })
const pdf: Uint8Array = sheetsToPdf([{ number: 'A-101', title: 'PLAN', svg }]) // one page per sheet

sceneToSvg (plan-view display polylines) and entitiesToSvg (exact paths, true NURBS arcs, y-up) cover direct 2D rendering without sheet layout.

Also in the Io surface

  • tessellationToIfc — BIM exchange.
  • tableToCsv, tableToPdf, tablesToXlsx — schedule/table output.
  • tessellationToStl / tessellationToObj — see Mesh formats.

All of these are re-exported from @huukhanhnguyen/model for parametric pipelines, so an evaluated model's entities feed any of them directly.

Where next

Last updated: 📖 1 min readEdit on GitHub