Lysa Nodes  0.0
Lysa Nodes — Scene Graph for the Lysa Engine
Loading and displaying an asset

Loader::load

lysa::nodes::Loader is the centralized asset loading gateway for Lysa Nodes.

For a .assets file the call is a single line:

assetRoot = Loader::load("app://res/models/crate.assets");

Loader::load internally calls AssetsPack::load<Node, MeshInstance, AnimationPlayer> with the library's own concrete types. The function returns a std::shared_ptr<Node> pointing to the synthetic root that wraps the entire imported hierarchy.

Note
assets pack files are created with tools from the assets_pack_tools repository.

Attaching the loaded subtree

assetRoot = Loader::load("app://res/models/crate.assets");
addChild(assetRoot);

addChild(assetRoot) attaches the entire subtree to the scene tree. Every MeshInstance descendant is registered with the renderer immediately (because the scene tree is already attached to a render target by the time addChild is called for the asset; see the constructor order in Scene tree).

Asynchronous loading

Loader::loadAsync runs the load on a background thread and invokes a callback on the main thread at the start of the next frame:

Loader::loadAsync("app://res/models/crate.assets",
[this](std::shared_ptr<Node> root) {
assetRoot = root;
assetRoot->setVisible(true);
addChild(assetRoot);
});

For assets that take perceptible time to load (large mesh packs, high-res textures), loadAsync is the recommended approach: the application remains responsive while the GPU upload happens in the background.

Caching

Both load and loadAsync accept a useCache = true flag. When caching is enabled the loaded root is stored in a global map keyed by URI, and subsequent calls with the same URI return the cached instance without re-reading the file. Loader::clearCache() drops all cached roots.

Note
Cached nodes are shared; modifying the transform or visibility of a cached root affects all users of that cache entry. Clone the subtree with Node::duplicate() before mutating it when independent instances are needed.

Next : Lights and environment