API reference
API reference
Select your platform
No SDKs available
No versions available

MeshManager Class

Modifiers: final
Manages 3D meshes for entities in the Aether framework.
MeshManager is responsible for loading, attaching, and destroying meshes for entities. It supports different mesh sources (mesh://, gfx://, file://, http://, https://) and manages the lifecycle of SceneObjects and SceneMeshes. It also handles input events for meshes and forwards them to the data model.
Example usage:
// Register a custom mesh creator
meshManager.meshCreators["mesh://custom"] = { entity ->
    // Create and return a custom SceneMesh for the entity
    SceneMesh.box(
        -0.5f, -0.5f, -0.5f,
        0.5f, 0.5f, 0.5f,
        material.generateSceneMaterial(entity, context)
    )
}
// Set a mesh for an entity using a URI
meshManager.setMeshForEntity(
    entity,
    Uri.parse("models/cube.glb"),
    Uri.parse("file:///data/data/com.example.app/files/models/cube.glb"),
    "",  // default shader override
    -1,  // default scene override
    true // use cache
)
// Set a mesh directly for an entity
meshManager.setMeshForEntityDirectly(entity, sceneMesh)

Signature

class MeshManager(val scene: Scene, val meshCreators: HashMap<String, (ent: Entity) -> SceneMesh>, val sceneObjectSystem: SceneObjectSystem)

Constructors

MeshManager ( scene , meshCreators , sceneObjectSystem ) : MeshManager
Signature
constructor(scene: Scene, meshCreators: HashMap<String, (ent: Entity) -> SceneMesh>, sceneObjectSystem: SceneObjectSystem)
Parameters
scene: Scene
The Scene instance used for rendering
meshCreators: HashMap
Map of URI schemes to mesh creator functions
sceneObjectSystem: SceneObjectSystem
System for managing SceneObjects

Properties

meshCreators : HashMap
[Get]
Map of URI schemes to mesh creator functions
Signature
val meshCreators: HashMap<String, (ent: Entity) -> SceneMesh>
scene : Scene
[Get]
The Scene instance used for rendering
Signature
val scene: Scene
sceneObjectSystem : SceneObjectSystem
[Get]
System for managing SceneObjects
Signature
val sceneObjectSystem: SceneObjectSystem

Functions

deleteMeshForEntity ( entity )
This method removes the SceneObject associated with the entity and destroys any meshes that were created for it.
Signature
fun deleteMeshForEntity(entity: Entity)
Parameters
entity: Entity
The entity to remove the mesh from
destroy ()
Signature
fun destroy()
retrieveAssociatedMeshFilesForEntity ( entity ) : Array?
Signature
fun retrieveAssociatedMeshFilesForEntity(entity: Entity): Array<<Error class: unknown class>>?
Parameters
entity: Entity
Returns
Array?
setMeshForEntity ( entity , meshSimpleUri , meshFullPathUri , defaultShaderOverride , defaultSceneOverride , useCache )
Attaches a mesh to an Entity based on the provided URIs. Avoid using this method directly and instead assign the Mesh component the Entity.
This method loads a mesh from the specified URI and attaches it to the entity. It supports different URI schemes:
  • mesh:// - Uses a registered mesh creator function
  • gfx:// - Loads a mesh from the GFX system
  • file:// - Loads a mesh from a local file
  • http://, https:// - Loads a mesh from a network location
Any previous mesh attached to the entity will be destroyed.
Signature
fun setMeshForEntity(entity: Entity, meshSimpleUri: Uri, meshFullPathUri: Uri, defaultShaderOverride: String, defaultSceneOverride: Int, useCache: Boolean = true)
Parameters
entity: Entity
The entity to attach the mesh to
meshSimpleUri: Uri
A simple URI used for identification and caching
meshFullPathUri: Uri
The full URI path to the mesh resource
defaultShaderOverride: String
Optional shader override to use when loading the mesh
defaultSceneOverride: Int
Optional scene index override to use when loading the mesh
useCache: Boolean
Whether to use cached meshes (default: true)
setMeshForEntityDirectly ( entity , mesh )
Attaches a mesh directly to an Entity, bypassing the data model. Should use the Mesh component instead.
This method should be used sparingly as it is not reflected by the data model. It's intended as an escape hatch when the mesh creators don't fit well with the standard workflow. Any previous mesh attached to the entity will be destroyed.
Signature
fun setMeshForEntityDirectly(entity: Entity, mesh: SceneMesh)
Parameters
entity: Entity
The entity to attach the mesh to
mesh: SceneMesh
The SceneMesh to attach
Did you find this page helpful?
Thumbs up icon
Thumbs down icon