convert method
Map<String, dynamic>
convert(
- dynamic materialsInfo
)
Implementation
Map<String, dynamic> convert(materialsInfo) {
if (options == null) return materialsInfo;
Map<String, dynamic> converted = {};
for (final mn in materialsInfo.keys) {
// Convert materials info into normalized form based on options
final mat = materialsInfo[mn];
Map<String, dynamic> covmat = {};
converted[mn] = covmat;
for (final prop in mat.keys) {
bool save = true;
dynamic value = mat[prop];
final lprop = prop.toLowerCase();
switch (lprop) {
case 'kd':
case 'ka':
case 'ks':
// Diffuse color (color under white light) using RGB values
if (options != null && options!["normalizeRGB"] != null) {
value = [value[0] / 255, value[1] / 255, value[2] / 255];
}
if (options != null && options!["ignoreZeroRGBs"] != null) {
if (value[0] == 0 && value[1] == 0 && value[2] == 0) {
// ignore
save = false;
}
}
break;
default:
break;
}
if (save) {
covmat[lprop] = value;
}
}
}
return converted;
}