Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

GSAP modify the material color of a GLTF model but normalize the rgb, result in bad color

$
0
0

i work on R3F, i set the material color with "0x292929" and the color is great! Like i want!

if (modelModifier.color !== undefined) {  gsap.to(material.color, {    r: ((modelModifier.color >> 16) & 255) / 255,    g: ((modelModifier.color >> 8) & 255) / 255,    b: (modelModifier.color & 255) / 255,    duration: 1,    immediateRender: false  })} else {  material.color.setHex(0x292929)}

But now if i change the color with

modelModifier.color: 0xf64941,

The color isnt red but very very light white/red. So i change back to

modelModifier.color: 0x292929,

And the color material isnt dark but is now very very light white/grey.

I think its because of course i normalise the RGB on base/255 so 292929 is now, on normalized RGB: 0.16, 0.16, 0.16 ... Hmm, what i am doing wrong ? I cant normalize the RGB without having the good color i want ? ( Because hex 292929 in rgb is normaly 41, 41, 41 )

Thanks for your help guys!

I try to animate the transition color from hex to hex but GSAP didnt like that at all or with some bad trick. So i need Normalized RGB or maybe simple RGB ?


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>