The glTF2 format Exporter class.

This class provides functionality to export Rhodonite scene data to glTF 2.0 format. It supports various export formats including .gltf, .glb, and embedded formats.

Methods

  • Placeholder method for future glTF2 ArrayBuffer export functionality.

    This method is reserved for implementing glTF2 export that returns an ArrayBuffer without triggering a download.

    Returns void

  • Creates glTF2 BufferViews and Accessors for all geometry and animation data.

    This method processes mesh geometry, animation data, and skeletal information to create the necessary buffer views and accessors required for glTF2 format. It handles data deduplication and proper memory layout.

    Parameters

    • json: Gltf2Ex

      The glTF2 JSON document to populate

    • entities: ISceneGraphEntity[]

      Array of entities to process for buffer creation

    Returns void

  • Creates glTF2 materials and textures from Rhodonite materials.

    Processes all materials used by mesh entities, converting Rhodonite material properties to glTF2 PBR format. Handles texture extraction, optimization, and proper format conversion including support for various material extensions.

    Parameters

    • json: Gltf2Ex

      The glTF2 JSON document to populate with materials

    • entities: IMeshEntity[]

      Mesh entities containing materials to convert

    • option: Gltf2ExporterArguments

      Export options affecting material processing

    Returns Promise<any[]>

    Promise that resolves when all materials and textures are processed

  • Creates glTF2 nodes representing the scene graph structure.

    Converts Rhodonite entities into glTF2 nodes, preserving hierarchical relationships, transformations, and component associations (meshes, cameras, skins). Handles special cases like billboard nodes and blend shape weights.

    Parameters

    Returns void

  • Initiates download of the exported glTF2 data as a .glb file.

    Creates a downloadable .glb file containing the complete glTF2 scene in binary format. Uses browser download API to save the file locally.

    Parameters

    • json: Gltf2

      The glTF2 JSON document

    • filename: string

      Base filename for the download

    • arraybuffer: ArrayBuffer

      Binary data buffer containing the .glb file

    Returns void

  • Initiates download of the exported glTF2 data as separate .gltf and .bin files.

    Creates downloadable .gltf (JSON) and .bin (binary) files representing the complete glTF2 scene in text format with external binary references.

    Parameters

    • json: Gltf2

      The glTF2 JSON document

    • filename: string

      Base filename for the downloads

    • arraybuffer: ArrayBuffer

      Binary data buffer for the .bin file

    Returns void

  • Exports scene data from the Rhodonite system in glTF2 format.

    This is the main entry point for glTF2 export functionality. It processes the scene graph, materials, animations, and other data to create a complete glTF2 output in the specified format.

    Parameters

    • filename: string

      The target output filename (without extension)

    • option: Gltf2ExporterArguments = ...

      Export configuration options

    Returns Promise<ArrayBuffer>

    Promise that resolves to the generated glTF2 ArrayBuffer

    const buffer = await Gltf2Exporter.export('myScene', {
    type: GLTF2_EXPORT_GLB,
    entities: [rootEntity]
    });