parseMaterials method
dynamic
parseMaterials(
- dynamic json,
- dynamic textures
Implementation
parseMaterials(json, textures) {
var cache = {}; // MultiMaterial
var materials = {};
if (json != null) {
var loader = MaterialLoader(null);
loader.setTextures(textures);
for (var i = 0, l = json.length; i < l; i++) {
Map<String, dynamic> data = json[i];
if (data["type"] == 'MultiMaterial') {
// Deprecated
var array = [];
for (var j = 0; j < data["materials"].length; j++) {
var material = data["materials"][j];
if (cache[material.uuid] == null) {
cache[material.uuid] = loader.parse(material);
}
array.add(cache[material.uuid]);
}
materials[data["uuid"]] = array;
} else {
if (cache[data["uuid"]] == null) {
cache[data["uuid"]] = loader.parse(data);
}
materials[data["uuid"]] = cache[data["uuid"]];
}
}
}
return materials;
}