Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
e5d3ea7b
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,发现更多精彩内容 >>
提交
e5d3ea7b
编写于
2月 24, 2013
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'bhouston/color-converter' into dev
上级
0aa53f0a
a6852307
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
128 addition
and
4 deletion
+128
-4
examples/js/math/ColorConverter.js
examples/js/math/ColorConverter.js
+76
-0
src/math/Color.js
src/math/Color.js
+6
-0
test/unit/math/ColorConverter.js
test/unit/math/ColorConverter.js
+35
-0
test/unit/math/Line3.js
test/unit/math/Line3.js
+0
-1
test/unit/unittests_sources.html
test/unit/unittests_sources.html
+2
-0
test/unit/unittests_three-math.html
test/unit/unittests_three-math.html
+3
-1
test/unit/unittests_three.html
test/unit/unittests_three.html
+3
-1
test/unit/unittests_three.min.html
test/unit/unittests_three.min.html
+3
-1
未找到文件。
examples/js/math/ColorConverter.js
0 → 100644
浏览文件 @
e5d3ea7b
/**
* @author bhouston / http://exocortex.com/
*/
THREE
.
ColorConverter
=
{
fromRGB
:
function
(
color
,
r
,
g
,
b
)
{
return
color
.
setRGB
(
r
,
g
,
b
);
},
fromHex
:
function
(
color
,
hex
)
{
return
color
.
setHex
(
hex
);
},
toHex
:
function
(
color
)
{
return
color
.
getHex
();
},
toHexString
:
function
(
color
)
{
return
color
.
getHexString
(
color
);
},
fromHSL
:
function
(
color
,
h
,
s
,
l
)
{
return
color
.
setHSL
(
h
,
s
,
l
);
},
toHSL
:
function
(
color
)
{
return
color
.
getHSL
(
color
);
},
fromHSV
:
function
(
color
,
h
,
s
,
v
)
{
// https://gist.github.com/xpansive/1337890#file-index-js
return
color
.
setHSL
(
h
,
(
s
*
v
)
/
(
(
h
=
(
2
-
s
)
*
v
)
<
1
?
h
:
(
2
-
h
)
),
h
*
0.5
);
},
toHSV
:
function
(
color
)
{
var
hsl
=
color
.
getHSL
();
// based on https://gist.github.com/xpansive/1337890#file-index-js
hsl
.
s
*=
(
hsl
.
l
<
0.5
)
?
hsl
.
l
:
(
1
-
hsl
.
l
);
return
{
h
:
hsl
.
h
,
s
:
2
*
hsl
.
s
/
(
hsl
.
l
+
hsl
.
s
),
v
:
hsl
.
l
+
hsl
.
s
};
},
fromStyle
:
function
(
color
,
style
)
{
return
color
.
setStyle
(
style
);
},
toStyle
:
function
(
color
)
{
return
color
.
getStyle
(
color
);
}
};
\ No newline at end of file
src/math/Color.js
浏览文件 @
e5d3ea7b
...
...
@@ -351,6 +351,12 @@ THREE.extend( THREE.Color.prototype, {
},
equals
:
function
(
c
)
{
return
(
c
.
r
===
this
.
r
)
&&
(
c
.
g
===
this
.
g
)
&&
(
c
.
b
===
this
.
b
);
},
clone
:
function
()
{
return
new
THREE
.
Color
().
setRGB
(
this
.
r
,
this
.
g
,
this
.
b
);
...
...
test/unit/math/ColorConverter.js
0 → 100644
浏览文件 @
e5d3ea7b
module
(
"
ColorConverter
"
);
test
(
"
fromRGB
"
,
function
(){
var
c1
=
new
THREE
.
Color
();
var
c2
=
new
THREE
.
Color
().
setRGB
(
0
,
0.5
,
1
);
THREE
.
ColorConverter
.
fromRGB
(
c1
,
0
,
0.5
,
1
);
ok
(
c1
.
equals
(
c2
),
"
Ok
"
);
});
test
(
"
fromHex/toHex
"
,
function
(){
var
c1
=
new
THREE
.
Color
();
var
c2
=
new
THREE
.
Color
().
setHex
(
0x11aaff
);
THREE
.
ColorConverter
.
fromHex
(
c1
,
0x11aaff
);
ok
(
c1
.
equals
(
c2
),
"
Ok
"
);
var
hex
=
THREE
.
ColorConverter
.
toHex
(
c1
);
ok
(
hex
===
0x11aaff
,
"
Ok
"
);
});
test
(
"
fromHSV/toHSV
"
,
function
(){
var
c1
=
new
THREE
.
Color
();
var
c2
=
new
THREE
.
Color
().
setHSL
(
0.25
,
0.5
,
0.75
);
var
hsv
=
THREE
.
ColorConverter
.
toHSV
(
c2
);
THREE
.
ColorConverter
.
fromHSV
(
c1
,
hsv
.
h
,
hsv
.
s
,
hsv
.
v
);
ok
(
c1
.
equals
(
c2
),
"
Ok
"
);
});
test
(
"
fromHSL/toHSL
"
,
function
(){
var
c1
=
new
THREE
.
Color
();
var
c2
=
new
THREE
.
Color
().
setHSL
(
0.25
,
0.5
,
0.75
);
var
hsl
=
THREE
.
ColorConverter
.
toHSL
(
c2
);
THREE
.
ColorConverter
.
fromHSL
(
c1
,
hsl
.
h
,
hsl
.
s
,
hsl
.
l
);
ok
(
c1
.
equals
(
c2
),
"
Ok
"
);
});
test/unit/math/Line3.js
浏览文件 @
e5d3ea7b
...
...
@@ -55,7 +55,6 @@ test( "closestPointToPoint/closestPointToPointParameter", function() {
// nearby the ray
ok
(
a
.
closestPointToPointParameter
(
zero3
.
clone
(),
false
)
==
-
1
,
"
Passed!
"
);
var
b2
=
a
.
closestPointToPoint
(
zero3
.
clone
(),
false
);
console
.
log
(
b2
);
ok
(
b2
.
distanceTo
(
new
THREE
.
Vector3
(
1
,
1
,
0
)
)
<
0.0001
,
"
Passed!
"
);
// nearby the ray
...
...
test/unit/unittests_sources.html
浏览文件 @
e5d3ea7b
...
...
@@ -28,6 +28,7 @@
<script
src=
"../../src/math/Sphere.js"
></script>
<script
src=
"../../src/math/Math.js"
></script>
<script
src=
"../../src/math/Triangle.js"
></script>
<script
src=
"../../examples/js/math/ColorConverter.js"
></script>
<!-- add class-based unit tests below -->
...
...
@@ -47,6 +48,7 @@
<script
src=
"math/Matrix4.js"
></script>
<script
src=
"math/Frustum.js"
></script>
<script
src=
"math/Color.js"
></script>
<script
src=
"math/ColorConverter.js"
></script>
</body>
</html>
test/unit/unittests_three-math.html
浏览文件 @
e5d3ea7b
...
...
@@ -12,6 +12,7 @@
<!-- add ThreeJS sources to test below -->
<script
src=
"../../build/three-math.js"
></script>
<script
src=
"../../examples/js/math/ColorConverter.js"
></script>
<!-- add class-based unit tests below -->
...
...
@@ -30,6 +31,7 @@
<script
src=
"math/Matrix3.js"
></script>
<script
src=
"math/Matrix4.js"
></script>
<script
src=
"math/Frustum.js"
></script>
<script
src=
"math/ColorConverter.js"
></script>
</body>
</html>
test/unit/unittests_three.html
浏览文件 @
e5d3ea7b
...
...
@@ -12,6 +12,7 @@
<!-- add ThreeJS sources to test below -->
<script
src=
"../../build/three.js"
></script>
<script
src=
"../../examples/js/math/ColorConverter.js"
></script>
<!-- add class-based unit tests below -->
...
...
@@ -30,6 +31,7 @@
<script
src=
"math/Matrix3.js"
></script>
<script
src=
"math/Matrix4.js"
></script>
<script
src=
"math/Frustum.js"
></script>
<script
src=
"math/ColorConverter.js"
></script>
</body>
</html>
test/unit/unittests_three.min.html
浏览文件 @
e5d3ea7b
...
...
@@ -12,6 +12,7 @@
<!-- add ThreeJS sources to test below -->
<script
src=
"../../build/three.min.js"
></script>
<script
src=
"../../examples/js/math/ColorConverter.js"
></script>
<!-- add class-based unit tests below -->
...
...
@@ -30,6 +31,7 @@
<script
src=
"math/Matrix3.js"
></script>
<script
src=
"math/Matrix4.js"
></script>
<script
src=
"math/Frustum.js"
></script>
<script
src=
"math/ColorConverter.js"
></script>
</body>
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录