Develop

glXF

Updated: Apr 2, 2026

Overview

glXF (or glTFx) is a file format that enables the composition of glTFs and other glXFs. Spatial SDK uses glXF for scene composition and layout purposes.
Spatial Editor exports the glXF format, which you can inflate into a Spatial SDK app. Spatial SDK apps utilize the GLXFManager to manage glXF inflation, deletion, and queries.

How glXF, glTF, and compositions relate

These three concepts work together to define your 3D scenes:
  • glTF / glb: Standard 3D model files containing geometry, materials, textures, and animations for individual objects. Think of these as individual 3D assets (a chair, a tree, a character). See Loading custom 3D models with glTF for details.
  • glXF: A scene layout format that references and positions multiple glTF models (and other glXFs) into a complete scene. Think of it as a blueprint that says “place the chair here, the tree there, and the character over there.”
  • Composition: A Spatial Editor project that exports as a glXF file. When you design a scene in Spatial Editor, you create a composition. When you export that composition, it becomes a .glxf file that your app loads at runtime.
In short: you create individual 3D models as glTF files, arrange them into scenes using compositions in Spatial Editor, and load those scenes into your app as glXF files.

Loading and inflating a glXF

Loading and inflating a glXF means loading the file and inflating the nodes as Spatial SDK entities. These entities will have the proper Transform and Mesh components, set to correspond to their transform and asset in the glXF.
To load a glXF, launch a coroutine and call glXFManager’s inflateGLXF method from your Spatial SDK activity.
val myEntity = Entity.create()

private fun loadGLXF() {
  activityScope.launch {
    glXFManager.inflateGLXF(
        Uri.parse("apk:///demoproject1.glxf"),
        rootEntity = myEntity,
        keyName = "example_key_name")
  }
}
inflateGLXF returns a GLXFInfo object, which contains helpful information about the inflated glXF.
inflateGLXF takes the following parameters:
  • uri: The path to the glXF file.
  • rootEntity: An optional parameter that sets any entity you want as the rootEntity of the glXF. If you don’t include this parameter, the rootEntity will be a new entity. This parameter is helpful when moving the entire glXF scene altogether. Changing this rootEntity’s transform will cause all the inflated entities to move with it.
  • keyName: An optional parameter that tells GLXFManager to save the GLXFInfo inflated by this glXF using the name you passed into the method. Once saved, you can access this data anytime using the keyName you created.
You can load glXFs from the same file as many times as you want.

Querying glXFs

You can query GLXFInfo using the keyName parameter. Two options exist to do this with glXFManager, and both return the GLXFInfo if it exists.
  • glXFManager.getGLXFInfo("example_key_name"): This method does not check if the GLXFInfo exists, and will throw an error if there is no GLXFInfo for the corresponding key name.
  • glXFManager.tryGetGLXFInfo("example_key_name"): This method will return null if there is no GLXFInfo for the corresponding key name.

Querying the nodes and entities of a glXF

A node must have a unique name for it to be queryable in a glXF. Using this name, you can get the GLXFNode and then the inflated entity that represents that node.
val glXFInfo = glXFManager.getGLXFInfo("example_key_name")
val myDuckNode: GLXFNode = glXFInfo.getNodeByName("myDuck") // gets GLXFNode
val myDuckEntity = myDuckNode.entity
// Do something with myDuckEntity
Similar to querying GLXFInfo, there are two options for querying glXF:
  • getNodeByName: This call throws an exception if a node with the specified name doesn’t exist.
  • tryGetNodeByName: This call will return null if the node name doesn’t exist.
You can also pass Android resource string IDs to these functions.
val myDuckNode: GLXFNode = glXFInfo.getNodeByName(R.string.my_duck) // gets GLXFNode

Query nested glXFs

You can query nested GLXFInfos by using the getNestedGLXFInfo method of GLXFManager.
val childGLXFInfo = glXFManager.getNestedGLXFInfo(parentInfo = myGLXFInfo, childName = "myNestedGLXFNodeName")
To get GLXFInfo that is nested on more than one level, you can pass in a list of names instead. Treat the list like a file path, where the first name is the first nested GLXF, and so on.
val greatGrandChildGLXFInfo = glXFManager.getNestedGLXFInfo(parentInfo = myGLXFInfo, childNamePathList = listOf("child", "grandChild", "greatGrandChild"))

Delete glXFs or entities from glXFs

To delete glXFs, simply destroy the rootEntity of the glXF as you would any normal entity.
myGLXFInfo.rootEntity.destroy()
This call will delete all entities inflated from that glXF and remove its info from the GLXFManager.
You can also independently delete subnodes of a scene. Deleting an entity inflated from a glXF will also automatically delete its children, including those from nested glXFs.
val myNode: GLXFNode = glXFInfo.getNodeByName("myNode")
val myEntity = myNode.entity
myEntity.destroy()

Design guidelines