Hello, I’m trying to use without success the setParameter( ‘material_diffuse’,…) method to change the color of a model. Here is my code :
var Clone = pc.createScript('clone');
Clone.attributes.add('source', {type:'entity'});
// initialize code called once per entity
Clone.prototype.initialize = function() {
let clone = this.source.clone();
clone.setPosition(1,0.5,1);
this.app.root.addChild(clone);
let mesh = this.source.model.meshInstances[0];
mesh.setParameter( 'material_diffuse', [1,0,0] );
mesh.setParameter( 'material_emissive', [1,0,0] );
mesh = clone.model.meshInstances[0];
mesh.setParameter( 'material_diffuse', [0,1,0] );
//mesh.setParameter( 'material_emissive', [0,1,0] );
};
here is my test project : https://playcanvas.com/project/806696/overview/change-mesh-color
here is the result :
It looks like the ‘material_emissive’ parameter works… but not the ‘material_diffuse’…
Am I missing something ? Thanks for your help !
ps : I would like to avoid cloning materials to achieve this…