Thank you for creating this amazing Engine. I enjoy it very much. An amazing job!
A Question about Entity Assets:
I have a button which gets set a color depending on its status. I used following code:
this.buttonMaterial = buttonMesh.material;
this.buttonMaterial.diffuse.set(255, 0, 0);
ButtonMesh is a Meshinstance of the Model. The problem being I have multiple instances of the model and all meshinstances are being updated. So I guess I am still only editing the model’s assets instead of its entity assets.
But I don’t really know how I can acces these entity materials. I tried accessing the model to get the materials but failed:
this.entity.model.materialAsset == null
Thanks a lot for the help and the great product!
@Sebastian and welcome,
This is a valid question, the way to do it is to update the shader/material values directly on the mesh instance.
That isn’t fully documented right now, but here is a forum post with instructions on how to do this:
These parameters are not really documented on purpose because they are not considered public API yet. You can use them but they might change without notice. Now having said that the material_diffuse parameter expects an array. So this should work:
The ‘proper’ way to change the diffuse color for now is to do it on the material like so:
material.diffuse = new pc.Color(1,1,1);
This will change the …
Note the color values should be passed in the 0.0-1.0 range, not 0-255.
Let me know if this resolves your issue.
you are a hero.
Having provided the correct answer after a mere 19minutes is a job well done.
And thanks for pointing out the correct color values. This one might have caused me major headaches later on.
Cheers to you!