loadMaterial function
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,
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,
);
}