GLTFMaterialsSpecularExtension constructor
GLTFMaterialsSpecularExtension(
- dynamic parser
Implementation
GLTFMaterialsSpecularExtension(this.parser) {
name = gltfExtensions["KHR_MATERIALS_SPECULAR"]!;
getMaterialType = (materialIndex) {
var parser = this.parser;
var materialDef = parser.json["materials"][materialIndex];
if (materialDef["extensions"] == null || materialDef["extensions"][name] == null) return null;
return MeshPhysicalMaterial;
};
extendMaterialParams = (materialIndex, materialParams) async {
var parser = this.parser;
var materialDef = parser.json["materials"][materialIndex];
if (materialDef["extensions"] == null || materialDef["extensions"][name] == null) {
return null;
}
List<Future> pending = [];
var extension = materialDef["extensions"][name];
materialParams.specularIntensity = 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 = 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);
};
}