API

Class AbstractThreeMfSerializer<T, O>Abstract

Base class for 3MF serialization.

Responsibilities:

  • Convert user meshes to a 3MF model (toModel).
  • Wrap the 3MF document parts into an OPC container (zip) and stream bytes through the sink.

Non-responsibilities:

  • Providing/initializing the zip implementation (ensureZipLibReadyAsync is abstract).
  • Defining how meshes map to 3MF objects (toModel is abstract).

Type Parameters

Hierarchy (View Summary)

Implements

Index
  • Provide a zip implementation for the current host/runtime.

    This might be provided by the framework implementation, but it could differ depending on the host (native, Node.js, browser, etc.).

    Expected shape (fflate-like):

    • return [ Zip, ZipDeflate ] at minimum.

    Notes:

    • In a browser, this might require bundler configuration or dynamic import.
    • In Node.js, this might be a direct import of "fflate" or another compatible implementation.

    Returns Promise<any>

  • 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: T[]

      the meshes to serialize.

    Returns Promise<void>