I thought I had it in relation to loading textures - but apparently not. While debugging in relation to loading externally, I find myself in a situation where I struggle to read the mechanisms behind the ‘Tint’-method.
Take this difference within tinting a loaded texture:
-
Without any load methods it is possible to ‘do both’, within the editor when it comes to A: setting a texture B: tinting it afterwards
-
When I try to do this by code the approach fails >> first by the following code:
var meshes = self.getFoxy.model.meshInstances; console.log("MIL: "+meshes.length);
var colorR = 58/255; var colorG = 50/255;var colorB= 47/255;
colorG, colorB);
for(var i=0; i<meshes.length; i++){
if(i ===1 || i ===2 || i ===3 || i ===4){
meshes[i].material.diffuseMapTint.enabled = true; meshes[i].material.diffuse.set(colorR,
colorG, colorB); }
meshes[i].material.update();
}
- the model turns to the color only.
- If changing the order, by setting the texture prior to the colorsetting like this:
var meshes = self.getFoxy.model.meshInstances; console.log("MIL: "+meshes.length);
var colorR = 58/255; var colorG = 50/255;var colorB= 47/255;
colorG, colorB);
for(var i=0; i<meshes.length; i++){
meshes[i].material.diffuseMap = self.app.assets.get(31278812).resource;
if(i ===1 || i ===2 || i ===3 || i ===4){
meshes[i].material.diffuseMapTint.enabled = true; meshes[i].material.diffuse.set(colorR,
colorG, colorB); }
meshes[i].material.update();
}
- the model (and its instances) will change to the texture, but it will not be subject to the colorsetting at ‘.diffuse.set’ afterwards >> the same effect as posted in 1).