---
Product: Aspose.3D
Platform: net
Page Type: docs
Canonical URL: https://docs.aspose.org/3d/net/developer-guide/gltf
---

# Working with glTF and GLB

Load, save, and configure glTF 2.0 and GLB files in Aspose.3D for .NET — controlling embedded textures, Draco compression, and format-specific save options via GltfLoadOptions and GltfSaveOptions.

## Overview

Aspose.3D for .NET supports reading and writing glTF 2.0 (`.gltf` with separate assets) and GLB (single-file binary glTF). Use `GltfLoadOptions` to configure loading behaviour and `GltfSaveOptions` to control export output.

---

### Loading a glTF File

Load a `.gltf` or `.glb` file directly with `Scene.Open`. Supply `GltfLoadOptions` for finer control:

```csharp
using Aspose.ThreeD;
using Aspose.ThreeD.Formats;

// Basic load
var scene = Scene.FromFile("model.gltf");

// Load with options
var opts = new GltfLoadOptions();
var sceneWithOpts = new Scene();
sceneWithOpts.Open("model.gltf", opts);
```

> glTF files reference external `.bin` buffers and textures by relative path. Keep all referenced assets in the same directory as the `.gltf` file when loading.

---

### Saving as glTF or GLB

Save any scene as glTF or the compact binary GLB format:

```csharp
using Aspose.ThreeD;
using Aspose.ThreeD.Formats;

var scene = new Scene();
scene.RootNode.CreateChildNode("box", new Aspose.ThreeD.Entities.Box());

// Save as glTF (separate JSON + .bin buffer)
scene.Save("output.gltf", FileFormat.GLTF2);

// Save as GLB (single binary file)
scene.Save("output.glb", FileFormat.GLTF2_Binary);

// Save with custom options — embed the binary buffer inside the JSON
var saveOpts = new GltfSaveOptions(FileFormat.GLTF2);
saveOpts.EmbedAssets = true;
scene.Save("output_embedded.gltf", saveOpts);
```

---

### Controlling Embedded Image Format

When textures are embedded, control how image data is stored with `GltfEmbeddedImageFormat`:

```csharp
var saveOpts = new GltfSaveOptions(FileFormat.GLTF2_Binary);
saveOpts.ImageFormat = GltfEmbeddedImageFormat.Jpeg;
scene.Save("output.glb", saveOpts);
```

| `GltfEmbeddedImageFormat` value | Description |
|---|---|
| `Jpeg` | Re-encode embedded textures as JPEG (lossy, smaller) |
| `Png` | Re-encode embedded textures as PNG (lossless) |
| `NoChange` | Keep original encoding (default) |

---

### API Quick Reference

| Member | Description |
|---|---|
| `new GltfLoadOptions()` | Configure glTF import |
| `new GltfSaveOptions(format)` | Configure glTF/GLB export |
| `saveOpts.EmbedAssets` | Embed binary buffer inside the `.gltf` JSON |
| `saveOpts.ImageFormat` | Embedded texture encoding (`GltfEmbeddedImageFormat`) |
| `FileFormat.GLTF2` | Target format: separate `.gltf` + `.bin` |
| `FileFormat.GLTF2_Binary` | Target format: single `.glb` |

## See Also

- [Aspose.3D for .NET — Enterprise Documentation](https://docs.aspose.com/3d/net/)
- [Format Support](format-support) — full list of supported 3D formats