> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ploterr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GLB

> Export the 3D model as a GLB file with the Three.js exporter.

A GLB file holds the 3D model in one binary file. Game engines, 3D viewers and AR tools open it.

Floorkit builds your model as standard Three.js objects. Thus you can export it with `GLTFExporter`, which is a part of Three.js. You do not need a different package.

## Export a session

`session.root` holds the full compiled building. Give it to the exporter and ask for binary output.

```typescript theme={null}
import { GLTFExporter } from 'three/examples/jsm/exporters/GLTFExporter.js';
import type { BuildingSession } from '@opengeometry/floorkit';

export async function exportGlb(session: BuildingSession): Promise<Blob> {
  session.root.updateMatrixWorld(true);
  const result = await new GLTFExporter().parseAsync(session.root, {
    binary: true,
    onlyVisible: true,
  });
  if (!(result instanceof ArrayBuffer)) throw new Error('The exporter did not return a GLB.');
  return new Blob([result], { type: 'model/gltf-binary' });
}
```

## Download the file

```typescript theme={null}
export async function downloadGlb(session: BuildingSession, fileName: string): Promise<void> {
  const url = URL.createObjectURL(await exportGlb(session));
  const link = document.createElement('a');
  link.href = url;
  link.download = fileName;
  link.click();
  URL.revokeObjectURL(url);
}
```

## Export other objects

The exporter accepts any Three.js object. To export one storey, pass its group from `session.currentBuild.storeyGroups`. To export elements that you made with classes such as `Wall` or `Slab`, add them to a `THREE.Group` and pass that group.

## Notes

* Units are metres and the Y axis points up. These are also the glTF conventions, so no conversion is necessary.
* The file contains geometry, colours and object names. It does not contain the building document. Save a [project file](/floorkit/api/exports/project-file) to keep the model editable.
* Call the export after the last edit. The exporter reads the model as it is at that moment.
* A deployed site needs a valid hostname key, including a non-commercial demo. See [Licensing](/floorkit/licensing).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.