Sketchfab Forum

Sketchfab API - change material diffuse color


(Num T) #1

Hello!

I am experiencing a maddening problem while trying to change the diffuse color channels using the Sketchfab Viewer API. I can change the anything that doesn't have the 3 length color array - for example the opacity factor is changing no problem with "materialToUpdate.channels.Opacity.factor = 0.5;". However if I try "materialToUdpate.channels.DiffuseColor.color = [1.0, 0.0, 0.0] nothing happens. I can also change the EmitColor no problem.

Any ideas what I might be doing wrong here? It's really bugging me!

Cheers

Jon Westlake


(Shaderbytes) #2

Hi num_t

Not sure why you are having an issue, it could be you are referencing the wrong channel, try setting it on "DiffusePBR"

Also make sure to call setMaterial each time you make a change.

Have you checked out my Viewer API Utility? I have specifically abstracted calls like these to be really simple :wink:


(Num T) #3

Ah - it was actually AlbedoPBR that was the one I needed to use. That's the problem with trying to resolve something late at night for a meeting the next day! All sorted - I'll check out the utility at some point - thanks for the assist!