// 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
Returns |
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
basePath:
File
|
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
|
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
|
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
|
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
|
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
Returns
Boolean
|
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
assetFolderPath:
String
keyName:
String?
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
keyName:
String?
onLoaded:
Function1
|
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
overrideCreateEntity:
Function1
keyName:
String?
onLoaded:
Function1
|
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
newFileName:
Uri
Returns |
setDefaultCreateEntity
(
overrideCreateEntity
)
|
Developer can override the default entity creation function
Parameters
overrideCreateEntity:
Function1
|
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
Returns
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:
String
Returns
Boolean
|