3D export to glTF: files, materials and verification
Export GLB/glTF from the editor and C#, handle dependencies, material limits and round trips.
What glTF transfers
glTF 2.0 is a 3D interchange format, not a project backup. Export geometry and supported materials for editing in a DCC application or transfer to another tool. Use native project formats to preserve Reckfell gameplay Entities/resources, and project export to distribute the game.
Successful file writing does not guarantee identical appearance: the receiving application may handle lighting, materials and glTF extensions differently. Scripts, gameplay connections, WorldEnvironment settings, postprocessing and particle simulation do not become a portable game project.
Export from the editor
- Open the required 3D level or prefab. Export traverses its root and descendants; it does not export every open tab.
- Check geometry, local transforms, materials and membership in the saved tree. In editor mode, temporary descendants without an Owner can be excluded.
- Select Scene → Export As… → glTF 2.0 Scene…, choose the output file and review export settings before confirming.
- Open the result in the receiving program. Compare scale, hierarchy, surfaces, textures and required animations.
Menu labels can be localized. Visibility and root-mode settings affect output; do not assume that an invisible object is automatically excluded. This interface workflow was checked against source; additional plugins can change export settings.
| Format | What to transfer |
|---|---|
.gltf | The JSON file plus generated .bin, images and other dependencies, preserving relative paths |
.glb | Usually a binary container with embedded data; still check external URIs and the result in the receiving application |
Do not call .gltf with neighboring files an embedded format. For very large data or nondefault settings, do not assume that one .glb always suffices.
Export from C#
The output directory must exist and be writable. Pass a live Entity3D root and a path ending in .glb or .gltf, such as user://model.glb. Save this class as ExportModel.cs:
using System;
using Reckfell;
public static class ExportModel
{
public static Error Write(Entity3D root, string outputPath)
{
if (!outputPath.EndsWith(".glb", StringComparison.OrdinalIgnoreCase)
&& !outputPath.EndsWith(".gltf", StringComparison.OrdinalIgnoreCase))
return Error.InvalidParameter;
using var document = new GltfDocument();
using var state = new GltfState();
Error error = document.AppendFromScene(root, state);
if (error != Error.Ok)
return error;
return document.WriteToFilesystem(state, outputPath);
}
}AppendFromScene populates GltfState; WriteToFilesystem creates the file. Check both stages. For independent exports, the example creates a new state each call. The source tree remains owned by the caller and is not freed.
Error.Ok means the API operation succeeded, not that every artistic or gameplay requirement was verified. Export can create several files and is not an atomic directory replacement: inspect partially written output after failure.
Practical limitations
| Source content | What to check |
|---|---|
| StandardMaterial3D / BaseMaterial3D | Supported PBR factors, color, texture channels, transparency and UVs; not every material effect has an equivalent |
| ShaderMaterial | The shader program is not transferred as an executable glTF material. Export can succeed with a simple material instead of the original effect |
| Particles | Do not expect simulation or behavior to transfer. A generic hierarchy element does not mean the particle system survived |
| CSG | Output depends on conversion of current geometry; operation history does not become editable CSG in another application |
| Cameras and lights | Receiver support for parameters/extensions, units, exposure and actual frame appearance |
| Animation and skeleton | Names, bindings, range and bake rate, then motion in the receiving program |
Verify the result and diagnose failures
For a round trip, create a fresh GltfDocument and GltfState, call AppendFromFile(path, state) and, after Error.Ok, GenerateScene(state). The returned tree has not been added to EntityTree: use it explicitly and free it when no longer needed. This checks Reckfell's own reader; compatibility with another application requires a separate test there.
| Problem | Check |
|---|---|
| No output or writing failed | Directory existence, write access, Error and log; this is not a parent-directory creation command |
| Model exists, textures missing | Neighboring files and relative URIs, source material export and image-format support |
| File written, effect lost | ShaderMaterial, postprocessing or unsupported material feature; Error.Ok alone is insufficient |
| Object missing | Editor Owner, visibility mode, exported subtree and log |
| Lighting differs | Environment, exposure, extension support and receiver rendering settings |
Continue with 3D import and runtime files.