(mtl, materials)
return ",\n\n".join([m for i,m in sorted(mtl_array)])
Generate JS array of materials objects

    JS material objects are basically prettified one-to-one
    mappings of MTL properties in JSON format.
Generate JS array of materials objects
Generate JS array of materials objects
def generate_materials(mtl, materials):
    """Generate JS array of materials objects

    JS material objects are basically prettified one-to-one
    mappings of MTL properties in JSON format.
    """

    mtl_array = []
    for m in mtl:
        if m in materials:
            index = materials[m]

            # add debug information
            #  materials should be sorted according to how
            #  they appeared in OBJ file (for the first time)
            #  this index is identifier used in face definitions
            mtl[m]['DbgName'] = m
            mtl[m]['DbgIndex'] = index
            mtl[m]['DbgColor'] = generate_color(index)

            if BAKE_COLORS:
                mtl[m]['vertexColors'] = "face"

            mtl_raw = ",\n".join(['\t"%s" : %s' % (n, value2string(v)) for n,v in sorted(mtl[m].items())])
            mtl_string = "\t{\n%s\n\t}" % mtl_raw
            mtl_array.append([index, mtl_string])

    return ",\n\n".join([m for i,m in sorted(mtl_array)])
def generate_materials ( mtl , materials ) : mtl_array = [ ] for m in mtl : if m in materials : index = materials [ m ] # add debug information #  materials should be sorted according to how #  they appeared in OBJ file (for the first time) #  this index is identifier used in face definitions mtl [ m ] [ 'DbgName' ] = m mtl [ m ] [ 'DbgIndex' ] = index mtl [ m ] [ 'DbgColor' ] = generate_color ( index ) if BAKE_COLORS : mtl [ m ] [ 'vertexColors' ] = "face" mtl_raw = ",\n" . join ( [ '\t"%s" : %s' % ( n , value2string ( v ) ) for n , v in sorted ( mtl [ m ] . items ( ) ) ] ) mtl_string = "\t{\n%s\n\t}" % mtl_raw mtl_array . append ( [ index , mtl_string ] ) return ",\n\n" . join ( [ m for i , m in sorted ( mtl_array ) ] )