Any idea why the following code makes the material color change? On my mindset it shouldn’t update the color. Am I doing something wrong or is it a bug?
I am trying to reset the material value to the initial set in the editor.
var MaterialColor = pc.createScript('materialColor');
// initialize code called once per entity
MaterialColor.prototype.initialize = function() {
var color = this.entity.model.meshInstances[0].material.diffuse.clone();
console.log('initial color: ', color.r, color.g, color.b);
window.setTimeout( function(){
var meshInstance = this.entity.model.meshInstances[0];
meshInstance.setParameter('material_diffuse', [color.r, color.g, color.b]);
console.log('color update: ', color.r, color.g, color.b);
}.bind(this), 1500 );
};
In case you’re interested to see where the engine converted non-gamma corrected color properties to gamma corrected shader uniforms, check out this source file: