loadMaterial function

Future<RenderMaterial> loadMaterial(
  1. AssetSource source, {
  2. required GraphicsDevice device,
  3. List<MaterialDecoder> decoders = const <MaterialDecoder>[],
  4. LightingModel lighting = LightingModel.pbr,
  5. IssueSink? onIssue,
  6. ImageDecoder decodeImage = defaultImageDecoder,
  7. Map<String, MaterialProgram> programs = const <String, MaterialProgram>{},
  8. LightingModels? lightingModels,
  9. TextureCodecs? codecs,
})

Reads and binds in one call, which is what an application usually wants. programs lifts the parameters as bindMaterial says; lightingModels is what the file is read against, as loadMaterialDocument says, and codecs what its images are decoded with, as bindMaterial says.

Implementation

Future<RenderMaterial> loadMaterial(
  AssetSource source, {
  required GraphicsDevice device,
  List<MaterialDecoder> decoders = const <MaterialDecoder>[],
  LightingModel lighting = LightingModel.pbr,
  IssueSink? onIssue,
  ImageDecoder decodeImage = defaultImageDecoder,
  Map<String, MaterialProgram> programs = const <String, MaterialProgram>{},
  LightingModels? lightingModels,
  TextureCodecs? codecs,
}) async {
  final document = await loadMaterialDocument(
    source,
    decoders: decoders,
    lightingModels: lightingModels,
  );
  for (final warning in document.warnings) {
    onIssue?.call(Issue(warning));
  }
  return bindMaterial(
    document,
    device: device,
    resolveUri: source.resolveUri,
    lighting: lighting,
    onIssue: onIssue,
    decodeImage: decodeImage,
    programs: programs,
    codecs: codecs,
  );
}