This chapter describes the minimum application setup required before populating the scene.
Initialization
Sezione intitolata “Initialization”AuLoader is a resource-loading utility. It is only needed when the application wants to load resources through it, for example AuBitmap instances coming from the file system or from packaged assets.
If the application does not use AuLoader, there is no need to call AuLoader.init().
When it is used, it should be initialized before loading resources through that class. Any platform-specific context is passed here, not to the rest of the scene objects.
AuLoader.init(context)From this point on, the application can load bitmaps through AuLoader and use them to create textures or widget content.
Creating the world
Sezione intitolata “Creating the world”AuWorld is the root of the AR scene and is always associated with an ARSession from the ARDK.
val world = AuWorld(session)The world is not just a container: it is also the point through which the application notifies the engine about surface creation, viewport changes, and frame rendering.
Resource ownership
Sezione intitolata “Resource ownership”In AuRea it is useful to distinguish between three kinds of resources:
- scene resources, such as AuWorld;
- content resources, such as AuAnchor, AuEntity, AuMesh, AuTexture, AuAnimation;
- support resources, such as bitmaps or widgets used to generate final assets.
To keep the lifecycle predictable:
- create resources as close as possible to the point where they are used;
- keep creation and destruction together;
- avoid indefinite caching of native assets unless they are truly shared.
Practical cleanup strategy
Sezione intitolata “Practical cleanup strategy”A typical teardown sequence is:
- stop updating the rendering loop;
- remove anchors and content that are no longer needed from the world;
- close the native objects created by the application;
- finally close AuWorld.
When a resource is only intermediate, use is the preferred pattern:
AuMesh.Rectangle(width, height).use { mesh -> AuTexture(bitmap, wrapMode, minFilter, magFilter).use { texture -> val panel = AuBasicObject(mesh, texture, 0xFFFFFFFFU, transform) anchor.add(panel) }}The key principle is that native memory does not automatically follow the lifecycle of Kotlin objects. Being disciplined about close() is part of normal framework usage.
When to create and when to reuse
Sezione intitolata “When to create and when to reuse”In a stable integration it is generally best to:
- reuse AuWorld for the entire lifetime of the AR view;
- reuse meshes and textures when the same content appears multiple times;
- create AuAnchor only when a marker becomes truly relevant to the scene;
- initialize AuLoader only in applications that actually load resources through it;
- destroy temporary resources as soon as their purpose has been fulfilled.