> ## 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.

# Export a GLB

> Get the 3D model as one GLB file for viewers, game engines and AR.

export const LiveExample = ({path, title = 'Live example', height = 460}) => {
  return <Frame>
      <iframe src={`https://floorkit-examples.ploterr.com/floorkit/${path}?embed=1`} ref={frame => {
    if (!frame || !['localhost', '127.0.0.1'].includes(window.location.hostname)) return;
    const local = `http://localhost:5555/${path}?embed=1`;
    if (frame.src !== local) frame.src = local;
  }} title={title} loading="lazy" allow="fullscreen" style={{
    width: '100%',
    height: `${height}px`,
    border: 0,
    display: 'block'
  }} />
    </Frame>;
};

A GLB file holds the 3D model in one binary file. Floorkit builds your model as standard Three.js objects, so you export it with the exporter that is part of Three.js.

<LiveExample path="guides/export-a-glb" />

## Before you start

You have a session from [Start a building](/floorkit/guides/start-a-building) with some elements in it.

## Export and download

`session.root` holds the full building. Give it to `GLTFExporter` 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 downloadGlb(session: BuildingSession): Promise<void> {
  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.');
  const url = URL.createObjectURL(new Blob([result], { type: 'model/gltf-binary' }));
  const link = document.createElement('a');
  link.href = url;
  link.download = 'building.glb';
  link.click();
  URL.revokeObjectURL(url);
}
```

## Export one storey

A build keeps one group for each storey. Pass that group in place of the root.

```typescript theme={null}
export function storeyGroup(session: BuildingSession, storeyId: string) {
  return session.currentBuild.storeyGroups.get(storeyId);
}
```

## Rules

* The model is in metres and the Y axis points up. glTF uses the same conventions, so no conversion is necessary.
* The file holds geometry, colours and object names. It does not hold the building model. To keep the design editable, also [save the project](/floorkit/guides/save-and-reopen).
* 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).

## Next

<CardGroup cols={2}>
  <Card title="Save and reopen" icon="floppy-disk" href="/floorkit/guides/save-and-reopen">
    Keep the design editable.
  </Card>

  <Card title="GLB reference" icon="code" href="/floorkit/api/exports/glb">
    See the export function as a reusable module.
  </Card>
</CardGroup>


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