Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
50beaac1
T
three.js
项目概览
Ablesons
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
50beaac1
编写于
11月 06, 2012
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Moved ColorUtils.rgbToHsv into Color.getHSV
Fixes #2600
上级
78103f39
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
145 addition
and
142 deletion
+145
-142
build/three.js
build/three.js
+71
-69
build/three.min.js
build/three.min.js
+3
-4
src/core/Color.js
src/core/Color.js
+70
-0
src/extras/ColorUtils.js
src/extras/ColorUtils.js
+1
-69
未找到文件。
build/three.js
浏览文件 @
50beaac1
...
...
@@ -460,6 +460,76 @@ THREE.Color.prototype = {
},
getHSV: function ( hsv ) {
// based on MochiKit implementation by Bob Ippolito
// h,s,v ranges are < 0.0 - 1.0 >
var r = this.r;
var g = this.g;
var b = this.b;
var max = Math.max( Math.max( r, g ), b );
var min = Math.min( Math.min( r, g ), b );
var hue;
var saturation;
var value = max;
if ( min === max ) {
hue = 0;
saturation = 0;
} else {
var delta = ( max - min );
saturation = delta / max;
if ( r === max ) {
hue = ( g - b ) / delta;
} else if ( g === max ) {
hue = 2 + ( ( b - r ) / delta );
} else {
hue = 4 + ( ( r - g ) / delta );
}
hue /= 6;
if ( hue < 0 ) {
hue += 1;
}
if ( hue > 1 ) {
hue -= 1;
}
}
if ( hsv === undefined ) {
hsv = { h: 0, s: 0, v: 0 };
}
hsv.h = hue;
hsv.s = saturation;
hsv.v = value;
return hsv;
},
clone: function () {
return new THREE.Color().setRGB( this.r, this.g, this.b );
...
...
@@ -23226,7 +23296,7 @@ THREE.ColorUtils = {
var hsv = THREE.ColorUtils.__hsv;
THREE.ColorUtils.rgbToHsv( color,
hsv );
color.getHSV(
hsv );
hsv.h = THREE.Math.clamp( hsv.h + h, 0, 1 );
hsv.s = THREE.Math.clamp( hsv.s + s, 0, 1 );
...
...
@@ -23234,74 +23304,6 @@ THREE.ColorUtils = {
color.setHSV( hsv.h, hsv.s, hsv.v );
},
// based on MochiKit implementation by Bob Ippolito
rgbToHsv : function ( color, hsv ) {
var r = color.r;
var g = color.g;
var b = color.b;
var max = Math.max( Math.max( r, g ), b );
var min = Math.min( Math.min( r, g ), b );
var hue;
var saturation;
var value = max;
if ( min === max ) {
hue = 0;
saturation = 0;
} else {
var delta = ( max - min );
saturation = delta / max;
if ( r === max ) {
hue = ( g - b ) / delta;
} else if ( g === max ) {
hue = 2 + ( ( b - r ) / delta );
} else {
hue = 4 + ( ( r - g ) / delta );
}
hue /= 6;
if ( hue < 0 ) {
hue += 1;
}
if ( hue > 1 ) {
hue -= 1;
}
}
if ( hsv === undefined ) {
hsv = { h: 0, s: 0, v: 0 };
}
hsv.h = hue;
hsv.s = saturation;
hsv.v = value;
return hsv;
}
};
...
...
build/three.min.js
浏览文件 @
50beaac1
...
...
@@ -10,8 +10,8 @@ THREE.Clock.prototype.start=function(){this.oldTime=this.startTime=Date.now();th
THREE
.
Color
=
function
(
a
){
void
0
!==
a
&&
this
.
setHex
(
a
);
return
this
};
THREE
.
Color
.
prototype
=
{
constructor
:
THREE
.
Color
,
r
:
1
,
g
:
1
,
b
:
1
,
copy
:
function
(
a
){
this
.
r
=
a
.
r
;
this
.
g
=
a
.
g
;
this
.
b
=
a
.
b
;
return
this
},
copyGammaToLinear
:
function
(
a
){
this
.
r
=
a
.
r
*
a
.
r
;
this
.
g
=
a
.
g
*
a
.
g
;
this
.
b
=
a
.
b
*
a
.
b
;
return
this
},
copyLinearToGamma
:
function
(
a
){
this
.
r
=
Math
.
sqrt
(
a
.
r
);
this
.
g
=
Math
.
sqrt
(
a
.
g
);
this
.
b
=
Math
.
sqrt
(
a
.
b
);
return
this
},
convertGammaToLinear
:
function
(){
var
a
=
this
.
r
,
b
=
this
.
g
,
c
=
this
.
b
;
this
.
r
=
a
*
a
;
this
.
g
=
b
*
b
;
this
.
b
=
c
*
c
;
return
this
},
convertLinearToGamma
:
function
(){
this
.
r
=
Math
.
sqrt
(
this
.
r
);
this
.
g
=
Math
.
sqrt
(
this
.
g
);
this
.
b
=
Math
.
sqrt
(
this
.
b
);
return
this
},
setRGB
:
function
(
a
,
b
,
c
){
this
.
r
=
a
;
this
.
g
=
b
;
this
.
b
=
c
;
return
this
},
setHSV
:
function
(
a
,
b
,
c
){
var
d
,
e
,
f
;
0
===
c
?
this
.
r
=
this
.
g
=
this
.
b
=
0
:(
d
=
Math
.
floor
(
6
*
a
),
e
=
6
*
a
-
d
,
a
=
c
*
(
1
-
b
),
f
=
c
*
(
1
-
b
*
e
),
b
=
c
*
(
1
-
b
*
(
1
-
e
)),
0
===
d
?(
this
.
r
=
c
,
this
.
g
=
b
,
this
.
b
=
a
):
1
===
d
?(
this
.
r
=
f
,
this
.
g
=
c
,
this
.
b
=
a
):
2
===
d
?(
this
.
r
=
a
,
this
.
g
=
c
,
this
.
b
=
b
):
3
===
d
?(
this
.
r
=
a
,
this
.
g
=
f
,
this
.
b
=
c
):
4
===
d
?(
this
.
r
=
b
,
this
.
g
=
a
,
this
.
b
=
c
):
5
===
d
&&
(
this
.
r
=
c
,
this
.
g
=
a
,
this
.
b
=
f
));
return
this
},
setHex
:
function
(
a
){
a
=
Math
.
floor
(
a
);
this
.
r
=
(
a
>>
16
&
255
)
/
255
;
this
.
g
=
(
a
>>
8
&
255
)
/
255
;
this
.
b
=
(
a
&
255
)
/
255
;
return
this
},
lerpSelf
:
function
(
a
,
b
){
this
.
r
+=
(
a
.
r
-
this
.
r
)
*
b
;
this
.
g
+=
(
a
.
g
-
this
.
g
)
*
b
;
this
.
b
+=
(
a
.
b
-
this
.
b
)
*
b
;
return
this
},
getHex
:
function
(){
return
255
*
this
.
r
<<
16
^
255
*
this
.
g
<<
8
^
255
*
this
.
b
<<
0
},
getHexString
:
function
(){
return
(
"
000000
"
+
this
.
getHex
().
toString
(
16
)).
slice
(
-
6
)},
getContextStyle
:
function
(){
return
"
rgb(
"
+
(
255
*
this
.
r
|
0
)
+
"
,
"
+
(
255
*
this
.
g
|
0
)
+
"
,
"
+
(
255
*
this
.
b
|
0
)
+
"
)
"
},
clone
:
function
(){
return
(
new
THREE
.
Color
).
setRGB
(
this
.
r
,
this
.
g
,
this
.
b
)}};
THREE
.
Vector2
=
function
(
a
,
b
){
this
.
x
=
a
||
0
;
this
.
y
=
b
||
0
};
255
)
/
255
;
this
.
g
=
(
a
>>
8
&
255
)
/
255
;
this
.
b
=
(
a
&
255
)
/
255
;
return
this
},
lerpSelf
:
function
(
a
,
b
){
this
.
r
+=
(
a
.
r
-
this
.
r
)
*
b
;
this
.
g
+=
(
a
.
g
-
this
.
g
)
*
b
;
this
.
b
+=
(
a
.
b
-
this
.
b
)
*
b
;
return
this
},
getHex
:
function
(){
return
255
*
this
.
r
<<
16
^
255
*
this
.
g
<<
8
^
255
*
this
.
b
<<
0
},
getHexString
:
function
(){
return
(
"
000000
"
+
this
.
getHex
().
toString
(
16
)).
slice
(
-
6
)},
getContextStyle
:
function
(){
return
"
rgb(
"
+
(
255
*
this
.
r
|
0
)
+
"
,
"
+
(
255
*
this
.
g
|
0
)
+
"
,
"
+
(
255
*
this
.
b
|
0
)
+
"
)
"
},
getHSV
:
function
(
a
){
var
b
=
this
.
r
,
c
=
this
.
g
,
d
=
this
.
b
,
e
=
Math
.
max
(
Math
.
max
(
b
,
c
),
d
),
f
=
Math
.
min
(
Math
.
min
(
b
,
c
),
d
);
if
(
f
===
e
)
f
=
b
=
0
;
else
{
var
g
=
e
-
f
,
f
=
g
/
e
,
b
=
(
b
===
e
?(
c
-
d
)
/
g
:
c
===
e
?
2
+
(
d
-
b
)
/
g
:
4
+
(
b
-
c
)
/
g
)
/
6
;
0
>
b
&&
(
b
+=
1
);
1
<
b
&&
(
b
-=
1
)}
void
0
===
a
&&
(
a
=
{
h
:
0
,
s
:
0
,
v
:
0
});
a
.
h
=
b
;
a
.
s
=
f
;
a
.
v
=
e
;
return
a
},
clone
:
function
(){
return
(
new
THREE
.
Color
).
setRGB
(
this
.
r
,
this
.
g
,
this
.
b
)}};
THREE
.
Vector2
=
function
(
a
,
b
){
this
.
x
=
a
||
0
;
this
.
y
=
b
||
0
};
THREE
.
Vector2
.
prototype
=
{
constructor
:
THREE
.
Vector2
,
set
:
function
(
a
,
b
){
this
.
x
=
a
;
this
.
y
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
x
=
a
.
x
;
this
.
y
=
a
.
y
;
return
this
},
add
:
function
(
a
,
b
){
this
.
x
=
a
.
x
+
b
.
x
;
this
.
y
=
a
.
y
+
b
.
y
;
return
this
},
addSelf
:
function
(
a
){
this
.
x
+=
a
.
x
;
this
.
y
+=
a
.
y
;
return
this
},
sub
:
function
(
a
,
b
){
this
.
x
=
a
.
x
-
b
.
x
;
this
.
y
=
a
.
y
-
b
.
y
;
return
this
},
subSelf
:
function
(
a
){
this
.
x
-=
a
.
x
;
this
.
y
-=
a
.
y
;
return
this
},
multiplyScalar
:
function
(
a
){
this
.
x
*=
a
;
this
.
y
*=
a
;
return
this
},
divideScalar
:
function
(
a
){
a
?(
this
.
x
/=
a
,
this
.
y
/=
a
):
this
.
set
(
0
,
0
);
return
this
},
negate
:
function
(){
return
this
.
multiplyScalar
(
-
1
)},
dot
:
function
(
a
){
return
this
.
x
*
a
.
x
+
this
.
y
*
a
.
y
},
lengthSq
:
function
(){
return
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
},
length
:
function
(){
return
Math
.
sqrt
(
this
.
lengthSq
())},
normalize
:
function
(){
return
this
.
divideScalar
(
this
.
length
())},
distanceTo
:
function
(
a
){
return
Math
.
sqrt
(
this
.
distanceToSquared
(
a
))},
distanceToSquared
:
function
(
a
){
var
b
=
this
.
x
-
a
.
x
,
a
=
this
.
y
-
a
.
y
;
return
b
*
b
+
a
*
a
},
setLength
:
function
(
a
){
return
this
.
normalize
().
multiplyScalar
(
a
)},
lerpSelf
:
function
(
a
,
b
){
this
.
x
+=
(
a
.
x
-
this
.
x
)
*
b
;
this
.
y
+=
(
a
.
y
-
this
.
y
)
*
b
;
return
this
},
equals
:
function
(
a
){
return
a
.
x
===
this
.
x
&&
a
.
y
===
this
.
y
},
isZero
:
function
(
a
){
return
this
.
lengthSq
()
<
(
void
0
!==
a
?
a
:
1
E
-
4
)},
clone
:
function
(){
return
new
THREE
.
Vector2
(
this
.
x
,
this
.
y
)}};
THREE
.
Vector3
=
function
(
a
,
b
,
c
){
this
.
x
=
a
||
0
;
this
.
y
=
b
||
0
;
this
.
z
=
c
||
0
};
...
...
@@ -503,8 +503,7 @@ THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,
THREE
.
RenderableFace3
=
function
(){
this
.
v1
=
new
THREE
.
RenderableVertex
;
this
.
v2
=
new
THREE
.
RenderableVertex
;
this
.
v3
=
new
THREE
.
RenderableVertex
;
this
.
centroidWorld
=
new
THREE
.
Vector3
;
this
.
centroidScreen
=
new
THREE
.
Vector3
;
this
.
normalWorld
=
new
THREE
.
Vector3
;
this
.
vertexNormalsWorld
=
[
new
THREE
.
Vector3
,
new
THREE
.
Vector3
,
new
THREE
.
Vector3
];
this
.
vertexNormalsLength
=
0
;
this
.
material
=
this
.
color
=
null
;
this
.
uvs
=
[[]];
this
.
z
=
null
};
THREE
.
RenderableFace4
=
function
(){
this
.
v1
=
new
THREE
.
RenderableVertex
;
this
.
v2
=
new
THREE
.
RenderableVertex
;
this
.
v3
=
new
THREE
.
RenderableVertex
;
this
.
v4
=
new
THREE
.
RenderableVertex
;
this
.
centroidWorld
=
new
THREE
.
Vector3
;
this
.
centroidScreen
=
new
THREE
.
Vector3
;
this
.
normalWorld
=
new
THREE
.
Vector3
;
this
.
vertexNormalsWorld
=
[
new
THREE
.
Vector3
,
new
THREE
.
Vector3
,
new
THREE
.
Vector3
,
new
THREE
.
Vector3
];
this
.
vertexNormalsLength
=
0
;
this
.
material
=
this
.
color
=
null
;
this
.
uvs
=
[[]];
this
.
z
=
null
};
THREE
.
RenderableObject
=
function
(){
this
.
z
=
this
.
object
=
null
};
THREE
.
RenderableParticle
=
function
(){
this
.
rotation
=
this
.
z
=
this
.
y
=
this
.
x
=
this
.
object
=
null
;
this
.
scale
=
new
THREE
.
Vector2
;
this
.
material
=
null
};
THREE
.
RenderableLine
=
function
(){
this
.
z
=
null
;
this
.
v1
=
new
THREE
.
RenderableVertex
;
this
.
v2
=
new
THREE
.
RenderableVertex
;
this
.
material
=
null
};
THREE
.
ColorUtils
=
{
adjustHSV
:
function
(
a
,
b
,
c
,
d
){
var
e
=
THREE
.
ColorUtils
.
__hsv
;
THREE
.
ColorUtils
.
rgbToHsv
(
a
,
e
);
e
.
h
=
THREE
.
Math
.
clamp
(
e
.
h
+
b
,
0
,
1
);
e
.
s
=
THREE
.
Math
.
clamp
(
e
.
s
+
c
,
0
,
1
);
e
.
v
=
THREE
.
Math
.
clamp
(
e
.
v
+
d
,
0
,
1
);
a
.
setHSV
(
e
.
h
,
e
.
s
,
e
.
v
)},
rgbToHsv
:
function
(
a
,
b
){
var
c
=
a
.
r
,
d
=
a
.
g
,
e
=
a
.
b
,
f
=
Math
.
max
(
Math
.
max
(
c
,
d
),
e
),
g
=
Math
.
min
(
Math
.
min
(
c
,
d
),
e
);
if
(
g
===
f
)
g
=
c
=
0
;
else
{
var
h
=
f
-
g
,
g
=
h
/
f
,
c
=
(
c
===
f
?(
d
-
e
)
/
h
:
d
===
f
?
2
+
(
e
-
c
)
/
h
:
4
+
(
c
-
d
)
/
h
)
/
6
;
0
>
c
&&
(
c
+=
1
);
1
<
c
&&
(
c
-=
1
)}
void
0
===
b
&&
(
b
=
{
h
:
0
,
s
:
0
,
v
:
0
});
b
.
h
=
c
;
b
.
s
=
g
;
b
.
v
=
f
;
return
b
}};
THREE
.
ColorUtils
.
__hsv
=
{
h
:
0
,
s
:
0
,
v
:
0
};
THREE
.
ColorUtils
=
{
adjustHSV
:
function
(
a
,
b
,
c
,
d
){
var
e
=
THREE
.
ColorUtils
.
__hsv
;
a
.
getHSV
(
e
);
e
.
h
=
THREE
.
Math
.
clamp
(
e
.
h
+
b
,
0
,
1
);
e
.
s
=
THREE
.
Math
.
clamp
(
e
.
s
+
c
,
0
,
1
);
e
.
v
=
THREE
.
Math
.
clamp
(
e
.
v
+
d
,
0
,
1
);
a
.
setHSV
(
e
.
h
,
e
.
s
,
e
.
v
)}};
THREE
.
ColorUtils
.
__hsv
=
{
h
:
0
,
s
:
0
,
v
:
0
};
THREE
.
GeometryUtils
=
{
merge
:
function
(
a
,
b
){
for
(
var
c
,
d
,
e
=
a
.
vertices
.
length
,
f
=
b
instanceof
THREE
.
Mesh
?
b
.
geometry
:
b
,
g
=
a
.
vertices
,
h
=
f
.
vertices
,
i
=
a
.
faces
,
j
=
f
.
faces
,
m
=
a
.
faceVertexUvs
[
0
],
n
=
f
.
faceVertexUvs
[
0
],
l
=
{},
p
=
0
;
p
<
a
.
materials
.
length
;
p
++
)
l
[
a
.
materials
[
p
].
id
]
=
p
;
b
instanceof
THREE
.
Mesh
&&
(
b
.
matrixAutoUpdate
&&
b
.
updateMatrix
(),
c
=
b
.
matrix
,
d
=
new
THREE
.
Matrix4
,
d
.
extractRotation
(
c
,
b
.
scale
));
for
(
var
p
=
0
,
o
=
h
.
length
;
p
<
o
;
p
++
){
var
q
=
h
[
p
].
clone
();
c
&&
c
.
multiplyVector3
(
q
);
g
.
push
(
q
)}
p
=
0
;
for
(
o
=
j
.
length
;
p
<
o
;
p
++
){
var
g
=
j
[
p
],
s
,
r
,
A
=
g
.
vertexNormals
,
u
=
g
.
vertexColors
;
g
instanceof
THREE
.
Face3
?
s
=
new
THREE
.
Face3
(
g
.
a
+
e
,
g
.
b
+
e
,
g
.
c
+
e
):
g
instanceof
THREE
.
Face4
&&
(
s
=
new
THREE
.
Face4
(
g
.
a
+
e
,
g
.
b
+
e
,
g
.
c
+
e
,
g
.
d
+
e
));
s
.
normal
.
copy
(
g
.
normal
);
d
&&
d
.
multiplyVector3
(
s
.
normal
);
h
=
0
;
for
(
q
=
A
.
length
;
h
<
q
;
h
++
)
r
=
A
[
h
].
clone
(),
d
&&
d
.
multiplyVector3
(
r
),
s
.
vertexNormals
.
push
(
r
);
s
.
color
.
copy
(
g
.
color
);
h
=
0
;
for
(
q
=
u
.
length
;
h
<
q
;
h
++
)
r
=
u
[
h
],
s
.
vertexColors
.
push
(
r
.
clone
());
void
0
!==
g
.
materialIndex
&&
(
h
=
f
.
materials
[
g
.
materialIndex
],
q
=
h
.
id
,
u
=
l
[
q
],
void
0
===
u
&&
(
u
=
a
.
materials
.
length
,
l
[
q
]
=
u
,
a
.
materials
.
push
(
h
)),
s
.
materialIndex
=
u
);
s
.
centroid
.
copy
(
g
.
centroid
);
c
&&
c
.
multiplyVector3
(
s
.
centroid
);
i
.
push
(
s
)}
p
=
0
;
for
(
o
=
n
.
length
;
p
<
o
;
p
++
){
c
=
n
[
p
];
d
=
[];
h
=
0
;
for
(
q
=
c
.
length
;
h
<
q
;
h
++
)
d
.
push
(
new
THREE
.
UV
(
c
[
h
].
u
,
c
[
h
].
v
));
m
.
push
(
d
)}},
clone
:
function
(
a
){
var
b
=
new
THREE
.
Geometry
,
c
,
d
=
a
.
vertices
,
e
=
a
.
faces
,
f
=
a
.
faceVertexUvs
[
0
];
a
.
materials
&&
(
b
.
materials
=
a
.
materials
.
slice
());
a
=
0
;
for
(
c
=
d
.
length
;
a
<
c
;
a
++
)
b
.
vertices
.
push
(
d
[
a
].
clone
());
a
=
0
;
for
(
c
=
e
.
length
;
a
<
c
;
a
++
)
b
.
faces
.
push
(
e
[
a
].
clone
());
a
=
0
;
for
(
c
=
f
.
length
;
a
<
...
...
src/core/Color.js
浏览文件 @
50beaac1
...
...
@@ -181,6 +181,76 @@ THREE.Color.prototype = {
},
getHSV
:
function
(
hsv
)
{
// based on MochiKit implementation by Bob Ippolito
// h,s,v ranges are < 0.0 - 1.0 >
var
r
=
this
.
r
;
var
g
=
this
.
g
;
var
b
=
this
.
b
;
var
max
=
Math
.
max
(
Math
.
max
(
r
,
g
),
b
);
var
min
=
Math
.
min
(
Math
.
min
(
r
,
g
),
b
);
var
hue
;
var
saturation
;
var
value
=
max
;
if
(
min
===
max
)
{
hue
=
0
;
saturation
=
0
;
}
else
{
var
delta
=
(
max
-
min
);
saturation
=
delta
/
max
;
if
(
r
===
max
)
{
hue
=
(
g
-
b
)
/
delta
;
}
else
if
(
g
===
max
)
{
hue
=
2
+
(
(
b
-
r
)
/
delta
);
}
else
{
hue
=
4
+
(
(
r
-
g
)
/
delta
);
}
hue
/=
6
;
if
(
hue
<
0
)
{
hue
+=
1
;
}
if
(
hue
>
1
)
{
hue
-=
1
;
}
}
if
(
hsv
===
undefined
)
{
hsv
=
{
h
:
0
,
s
:
0
,
v
:
0
};
}
hsv
.
h
=
hue
;
hsv
.
s
=
saturation
;
hsv
.
v
=
value
;
return
hsv
;
},
clone
:
function
()
{
return
new
THREE
.
Color
().
setRGB
(
this
.
r
,
this
.
g
,
this
.
b
);
...
...
src/extras/ColorUtils.js
浏览文件 @
50beaac1
...
...
@@ -8,7 +8,7 @@ THREE.ColorUtils = {
var
hsv
=
THREE
.
ColorUtils
.
__hsv
;
THREE
.
ColorUtils
.
rgbToHsv
(
color
,
hsv
);
color
.
getHSV
(
hsv
);
hsv
.
h
=
THREE
.
Math
.
clamp
(
hsv
.
h
+
h
,
0
,
1
);
hsv
.
s
=
THREE
.
Math
.
clamp
(
hsv
.
s
+
s
,
0
,
1
);
...
...
@@ -16,74 +16,6 @@ THREE.ColorUtils = {
color
.
setHSV
(
hsv
.
h
,
hsv
.
s
,
hsv
.
v
);
},
// based on MochiKit implementation by Bob Ippolito
rgbToHsv
:
function
(
color
,
hsv
)
{
var
r
=
color
.
r
;
var
g
=
color
.
g
;
var
b
=
color
.
b
;
var
max
=
Math
.
max
(
Math
.
max
(
r
,
g
),
b
);
var
min
=
Math
.
min
(
Math
.
min
(
r
,
g
),
b
);
var
hue
;
var
saturation
;
var
value
=
max
;
if
(
min
===
max
)
{
hue
=
0
;
saturation
=
0
;
}
else
{
var
delta
=
(
max
-
min
);
saturation
=
delta
/
max
;
if
(
r
===
max
)
{
hue
=
(
g
-
b
)
/
delta
;
}
else
if
(
g
===
max
)
{
hue
=
2
+
(
(
b
-
r
)
/
delta
);
}
else
{
hue
=
4
+
(
(
r
-
g
)
/
delta
);
}
hue
/=
6
;
if
(
hue
<
0
)
{
hue
+=
1
;
}
if
(
hue
>
1
)
{
hue
-=
1
;
}
}
if
(
hsv
===
undefined
)
{
hsv
=
{
h
:
0
,
s
:
0
,
v
:
0
};
}
hsv
.
h
=
hue
;
hsv
.
s
=
saturation
;
hsv
.
v
=
value
;
return
hsv
;
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录