HSL Colours with ThreeJs

1.4k views Asked by At

Having a bit of trouble getting HSL colours to work with ThreeJs. Here's my code:

var exampleColor = new THREE.Color( 0xffffff );
exampleColor.setHSL( getHSLColour(exampleObject) );
var exampleMaterial = new THREE.MeshLambertMaterial ( {color: exampleColor} );

The output of getHSLColour is something like:

0.06721230158730158, 0.9913555194805196, 0.658271103896104

Which seems to match the format ThreeJs wants. But when I print exampleColor to the console, it still shows up as an RGB colour with NaN values:

T…E.Color {r: NaN, g: NaN, b: NaN}

What am I doing wrong?

1

There are 1 answers

0
Peter O. On

setHSL expects three different parameters, not an array:

var hsl = getHSLColour(exampleObject);
exampleColor.setHSL( hsl[0], hsl[1], hsl[2] );