// ImmersiveActivity.kt(your Spatial SDK activity)
private fun loadGLXF() {
activityScope.launch {
glXFManager.inflateGLXF(Uri.parse("apk:///demoproject1.glxf"))
}
}
GLXFManager
(
context
)
|
Signature
constructor(context: Context) Parameters context: Context
: the context of the GLXFManager, a.k.a. the Spatial activity object.
Returns GLXFManager |
context
: Context
[Get] |
: the context of the GLXFManager, a.k.a. the Spatial activity object.
Signature
val context: Context |
addReloadedGLXFUris
(
toReloadUris
, basePath
)
|
Adds URIs that should be loaded using the local file system instead of the APK file system. This is used when hot reloading to reload GLXFs so that future GLXFs use the reloaded files. It is recommended not to use this unless you know what you're doing.
Parameters toReloadUris: Set
The URIs that have been reloaded and use the local file system instead of the APK file system.
basePath: File
The base path of the reloaded files.
|
deleteGLXF
(
glxfInfo
)
|
Deletes root entity and all children. Removes references to the deleted GLXFInfo from the maps.
Example:
// ImmersiveActivity.kt(your Spatial SDK activity) glXFManager.deleteGLXF(glXFInfo)
Signature
fun deleteGLXF(glxfInfo: GLXFInfo) Parameters |
deleteGLXF
(
entity
)
|
Deletes the GLXFInfo the entity belongs to along with all other entities in that GLXFInfo.
Example:
// ImmersiveActivity.kt(your Spatial SDK activity) // If you have a reference to the root entity but not the GLXFInfo glXFManager.deleteGLXF(gltfxEntity)
Signature
fun deleteGLXF(entity: Entity) Parameters |
deleteGLXFEntityAndGetDeletedChildren
(
entity
)
|
Deletes a GLXF entity and get the deleted children. This is used for handling the deletion of children entities when deleting a GLXF entity. It is recommended not to use this unless you know what you're doing.
Example:
// ImmersiveActivity.kt(your Spatial SDK activity)
val deletedChildren = glXFManager.deleteGLXFEntityAndGetDeletedChildren(gltfxEntity)
for (childEntity in deletedChildren) {
// Do something with each deleted child entity
println("Deleted child entity: $childEntity")
}
Signature
fun deleteGLXFEntityAndGetDeletedChildren(entity: Entity): Set<Entity> Parameters Returns Set
A set of deleted children entities.
|
getGLXFInfo
(
keyName
)
|
Returns the GLXFInfo object for the given keyName.
Example:
// ImmersiveActivity.kt(your Spatial SDK activity)
val glXFInfo = glXFManager.getGLXFInfo("myKey")
Signature
fun getGLXFInfo(keyName: String): GLXFInfo Parameters keyName: String
The key name of the GLXFInfo object to retrieve.
|
getNestedGLXFInfo
(
parentInfo
, childName
)
|
Gets the nested GLXFInfo for a given child name.
Example:
val myGLXFInfo = glXFManager.getGLXFInfo("myKey")
val myNestedGLXFInfo = glXFManager.getNestedGLXFInfo(myGLXFInfo, "childWithNestedGLXFName")
Signature
fun getNestedGLXFInfo(parentInfo: GLXFInfo, childName: String): GLXFInfo? Parameters childName: String
The name of the child node.
|
getNestedGLXFInfo
(
parentInfo
, childNamePathList
)
|
Gets the nested GLXFInfo for a given list of child names. The first name should be the highest level child name, with each subsequent name being a child of that nested GLXFInfo
val myGLXFInfo = glXFManager.getGLXFInfo("myKey")
val myNestedGLXFInfo = glXFManager.getNestedGLXFInfo(myGLXFInfo, listOf("childOfMyGLXFInfo", "childOf_childOfMyGLXFInfo"))
Signature
fun getNestedGLXFInfo(parentInfo: GLXFInfo, childNamePathList: List<String>): GLXFInfo? Parameters childNamePathList: List
The list of child names.
|
hasGLXFInfoForUri
(
uri
)
|
Checks if there is a GLXFInfo object for a given URI. This is useful for checking if a glXF file is in use. It is used mostly for hot reloading glXFs.
// ImmersiveActivity.kt(your Spatial SDK activity)
val uri = Uri.parse("apk:///scenes/Composition.glxf")
if (glXFManager.hasGLXFInfoForUri(uri)) {
// The GLXF has already been loaded
} else {
// Need to load the GLXF
activityScope.launch {
glXFManager.inflateGLXF(uri)
}
}
Signature
fun hasGLXFInfoForUri(uri: Uri): Boolean Parameters uri: Uri
The URI to check.
Returns Boolean
True if a GLXFInfo object exists for the URI, false otherwise.
|
inflateComposition
(
compositionName
, assetFolderPath
, rootEntity
, keyName
, onLoaded
)
|
Parses the Composition glxf file and calls inflateGLXF, inflates a GLXF file into a GLXFInfo object, adds it to the map of GLXFInfo objects, and sets the GLXF component on the root entity of the GLXF file.
// ImmersiveActivity.kt(your Spatial SDK activity)
private fun loadGLXF() {
activityScope.launch {
glXFManager.inflateComposition("demoproject1", assetFolderPath = "subfolder") // Inflates Uri.parse("apk:///subfolder/demoproject1.glxf")
}
}
Signature
suspend fun inflateComposition(compositionName: String, assetFolderPath: String = "scenes", rootEntity: Entity = Entity.createGlobal(), keyName: String? = null, onLoaded: (GLXFInfo) -> Unit = {}): GLXFInfo?Parameters compositionName: String
The name of the composition to inflate.
assetFolderPath: String
The folder path where the assets are stored.
keyName: String?
The key name of the GLXFInfo object to create.
onLoaded: Function1 |
inflateGLXF
(
uri
, rootEntity
, keyName
, onLoaded
)
|
Inflates a GLXF file into a GLXFInfo object, adds it to the map of GLXFInfo objects, and sets the GLXF component on the root entity of the GLXF file.
// ImmersiveActivity.kt(your Spatial SDK activity)
private fun loadGLXF() {
activityScope.launch {
glXFManager.inflateGLXF(Uri.parse("apk:///demoproject1.glxf"), rootEntity = myEntity, keyName = "myKey")
}
}
Signature
suspend fun inflateGLXF(uri: Uri, rootEntity: Entity = defaultCreateEntity(null), keyName: String? = null, onLoaded: (GLXFInfo) -> Unit = {}): GLXFInfo?Parameters uri: Uri
The URI of the GLXF file to inflate.
keyName: String?
The key name of the GLXFInfo object to create.
onLoaded: Function1
The callback function to call after the GLXFInfo object is loaded.
|
inflateGLXF
(
uri
, overrideCreateEntity
, rootEntity
, keyName
, onLoaded
)
|
Inflates a GLXF file into a GLXFInfo object, adds it to the map of GLXFInfo objects, and sets the GLXF component on the root entity of the GLXF file.
// ImmersiveActivity.kt(your Spatial SDK activity)
private fun loadGLXF() {
val addCustomComponentMethod: (JSONObject?) -> Entity = { Entity.create(MyCustomComponent()) }
activityScope.launch {
glXFManager.inflateGLXF(Uri.parse("apk:///demoproject1.glxf"), overrideCreateEntity = addCustomComponentMethod)
}
}
Parameters uri: Uri
The URI of the GLXF file to inflate.
overrideCreateEntity: Function1
The function to create a new entity in the glXF, the JSONObject is the glXF node the entity represents, it will be null for the root node which has no glXF JSON associated with it.
keyName: String?
The key name of the GLXFInfo object to create.
onLoaded: Function1
The callback function to call after the GLXFInfo object is loaded.
|
reloadGLXFsFromFile
(
oldFileName
, newFileName
, meshManager
)
|
Reloads GLXFs from a file. This is used for hot reloading glXFs. We recommend not using this unless you know what you're doing.
Signature
suspend fun reloadGLXFsFromFile(oldFileName: Uri, newFileName: Uri, meshManager: MeshManager): Parameters oldFileName: Uri
The old file name.
newFileName: Uri
The new file name.
Returns |
setDefaultCreateEntity
(
overrideCreateEntity
)
|
Developer can override the default entity creation function
Parameters overrideCreateEntity: Function1
The function to create a new entity in the glXF
|
setReloadType
(
reloadType
)
|
Developer can pick how GLXFs reload. The default reload type of GLXFManager is DELETE_AND_RECREATE_ENTITIES.
Example:
// ImmersiveActivity.kt(your Spatial SDK activity) // Set reload type to keep existing entities when reloading glXFManager.setReloadType(GLXFReloadType.KEEP_EXISTING_ENTITIES) // Or set reload type to delete and recreate entities when reloading (default) glXFManager.setReloadType(GLXFReloadType.DELETE_AND_RECREATE_ENTITIES)
Signature
fun setReloadType(reloadType: GLXFReloadType) Parameters |
tryGetGLXFInfo
(
keyName
)
|
Returns the GLXFInfo object for the given keyName, or null if it doesn't exist.
Example:
// ImmersiveActivity.kt(your Spatial SDK activity)
val glXFInfo = glXFManager.getGLXFInfo("myKey") ?: return
Signature
fun tryGetGLXFInfo(keyName: String): GLXFInfo? Parameters keyName: String
The key name of the GLXFInfo object to retrieve.
Returns GLXFInfo?
The GLXFInfo object associated with the given keyName, or null if it doesn't exist.
|
isSupportedGLXFExtension
(
fileName
)
|
Determine whether a file type can be loaded by GLXFManager into an inflated GLXFInfo
Signature
fun isSupportedGLXFExtension(fileName: String): Boolean Parameters fileName: StringReturns Boolean
true if the file name is a supported GLXF extension such as .glxf or .gltfx, false otherwise
|