(Solved)Strange behavior when using scene.clearColor = BABYLON.Color3(r, g, b)

Hi, I try to set clearColor using scene.clearColor = BABYLON.Color3(0.8, 0.8, 0.8); but Babylonjs render “ghost” frame. If I using builtin Color no problem. example: scene.clearColor = BABYLON.Color3.Gray;
You can reproduce in PG. Just open new PG and change clearColor.

For some reason re-setting the clearColor vector does a bit of magic. If you set the values instead (https://playground.babylonjs.com/#QN92LE#1) it works as expected. @sebavan - any idea where to start looking?

See next answer :slight_smile:

1 Like

Hi @kanyu, you forgot the ‘new’ keyword:


oh my, that was the problem? thanks! gosh, i should have noticed :wink:


Love it :wink:

Note that you should pass a Color4 as it is what clearColor expects.

1 Like

Oh, great answer. Thank you @Gijs
I think Babylon should throw some errors because of assigning wrong type/parameter/Color etc…

Actually using typescript instead of js you would see the error at transpile time :slight_smile:

We can not assert the types of all methods or the framework would be way to slow to run. And typings help a lot with that before runtime.


Oh! I see. That’s great.