HSL颜色与ThreeJs

时间:2015-06-15 14:09:10

标签: javascript colors three.js hsl

让HSL颜色与ThreeJ一起使用时遇到一些麻烦。这是我的代码:

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

getHSLColour的输出类似于:

0.06721230158730158, 0.9913555194805196, 0.658271103896104

这似乎与ThreeJs想要的格式相符。但是当我将exampleColor打印到控制台时,它仍然显示为具有NaN值的RGB颜色:

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

我做错了什么?

1 个答案:

答案 0 :(得分:3)

setHSL expects three different parameters, not an array:

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