parseParameters method
dynamic
parseParameters(
- Map materialNode,
- dynamic textureMap,
- dynamic ID
)
Implementation
parseParameters(Map materialNode, textureMap, ID ) {
Map<String, dynamic> parameters = {};
if ( materialNode["BumpFactor"] != null ) {
parameters["bumpScale"] = materialNode["BumpFactor"]["value"];
}
if ( materialNode["Diffuse"] != null ) {
parameters["color"] = new Color().fromArray( List<double>.from(materialNode["Diffuse"]["value"]) );
} else if ( materialNode["DiffuseColor"] != null && ( materialNode["DiffuseColor"]["type"] == 'Color' || materialNode["DiffuseColor"]["type"] == 'ColorRGB' ) ) {
// The blender exporter exports diffuse here instead of in materialNode.Diffuse
parameters["color"] = new Color().fromArray( materialNode["DiffuseColor"]["value"] );
}
if ( materialNode["DisplacementFactor"] != null ) {
parameters["displacementScale"] = materialNode["DisplacementFactor"]["value"];
}
if ( materialNode["Emissive"] != null ) {
parameters["emissive"] = new Color().fromArray( List<double>.from(materialNode["Emissive"]["value"]) );
} else if ( materialNode["EmissiveColor"] != null && ( materialNode["EmissiveColor"]["type"] == 'Color' || materialNode["EmissiveColor"].type == 'ColorRGB' ) ) {
// The blender exporter exports emissive color here instead of in materialNode.Emissive
parameters["emissive"] = new Color().fromArray( List<double>.from(materialNode["EmissiveColor"]["value"]) );
}
if ( materialNode["EmissiveFactor"] != null ) {
parameters["emissiveIntensity"] = parseFloat( materialNode["EmissiveFactor"]["value"] );
}
if ( materialNode["Opacity"] != null ) {
parameters["opacity"] = parseFloat( materialNode["Opacity"]["value"].toString() );
}
if ( parameters["opacity"] < 1.0 ) {
parameters["transparent"] = true;
}
if ( materialNode["ReflectionFactor"] != null ) {
parameters["reflectivity"] = materialNode["ReflectionFactor"]["value"];
}
if ( materialNode["Shininess"] != null ) {
parameters["shininess"] = materialNode["Shininess"]["value"];
}
if ( materialNode["Specular"] != null ) {
parameters["specular"] = new Color().fromArray( List<double>.from(materialNode["Specular"]["value"]) );
} else if ( materialNode["SpecularColor"] != null && materialNode["SpecularColor"]["type"] == 'Color' ) {
// The blender exporter exports specular color here instead of in materialNode.Specular
parameters["specular"] = new Color().fromArray( materialNode["SpecularColor"]["value"] );
}
var scope = this;
final connection = connections[ ID ];
if(connection["children"] != null) {
connection["children"].forEach( ( child ) {
var type = child["relationship"];
var childID = child["ID"];
switch ( type ) {
case 'Bump':
parameters["bumpMap"] = scope.getTexture( textureMap, childID );
break;
case 'Maya|TEX_ao_map':
parameters["aoMap"] = scope.getTexture( textureMap, childID );
break;
case 'DiffuseColor':
case 'Maya|TEX_color_map':
parameters["map"] = scope.getTexture( textureMap, childID );
if ( parameters["map"] != null ) {
parameters["map"].encoding = sRGBEncoding;
}
break;
case 'DisplacementColor':
parameters["displacementMap"] = scope.getTexture( textureMap, childID );
break;
case 'EmissiveColor':
parameters["emissiveMap"] = scope.getTexture( textureMap, childID );
if ( parameters["emissiveMap"] != null ) {
parameters["emissiveMap"].encoding = sRGBEncoding;
}
break;
case 'NormalMap':
case 'Maya|TEX_normal_map':
parameters["normalMap"] = scope.getTexture( textureMap, childID );
break;
case 'ReflectionColor':
parameters["envMap"] = scope.getTexture( textureMap, childID );
if ( parameters["envMap"] != null ) {
parameters["envMap"].mapping = EquirectangularReflectionMapping;
parameters["envMap"].encoding = sRGBEncoding;
}
break;
case 'SpecularColor':
parameters["specularMap"] = scope.getTexture( textureMap, childID );
if ( parameters["specularMap"] != null ) {
parameters["specularMap"].encoding = sRGBEncoding;
}
break;
case 'TransparentColor':
case 'TransparencyFactor':
parameters["alphaMap"] = scope.getTexture( textureMap, childID );
parameters["transparent"] = true;
break;
case 'AmbientColor':
case 'ShininessExponent': // AKA glossiness map
case 'SpecularFactor': // AKA specularLevel
case 'VectorDisplacementColor': // NOTE: Seems to be a copy of DisplacementColor
default:
print( 'THREE.FBXLoader: %s map is not supported in three.js, skipping texture. ${type}' );
break;
}
} );
}
return parameters;
}