GLTFMaterialsSpecularExtension constructor
GLTFMaterialsSpecularExtension(
- dynamic parser
Implementation
GLTFMaterialsSpecularExtension(parser) {
this.parser = parser;
this.name = EXTENSIONS["KHR_MATERIALS_SPECULAR"]!;
this.getMaterialType = (materialIndex) {
var parser = this.parser;
var materialDef = parser.json["materials"][materialIndex];
if (materialDef["extensions"] == null ||
materialDef["extensions"][this.name] == null) return null;
return MeshPhysicalMaterial;
};
this.extendMaterialParams = (materialIndex, materialParams) async {
var parser = this.parser;
var materialDef = parser.json["materials"][materialIndex];
if (materialDef["extensions"] == null ||
materialDef["extensions"][this.name] == null) {
return null;
}
List<Future> pending = [];
var extension = materialDef["extensions"][this.name];
materialParams.specularIntensity =
extension.specularFactor != null ? extension.specularFactor : 1.0;
if (extension.specularTexture != null) {
pending.add(parser.assignTexture(
materialParams, 'specularIntensityMap', extension.specularTexture));
}
var colorArray = extension.specularColorFactor ?? [1, 1, 1];
materialParams.specularColor =
new Color(colorArray[0], colorArray[1], colorArray[2]);
if (extension.specularColorTexture != null) {
var texture = await parser.assignTexture(
materialParams, 'specularColorMap', extension.specularColorTexture, sRGBEncoding);
pending.add(texture);
}
return await Future.wait(pending);
};
}