setClearcolor for renderer

Mr. Doob,

All knowing and all powerfull in the realm of 3D…Mr. Doob, I am gettting an unknown color error while attempting to dynamically change the clear color for the renderer. Here my code:

            try {
                var color = this.value.replace("#", "");
                color = "0x" + color;
                var THREEColor = new THREE.Color(color);

                var renderer = window.renderer;
                renderer.setClearColor(THREEColor, .5);

            } catch (error) {
                handleEvent("rendererClearColor()", error.message, true);
            }

I humbly request assistance in exchange for a pint of your chosing delivered to your favorite pub in the city of your choice…London perhaps…

Hi!
This part

can be just like this

var THREEColor = new THREE.Color(this.value);

As the constructor of Color accepts CSS string for color values.

So this line
console.log(new THREE.Color("#ff8800"));
gives next in console
изображение

You are passing color as a string instead of a number.
Try this
color = +( “0x” + color );

1 Like