Class ThreeMfSerializer
Hierarchy (View Summary)
- AbstractThreeMfSerializer<
WebXRSpatialLayerType
| WebXRSpatialLayerType,
IThreeMfSerializerOptions,
>- ThreeMfSerializer
Constructors
constructor
-
Parameters
- opts: Partial<IThreeMfSerializerOptions> = {}
serializer options (merged with defaults in base class).
Returns ThreeMfSerializer
- opts: Partial<IThreeMfSerializerOptions> = {}
Accessors
options
-
Expose the resolved options (defaults + overrides) as readonly.
Returns Readonly<O>
Methods
ensure Zip Lib Ready Async
-
Ensure the zip library (fflate) is available in the current runtime.
Host assumptions:
- This implementation relies on fflate being exposed on globalThis.fflate.
- If it is not present, it loads a script from ThreeMfSerializerGlobalConfiguration.FFLATEUrl using Babylon Tools.LoadScriptAsync.
Returns Promise<any>
serialize Async
-
serializeAsync(
sink: (err: any, chunk: Uint8Array, final: boolean) => void,
...meshes: any[],
): Promise<void>Generic 3MF binary serializer. Pipeline overview:
- ensureZipLibReadyAsync provides a zip implementation (host-dependent).
- Convert meshes into an I3mfDocument (OPC parts + model).
- Create a zip target that streams through the provided sink.
- Serialize XML parts into zip entries.
- 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>
to Document
-
Build a full 3MF OPC document from meshes.
The default behavior uses ThreeMfDocumentBuilder with the model produced by toModel(). Override if you need custom parts (textures, thumbnails, print ticket, etc.).
Parameters
- ...meshes: any[]
Returns I3mfDocument | undefined
to Model
-
Build a 3MF model from Babylon meshes.
Important: this method should not allocate huge intermediate data unless needed. Submesh extraction does allocate new position/index arrays for each exported submesh.
Parameters
- builder: ThreeMfModelBuilder
- ...meshes: any[]
Returns I3mfModel
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: