baseShaderLibrary top-level property Assets and loading

ShaderLibrary get baseShaderLibrary

The shader bundle shipped with flutter_scene.

Contains the vertex and fragment shaders used by the built-in geometries (UnskinnedVertex, SkinnedVertex) and materials (StandardFragment, UnlitFragment). Custom Geometry or Material subclasses can pull additional shaders from this library.

Reading a shader bundle from an asset is asynchronous on every backend, so the bundle must be loaded ahead of time by awaiting Scene.initializeStaticResources (which calls loadBaseShaderLibrary); accessing this getter before that completes throws.

Implementation

gpu.ShaderLibrary get baseShaderLibrary {
  final cached = _baseShaderLibrary;
  if (cached == null) {
    throw Exception(
      'The base shader bundle has not been loaded yet. Await '
      'Scene.initializeStaticResources() before constructing geometry or '
      'materials that touch the base shader library.',
    );
  }
  return cached;
}