AlbedoPBR channel, color array

(Madalin Berechet) #1


I am using setMaterial when the events are triggered.
Example here:

All works fine for Classic render (DiffuseColor - the sport model sunglasses) but not for PBR render (DiffusePBR or AlbedoPBR - the art model sunglasses). For the very first time when the 3d model is loaded, AlbedoPBR channel has no color array. You can see it in console.log, where I am listing materialToUpdate. I am using "incognito mode" in order to simulate the first time 3d model loading.

The error message is Uncaught TypeError: Cannot set property '0' of undefined. After reloading, all works fine for AlbedoBPR. The color array appears.

I assume that 3d model are completely loaded when the elementModify event are triggered. Or maybe I didn´t understand how it works setMaterial and materialToUpdate.channels.AlbedoPBR.enable = false; it is not necessary, even worse.

Another issue, especially in Mozilla Firefox 45.0.1: the automatic refresh doesn´t work. I need to rotate the model and only then change occurs. I tried without success api.stop() api.start().

(Shaderbytes) #2

Once you have received a success callback when calling Init() there is another listener you should be implementing :

api.addEventListener('viewerready', yourfunctionhere);

add this logic in and see if this solves your issues

(Madalin Berechet) #3

It was my mistake. I assumed that the nodes always are loaded in the same order. That's totally false, so I was trying to update a material that did not have the color array. Now I'm checking the name of the material before updating, and it works fine. Also added 'viewerready' event listener. Thanks.