[SOLVED] Multiple materials on same meshinstance - Looking to change an assetreg material

ok - almost

var matGet = app.assets.get(38251248);
console.log(‘matGet :’+matGet );

matGet.diffuse = new pc.Color(1,0,1);

  • outputs me (yet again):

raycast.js?id=38253976&branchId=062396da-e562-458c-8459-ba900f1730e8:82
matGet:[object Object]

  • while the actual diffuse-command runs through without an error.
    All I need is the ressouce-output - the listing you showed me in the screen dump … I can never remember how to access that list (think I know how if it is nodes, but I do not remember; the out of all the " … materialAsset [ …], meshInstances: Array[4] … etc")

is it done with a [0] to access the object? , but then what ??? :-s

ps: don’t bother the ‘???’ (meant for my own approach/energy) :slight_smile:

So I finally found the problem, and it lays within the structure and export of the model.
As I am using MB-lab (which is insanely awesome for graphic artists that use Blender), the finalizing of a character casts a certain structure for all its model objects and materials. This structure has an individual material for each of the appendix oriented objects (eyes, eyelashes, nails, tongue etc.). Upon the body it makes room for (kind of an) anti-erotic approach, where the ‘chest’ and ‘shorts’ are sought to be rendered with a black material. Never the less, this counts up for two different materials upon the same object - the body (skin-material and the anti-erotic black material).
Thus my confusion rose, when I just could not expand the material slots within Blender, for then to control them in PlayCanvas afterwards (?).

Solution: While putting the correct UV-mapping (that MB-lab otherwise provides) a side, I will still be able to achieve my goal within PlayCanvas >>

Here is how to bypass the MB-lab material node-structure, in order for PlayCanvas to read the dedicated material slots as meshinstances:
Open the tab ‘Shading’, and within the node interface, observe the initially cast structure from the finalized MB-lab character:


From here click ‘Surface’ to select ‘Diffuse BSDF’:

Do this to all the materials one wants ‘carried at export’ to Playcanvas for meshinstance.

[Note: At least this what I consider to be ‘most’ true, as I just found out that a refresh of my script-window alongside parsing of the script within editor, made some ‘break throughs’ for this code part:

var entityK = this.app.root.findByName("XYZ");
   // var meshInstances = this.entity.model.meshInstances;
    var meshInstances = entityK.model.meshInstances; console.log('length:'+meshInstances.length);
     for (var i = 0; i < meshInstances.length; ++i) { 
        var mesh = meshInstances[i];
         console.log('m_name:'+meshInstances[i].material.name);
         if(i===2) mesh.material = materialList.resource;
    }

And I do sit on a cabled internet-connection and a new Lenovo P330/i9-9900 machine => thus; to whome it might concern in regards to local user connections, CPU-to-polygon-editorhandling and remote engine-servers etc.
]