Lysa Nodes  0.0
Lysa Nodes — Scene Graph for the Lysa Engine
Loader Class Reference

Detailed Description

Centralized loader for scene trees and external resources.

The Loader resolves a file path from an URI and builds a tree of Node instances from supported formats:

  • JSON scene descriptions
  • Lysa AssetPacks

The loader optionally caches root nodes to allow fast re-use across the application lifetime. Access is thread-safe via an internal mutex.

Classes

struct  SceneNode
 

Static Public Member Functions

template<typename T = Node>
static std::shared_ptr< T > load (const std::string &uri, const bool useCache=false)
 
template<typename T = Node>
static void loadAsync (const std::string &URI, LoaderHandlerCallback callback, const bool useCache=false)
 
template<typename T = Node>
static std::shared_ptr< T > loadScene (const std::string &uri)
 
template<typename T = Node>
static std::shared_ptr< T > findFirst (const std::string &nodeName)
 
static void clearCache ()
 

Member Function Documentation

static void clearCache ( )
static

Clears the global resources cache.

All previously cached root nodes become eligible for destruction once no other shared references exist.

static std::shared_ptr<T> findFirst ( const std::string &  nodeName)
inlinestatic

Searches all cached resource trees and returns the first node that matches the provided name and type.

Template Parameters
TNode subtype used for the search and cast.
Parameters
nodeNameName to match against children of cached roots.
Returns
First matching node, or nullptr if none was found.
static std::shared_ptr<T> load ( const std::string &  uri,
const bool  useCache = false 
)
inlinestatic

Loads a JSON Scene or an AssetPack and returns the constructed node tree.

Template Parameters
TNode subtype to cast the root to (defaults to Node).
Parameters
uriURI to the JSON/glTF/ZRes file
useCacheWhen true, store and re-use the loaded root from a global cache.
Returns
Shared pointer to the loaded root node or nullptr if no scene (possibly from cache).
static void loadAsync ( const std::string &  URI,
LoaderHandlerCallback  callback,
const bool  useCache = false 
)
inlinestatic

Loads an assets pack from a URI in a background thread

Parameters
URIThe URI of the node to load
callbackcallback called at the start of the frame following the loading
useCacheWhen true, store and re-use the loaded root from a global cache.
static std::shared_ptr<T> loadScene ( const std::string &  uri)
inlinestatic

Loads a JSON Scene and returns the constructed node tree.

Parameters
uriURI to the JSON scene