The following code changes the material’s texture
//usage
this.entity.model.material.diffuseMap = this.tex_lens.resource;
this.entity.model.material.update();
But the below code gives error as : material.update is not a function
// declaration
Script.attributes.add('mat_lens', {type: 'asset', assetType: 'material',default: null });
//usage
this.mat_lens.diffuseMap = this.tex_lens.resource;// asset.resource;
this.mat_lens.update();
Everytime if we have to take the object and then change the material properties then it becomes longer code. Is there anything wrong in the second code?
vaios
July 19, 2016, 11:01am
#2
Asset attributes are referring to the pc.Asset not the resource itself. So in this case you should do
this.mat_lens.resource
to access the material because this.mat_lens
is the pc.Asset.
1 Like
Thank you Vaios. Only problem is many such important things are not easily available. Can you share some links.
vaios
July 19, 2016, 11:34am
#4
You can find more information about script attributes in the User Manual here:
http://developer.playcanvas.com/en/user-manual/scripting/script-attributes/
And also in the API reference here:
http://developer.playcanvas.com/en/api/pc.ScriptAttributes.html
Let us know if you need any more help
Thank you again.
Please help on the below query as well.
Is there anything call rendertexture (like in unity3d)? i.e whatever the camera is rendering to be stored into a texture which can be used to apply any surface and show on it.