提交 622a475a 编写于 作者: M Mr.doob

Color: Added lerpColors.

上级 6203ac1e
......@@ -218,6 +218,17 @@ const color7 = new THREE.Color( 1, 0, 0 );
this color and 1.0 is the first argument.
</p>
<h3>[method:this lerpColors]( [param:Color color1], [param:Color color2], [param:Float alpha] )</h3>
<p>
[page:Color color1] - the starting [page:Color].<br />
[page:Color color2] - [page:Color] to interpolate towards.<br />
[page:Float alpha] - interpolation factor, typically in the closed interval [0, 1].<br /><br />
Sets this color to be the color linearly interpolated between [page:Color color1] and
[page:Color color2] where alpha is the percent distance along the line connecting the two colors
- alpha = 0 will be [page:Color color1], and alpha = 1 will be [page:Color color2].
</p>
<h3>[method:Color lerpHSL]( [param:Color color], [param:Float alpha] ) </h3>
<p>
[page:Color color] - color to converge on.<br />
......
......@@ -156,6 +156,7 @@ export class Color {
multiply( color: Color ): this;
multiplyScalar( s: number ): this;
lerp( color: Color, alpha: number ): this;
lerpColors( color1: Color, color2: Color, alpha: number ): this;
lerpHSL( color: Color, alpha: number ): this;
equals( color: Color ): boolean;
......
......@@ -524,6 +524,16 @@ class Color {
}
lerpColors( color1, color2, alpha ) {
this.r = color1.r + ( color2.r - color1.r ) * alpha;
this.g = color1.g + ( color2.g - color1.g ) * alpha;
this.b = color1.b + ( color2.b - color1.b ) * alpha;
return this;
}
lerpHSL( color, alpha ) {
this.getHSL( _hslA );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册