Issue 1:
In my experience most colors in 3D graphics are 4 channel colors (red, green, blue and alpha.) It is only a subset of situations in 3D graphics where a 3 channel color is sufficient and usually that deals with solid surface shading algorithms.

Many situation, such as windows with varying transparent, volume effects and particle effects often need RGBA-based colors. Also blending algorithms where one engages in post-processing one also often needs 4 channel-based colors.

Thus I propose creating a Color4 class that enables easy usage of 4-channel colors.

NOTE: I am unsure of the best way to share the conversion code that is fairly common (and bulky) between Color4 and the existing Color (which I suggest renaming Color3.)

Here is my proposed Color4 class:

Color4

properties:

r as Scalar

g as Scalar

b as Scalar

a as Scalar // a is last so that it matches OpenGL/WebGL style: http://goo.gl/GKuD8

methods:

set( value )

setRGBA( r, g, b, a )

setHSV( h, s, v ) // centralize in helper as HSV doesn't have alpha

setStyle( style as string ) // centralize in helper

setHex( hex as Integer )

copy( color as Color4 )

copyGammaToLinear( color as Color4 ) // I think we don't need this on either Color/Color3 or Color4, just use copy(..).convertGammaToLinear()

copyLinearToGamma( color as Color4 ) // I think we don't need this on either Color/Color3 or Color4, just use copy(..).convertLinearToGamma()

convertGammaToLinear()

convertLinearToGamma()

getHex() // centralize in helper ?

getHexString() // centralize in helper

getStyle() // centralize in helper

getHSV() // centralize in helper as HSV doesn't include alpha

lerpSelf( color as Color4, alpha as Scalar )

clone()

bool equals( color as Color4 ) // this needs to be added to Color/Color3

Issue 2:
In order to load an object it is required to first load the material MTLoader and then load the object OBJLoader

Because the name of the .mtl is written in the .obj (eg mtllib male02.mtl), I'd expect the OBJLoader to automatically load the material

https://github.com/mrdoob/three.js/blob/master/examples/webgl_loader_obj_mtl.html#L75

Currenlty I have to do :

var materials = await new MTLLoader()
.loadAsync("https://example.com/obj/male02.mtl")
materials.preload() //load imgs
var group = await new OBJLoader()
.setMaterials(materials)
.loadAsync("https://example.com/obj/male02.obj")

but I'd like to do

var group = await new OBJLoader()
.loadAsync("https://example.com/obj/male02.obj")

To avoid complexifing too much OBJLoader, we could think having OBJMTLLoader something like :

class OBJMTLLoader extends OBJLoader {
load(url, onLoad, onProgress, onError) {
// make sure that path is set
if(!this.path) { //if the url provided is full url not fn
this.setPath(url.substr(0,url.lastIndexOf('/'))) //FIXME dirname
url = url.substr(url.lastIndexOf('/')) //url is fn
}

const scope = this
const loader = new FileLoader(this.manager)
loader.setPath(this.path)
loader.setRequestHeader(this.requestHeader)
loader.setWithCredentials(this.withCredentials)
loader.load(url, text => {
this.parseMtlAndLoad(text, () =>{
try {
onLoad(scope.parse(text))
} catch (e) {
if (onError) {
onError(e)
} else {
console.error(e)
}
scope.manager.itemError(url)
}
})
}, onProgress, onError)
}

parseMtlAndLoad(text, onLoadMtl) {
if(!this.materials) { //do not load a material if already provided
let idxStart = text.indexOf("mtllib ")
let idxEnd = text.indexOf(".mtl")
if (idxStart !== -1 && idxEnd !== -1 && idxEnd - idxStart > 7) {
var mtlFn = text.substring(idxStart + 7, idxEnd + 4); //to be improved, regex with end/start line; if has multiple mtl?
new MTLLoader().loadAsync(this.path + "/" + mtlFn).then(materials => {
materials.preload()
this.setMaterials(materials)
onLoadMtl()
})
}
} else {
onLoadMtl()
}
}
}