loadBaseShaderLibrary function Assets and loading

Future<void> loadBaseShaderLibrary()

Asynchronously loads and caches the base shader bundle. Idempotent. Called by Scene.initializeStaticResources so the synchronous baseShaderLibrary getter has a cached library to return (shader assets can't be read synchronously on any backend).

Implementation

Future<void> loadBaseShaderLibrary() async {
  if (_baseShaderLibrary != null) {
    return;
  }
  final key = await resolveBaseShaderBundleKey();
  if (key == null) {
    throw Exception(baseShaderBundleMissingMessage);
  }
  final lib = await gpu.loadShaderLibraryAsync(key);
  if (lib == null) {
    throw Exception(baseShaderBundleLoadFailureMessage(key));
  }
  _baseShaderLibrary = lib;
}