API

Class ThreeMfSerializer

Babylon.js to 3MF serializer.

This serializer converts Babylon meshes into a 3MF model, then relies on the base class (AbstractThreeMfSerializer) to package the OPC parts into a zip stream.

Design notes:

  • First pass: export "source" meshes (non-instances) and build an index to map Babylon mesh/submesh to 3MF object id.
  • Second pass (optional): export instances as additional build items referencing the original object ids.
  • Submesh export is handled by extracting per-submesh vertex/index buffers so materials/colors can be preserved by downstream steps that attach per-object properties.

Hierarchy (View Summary)

Index
DefaultOptions: IThreeMfSerializerOptions = ...

Default serialization options: meter units, no instance export.

  • Generic 3MF binary serializer. Pipeline overview:

    1. ensureZipLibReadyAsync provides a zip implementation (host-dependent).
    2. Convert meshes into an I3mfDocument (OPC parts + model).
    3. Create a zip target that streams through the provided sink.
    4. Serialize XML parts into zip entries.
    5. End the zip stream.

    Parameters

    • sink: (err: any, chunk: Uint8Array, final: boolean) => void

      a callback receiving byte chunks; enables streaming without buffering the full archive in memory.

    • ...meshes: any[]

      the meshes to serialize.

    Returns Promise<void>