:orphan:

###########
glTF Writer
###########

.. rst-class:: format-title-block

+----------------------------------------------------------------------+
|                        **gl Transmission Format**                    |
+-----------------------------------------+----------------------------+
| **File Extension**                      | glTF, GLB                  |
+-----------------------------------------+----------------------------+
| **Supported Versions**                  | 2.0                        |
+-----------------------------------------+----------------------------+
| **Platforms**                           | |wy| |ly| |my| |ay| |iy|   | 
+-----------------------------------------+----------------------------+
| **Tessellation**                        | |c_green|                  | 
+-----------------------------------------+----------------------------+
| **B-rep**                               | |c_grey| N/A               | 
+-----------------------------------------+----------------------------+
| **PMI**                                 | |c_grey| N/A               | 
+-----------------------------------------+----------------------------+
| **Assembly**                            | |c_grey| N/A               | 
+-----------------------------------------+----------------------------+
| **Views**                               | |c_grey| N/A               |
+-----------------------------------------+----------------------------+

The glTF (GL Transmission Format) file format was created by the Khronos Group in 2015. It is an open standard for 3D scenes and models, designed to be efficient and widely supported across platforms.

The file extensions that you can create when you export to glTF are

- `.gltf`
- `.glb`

HOOPS Exchange geometry access for glTF includes:

* **Tessellation:** Can be written by HOOPS Exchange for visualization.
* **B-rep:** This format does not support B-rep


Physically-Based Rendering Material
===================================

As of version 2019 HOOPS Exchange now supports physically based rendering (PBR) materials with `A3DGraphMaterialData` structure. PBR related information are read from glTF formats.
See :ref:`pg_get_pbr_material_properties` for how to retrieve these PBR-specific properties.

Assembly
========

This concept is not supported by glTF.

B-rep
=====

This concept is not supported by glTF.

Views
=====

This concept is not supported by glTF.

.. _gltf_wt_wireframe:

Wireframe
=========

Two kinds of line geometry can be written to a glTF file, and they are controlled differently:

* **Edge wireframe of surfaces and solids:**
  when :c:member:`A3DRWParamsExportGltfData.m_bExportEdgeWires` is set to ``A3D_TRUE``, the edges of each tessellated B-rep or polyhedral representation item are written as glTF ``LINES`` primitives, overlaid on its triangle mesh.
  The edges come from the face wire data of the tessellation (:c:member:`A3DTess3DData.m_puiWireIndexes`). Wires flagged with :c:macro:`kA3DTessFaceDataWireIsNotDrawn` are skipped.
  The edge wireframe is currently written in black.
  This option is ``A3D_FALSE`` by default.
* **Curves and wires of the source model:**
  curve (:c:type:`A3DRiCurve`) and polywire (:c:type:`A3DRiPolyWire`) representation items are written as glTF ``LINES`` primitives regardless of the value of ``m_bExportEdgeWires``.

Setting ``m_bExportEdgeWires`` to ``A3D_FALSE`` only removes the edge overlay from surfaces and solids. It does not drop curves or wires that exist in the source model.

.. code-block:: c

   A3DRWParamsExportGltfData sExportParams;
   A3D_INITIALIZE_DATA(A3DRWParamsExportGltfData, sExportParams);
   sExportParams.m_bExportEdgeWires = A3D_TRUE; // Add the edge wireframe to surfaces and solids

   A3DStatus iRet = A3DAsmModelFileExportToGltfFile(pModelFile, &sExportParams, "model.glb");


Miscellaneous
=============

.. rubric:: Supported

- Version 2.0 files only (tinygltf limitation; only "asset" data is correctly parsed from 1.0 files)
- Vertex position, normal, color, texture coordinate sets 0 and 1
- Triangles
- Full texture support and material data: normal, occlusion, emissive
- Physically Based Rendering (PBR) textures and constants: base color, metallness, roughness
- Texture file formats: JPEG, PNG, BMP, GIF (handled by tinygltf)
- Cameras
- Wireframe (see :ref:`gltf_wt_wireframe`)

.. rubric:: Unsupported

- Version 1.0 files
- Vertex tangents
- Animations
- Skins
- Extensions
- Shaders
- Sparse accessors (currently not supported by tinygltf)
- Byte-swapping for Big-Endian platforms
