loadBaseShaderLibrary function Assets and loading

Future<void> loadBaseShaderLibrary({
  1. AssetBundle? bundle,
})

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({AssetBundle? bundle}) async {
  if (_baseShaderLibrary != null) {
    return;
  }
  try {
    await _loadBaseShaderLibrary(bundle);
  } catch (error) {
    // Retained for the getter, which is synchronous and otherwise cannot say
    // more than "not loaded yet". Cleared on the next successful load.
    _baseShaderLibraryLoadError = error;
    rethrow;
  }
  _baseShaderLibraryLoadError = null;
}