Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
f2faf11a
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,发现更多精彩内容 >>
提交
f2faf11a
编写于
9月 02, 2012
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removed unnneeded color clamping.
上级
fbb5f5b7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
47 addition
and
52 deletion
+47
-52
examples/js/renderers/SVGRenderer.js
examples/js/renderers/SVGRenderer.js
+6
-6
src/core/Color.js
src/core/Color.js
+2
-2
src/renderers/CanvasRenderer.js
src/renderers/CanvasRenderer.js
+39
-44
未找到文件。
examples/js/renderers/SVGRenderer.js
浏览文件 @
f2faf11a
...
@@ -359,9 +359,9 @@ THREE.SVGRenderer = function () {
...
@@ -359,9 +359,9 @@ THREE.SVGRenderer = function () {
calculateLight
(
_lights
,
element
.
centroidWorld
,
element
.
normalWorld
,
_color
);
calculateLight
(
_lights
,
element
.
centroidWorld
,
element
.
normalWorld
,
_color
);
_color
.
r
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
r
*
_color
.
r
+
emissive
.
r
,
1
)
)
;
_color
.
r
=
diffuse
.
r
*
_color
.
r
+
emissive
.
r
;
_color
.
g
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
g
*
_color
.
g
+
emissive
.
g
,
1
)
)
;
_color
.
g
=
diffuse
.
g
*
_color
.
g
+
emissive
.
g
;
_color
.
b
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
b
*
_color
.
b
+
emissive
.
b
,
1
)
)
;
_color
.
b
=
diffuse
.
b
*
_color
.
b
+
emissive
.
b
;
}
else
{
}
else
{
...
@@ -419,9 +419,9 @@ THREE.SVGRenderer = function () {
...
@@ -419,9 +419,9 @@ THREE.SVGRenderer = function () {
calculateLight
(
_lights
,
element
.
centroidWorld
,
element
.
normalWorld
,
_color
);
calculateLight
(
_lights
,
element
.
centroidWorld
,
element
.
normalWorld
,
_color
);
_color
.
r
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
r
*
_color
.
r
+
emissive
.
r
,
1
)
)
;
_color
.
r
=
diffuse
.
r
*
_color
.
r
+
emissive
.
r
;
_color
.
g
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
g
*
_color
.
g
+
emissive
.
g
,
1
)
)
;
_color
.
g
=
diffuse
.
g
*
_color
.
g
+
emissive
.
g
;
_color
.
b
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
b
*
_color
.
b
+
emissive
.
b
,
1
)
)
;
_color
.
b
=
diffuse
.
b
*
_color
.
b
+
emissive
.
b
;
}
else
{
}
else
{
...
...
src/core/Color.js
浏览文件 @
f2faf11a
...
@@ -165,13 +165,13 @@ THREE.Color.prototype = {
...
@@ -165,13 +165,13 @@ THREE.Color.prototype = {
getHex
:
function
()
{
getHex
:
function
()
{
return
Math
.
floor
(
this
.
r
*
255
)
<<
16
^
Math
.
floor
(
this
.
g
*
255
)
<<
8
^
Math
.
floor
(
this
.
b
*
255
)
;
return
(
this
.
r
*
255
)
<<
16
^
(
this
.
g
*
255
)
<<
8
^
(
this
.
b
*
255
)
<<
0
;
},
},
getContextStyle
:
function
()
{
getContextStyle
:
function
()
{
return
'
rgb(
'
+
Math
.
floor
(
this
.
r
*
255
)
+
'
,
'
+
Math
.
floor
(
this
.
g
*
255
)
+
'
,
'
+
Math
.
floor
(
this
.
b
*
255
)
+
'
)
'
;
return
'
rgb(
'
+
(
(
this
.
r
*
255
)
|
0
)
+
'
,
'
+
(
(
this
.
g
*
255
)
|
0
)
+
'
,
'
+
(
(
this
.
b
*
255
)
|
0
)
+
'
)
'
;
},
},
...
...
src/renderers/CanvasRenderer.js
浏览文件 @
f2faf11a
...
@@ -576,17 +576,17 @@ THREE.CanvasRenderer = function ( parameters ) {
...
@@ -576,17 +576,17 @@ THREE.CanvasRenderer = function ( parameters ) {
calculateLight
(
element
.
v2
.
positionWorld
,
element
.
vertexNormalsWorld
[
1
],
_color2
);
calculateLight
(
element
.
v2
.
positionWorld
,
element
.
vertexNormalsWorld
[
1
],
_color2
);
calculateLight
(
element
.
v3
.
positionWorld
,
element
.
vertexNormalsWorld
[
2
],
_color3
);
calculateLight
(
element
.
v3
.
positionWorld
,
element
.
vertexNormalsWorld
[
2
],
_color3
);
_color1
.
r
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
r
*
_color1
.
r
+
emissive
.
r
,
1
)
)
;
_color1
.
r
=
diffuse
.
r
*
_color1
.
r
+
emissive
.
r
;
_color1
.
g
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
g
*
_color1
.
g
+
emissive
.
g
,
1
)
)
;
_color1
.
g
=
diffuse
.
g
*
_color1
.
g
+
emissive
.
g
;
_color1
.
b
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
b
*
_color1
.
b
+
emissive
.
b
,
1
)
)
;
_color1
.
b
=
diffuse
.
b
*
_color1
.
b
+
emissive
.
b
;
_color2
.
r
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
r
*
_color2
.
r
+
emissive
.
r
,
1
)
)
;
_color2
.
r
=
diffuse
.
r
*
_color2
.
r
+
emissive
.
r
;
_color2
.
g
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
g
*
_color2
.
g
+
emissive
.
g
,
1
)
)
;
_color2
.
g
=
diffuse
.
g
*
_color2
.
g
+
emissive
.
g
;
_color2
.
b
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
b
*
_color2
.
b
+
emissive
.
b
,
1
)
)
;
_color2
.
b
=
diffuse
.
b
*
_color2
.
b
+
emissive
.
b
;
_color3
.
r
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
r
*
_color3
.
r
+
emissive
.
r
,
1
)
)
;
_color3
.
r
=
diffuse
.
r
*
_color3
.
r
+
emissive
.
r
;
_color3
.
g
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
g
*
_color3
.
g
+
emissive
.
g
,
1
)
)
;
_color3
.
g
=
diffuse
.
g
*
_color3
.
g
+
emissive
.
g
;
_color3
.
b
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
b
*
_color3
.
b
+
emissive
.
b
,
1
)
)
;
_color3
.
b
=
diffuse
.
b
*
_color3
.
b
+
emissive
.
b
;
_color4
.
r
=
(
_color2
.
r
+
_color3
.
r
)
*
0.5
;
_color4
.
r
=
(
_color2
.
r
+
_color3
.
r
)
*
0.5
;
_color4
.
g
=
(
_color2
.
g
+
_color3
.
g
)
*
0.5
;
_color4
.
g
=
(
_color2
.
g
+
_color3
.
g
)
*
0.5
;
...
@@ -604,9 +604,9 @@ THREE.CanvasRenderer = function ( parameters ) {
...
@@ -604,9 +604,9 @@ THREE.CanvasRenderer = function ( parameters ) {
calculateLight
(
element
.
centroidWorld
,
element
.
normalWorld
,
_color
);
calculateLight
(
element
.
centroidWorld
,
element
.
normalWorld
,
_color
);
_color
.
r
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
r
*
_color
.
r
+
emissive
.
r
,
1
)
)
;
_color
.
r
=
diffuse
.
r
*
_color
.
r
+
emissive
.
r
;
_color
.
g
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
g
*
_color
.
g
+
emissive
.
g
,
1
)
)
;
_color
.
g
=
diffuse
.
g
*
_color
.
g
+
emissive
.
g
;
_color
.
b
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
b
*
_color
.
b
+
emissive
.
b
,
1
)
)
;
_color
.
b
=
diffuse
.
b
*
_color
.
b
+
emissive
.
b
;
material
.
wireframe
===
true
?
strokePath
(
_color
,
material
.
wireframeLinewidth
,
material
.
wireframeLinecap
,
material
.
wireframeLinejoin
)
:
fillPath
(
_color
);
material
.
wireframe
===
true
?
strokePath
(
_color
,
material
.
wireframeLinewidth
,
material
.
wireframeLinecap
,
material
.
wireframeLinejoin
)
:
fillPath
(
_color
);
...
@@ -736,21 +736,21 @@ THREE.CanvasRenderer = function ( parameters ) {
...
@@ -736,21 +736,21 @@ THREE.CanvasRenderer = function ( parameters ) {
calculateLight
(
element
.
v4
.
positionWorld
,
element
.
vertexNormalsWorld
[
3
],
_color3
);
calculateLight
(
element
.
v4
.
positionWorld
,
element
.
vertexNormalsWorld
[
3
],
_color3
);
calculateLight
(
element
.
v3
.
positionWorld
,
element
.
vertexNormalsWorld
[
2
],
_color4
);
calculateLight
(
element
.
v3
.
positionWorld
,
element
.
vertexNormalsWorld
[
2
],
_color4
);
_color1
.
r
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
r
*
_color1
.
r
+
emissive
.
r
,
1
)
)
;
_color1
.
r
=
diffuse
.
r
*
_color1
.
r
+
emissive
.
r
;
_color1
.
g
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
g
*
_color1
.
g
+
emissive
.
g
,
1
)
)
;
_color1
.
g
=
diffuse
.
g
*
_color1
.
g
+
emissive
.
g
;
_color1
.
b
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
b
*
_color1
.
b
+
emissive
.
b
,
1
)
)
;
_color1
.
b
=
diffuse
.
b
*
_color1
.
b
+
emissive
.
b
;
_color2
.
r
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
r
*
_color2
.
r
+
emissive
.
r
,
1
)
)
;
_color2
.
r
=
diffuse
.
r
*
_color2
.
r
+
emissive
.
r
;
_color2
.
g
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
g
*
_color2
.
g
+
emissive
.
g
,
1
)
)
;
_color2
.
g
=
diffuse
.
g
*
_color2
.
g
+
emissive
.
g
;
_color2
.
b
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
b
*
_color2
.
b
+
emissive
.
b
,
1
)
)
;
_color2
.
b
=
diffuse
.
b
*
_color2
.
b
+
emissive
.
b
;
_color3
.
r
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
r
*
_color3
.
r
+
emissive
.
r
,
1
)
)
;
_color3
.
r
=
diffuse
.
r
*
_color3
.
r
+
emissive
.
r
;
_color3
.
g
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
g
*
_color3
.
g
+
emissive
.
g
,
1
)
)
;
_color3
.
g
=
diffuse
.
g
*
_color3
.
g
+
emissive
.
g
;
_color3
.
b
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
b
*
_color3
.
b
+
emissive
.
b
,
1
)
)
;
_color3
.
b
=
diffuse
.
b
*
_color3
.
b
+
emissive
.
b
;
_color4
.
r
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
r
*
_color4
.
r
+
emissive
.
r
,
1
)
)
;
_color4
.
r
=
diffuse
.
r
*
_color4
.
r
+
emissive
.
r
;
_color4
.
g
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
g
*
_color4
.
g
+
emissive
.
g
,
1
)
)
;
_color4
.
g
=
diffuse
.
g
*
_color4
.
g
+
emissive
.
g
;
_color4
.
b
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
b
*
_color4
.
b
+
emissive
.
b
,
1
)
)
;
_color4
.
b
=
diffuse
.
b
*
_color4
.
b
+
emissive
.
b
;
_image
=
getGradientTexture
(
_color1
,
_color2
,
_color3
,
_color4
);
_image
=
getGradientTexture
(
_color1
,
_color2
,
_color3
,
_color4
);
...
@@ -770,9 +770,9 @@ THREE.CanvasRenderer = function ( parameters ) {
...
@@ -770,9 +770,9 @@ THREE.CanvasRenderer = function ( parameters ) {
calculateLight
(
element
.
centroidWorld
,
element
.
normalWorld
,
_color
);
calculateLight
(
element
.
centroidWorld
,
element
.
normalWorld
,
_color
);
_color
.
r
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
r
*
_color
.
r
+
emissive
.
r
,
1
)
)
;
_color
.
r
=
diffuse
.
r
*
_color
.
r
+
emissive
.
r
;
_color
.
g
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
g
*
_color
.
g
+
emissive
.
g
,
1
)
)
;
_color
.
g
=
diffuse
.
g
*
_color
.
g
+
emissive
.
g
;
_color
.
b
=
Math
.
max
(
0
,
Math
.
min
(
diffuse
.
b
*
_color
.
b
+
emissive
.
b
,
1
)
)
;
_color
.
b
=
diffuse
.
b
*
_color
.
b
+
emissive
.
b
;
drawQuad
(
_v1x
,
_v1y
,
_v2x
,
_v2y
,
_v3x
,
_v3y
,
_v4x
,
_v4y
);
drawQuad
(
_v1x
,
_v1y
,
_v2x
,
_v2y
,
_v3x
,
_v3y
,
_v4x
,
_v4y
);
...
@@ -1005,26 +1005,21 @@ THREE.CanvasRenderer = function ( parameters ) {
...
@@ -1005,26 +1005,21 @@ THREE.CanvasRenderer = function ( parameters ) {
// http://mrdoob.com/blog/post/710
// http://mrdoob.com/blog/post/710
var
c1r
=
(
color1
.
r
*
255
)
|
0
,
c1g
=
(
color1
.
g
*
255
)
|
0
,
c1b
=
(
color1
.
b
*
255
)
|
0
;
_pixelMapData
[
0
]
=
(
color1
.
r
*
255
)
|
0
;
var
c2r
=
(
color2
.
r
*
255
)
|
0
,
c2g
=
(
color2
.
g
*
255
)
|
0
,
c2b
=
(
color2
.
b
*
255
)
|
0
;
_pixelMapData
[
1
]
=
(
color1
.
g
*
255
)
|
0
;
var
c3r
=
(
color3
.
r
*
255
)
|
0
,
c3g
=
(
color3
.
g
*
255
)
|
0
,
c3b
=
(
color3
.
b
*
255
)
|
0
;
_pixelMapData
[
2
]
=
(
color1
.
b
*
255
)
|
0
;
var
c4r
=
(
color4
.
r
*
255
)
|
0
,
c4g
=
(
color4
.
g
*
255
)
|
0
,
c4b
=
(
color4
.
b
*
255
)
|
0
;
_pixelMapData
[
0
]
=
c1r
<
0
?
0
:
c1r
>
255
?
255
:
c1r
;
_pixelMapData
[
4
]
=
(
color2
.
r
*
255
)
|
0
;
_pixelMapData
[
1
]
=
c1g
<
0
?
0
:
c1g
>
255
?
255
:
c1g
;
_pixelMapData
[
5
]
=
(
color2
.
g
*
255
)
|
0
;
_pixelMapData
[
2
]
=
c1b
<
0
?
0
:
c1b
>
255
?
255
:
c1b
;
_pixelMapData
[
6
]
=
(
color2
.
b
*
255
)
|
0
;
_pixelMapData
[
4
]
=
c2r
<
0
?
0
:
c2r
>
255
?
255
:
c2r
;
_pixelMapData
[
8
]
=
(
color3
.
r
*
255
)
|
0
;
_pixelMapData
[
5
]
=
c2g
<
0
?
0
:
c2g
>
255
?
255
:
c2g
;
_pixelMapData
[
9
]
=
(
color3
.
g
*
255
)
|
0
;
_pixelMapData
[
6
]
=
c2b
<
0
?
0
:
c2b
>
255
?
255
:
c2b
;
_pixelMapData
[
10
]
=
(
color3
.
b
*
255
)
|
0
;
_pixelMapData
[
8
]
=
c3r
<
0
?
0
:
c3r
>
255
?
255
:
c3r
;
_pixelMapData
[
12
]
=
(
color4
.
r
*
255
)
|
0
;
_pixelMapData
[
9
]
=
c3g
<
0
?
0
:
c3g
>
255
?
255
:
c3g
;
_pixelMapData
[
13
]
=
(
color4
.
g
*
255
)
|
0
;
_pixelMapData
[
10
]
=
c3b
<
0
?
0
:
c3b
>
255
?
255
:
c3b
;
_pixelMapData
[
14
]
=
(
color4
.
b
*
255
)
|
0
;
_pixelMapData
[
12
]
=
c4r
<
0
?
0
:
c4r
>
255
?
255
:
c4r
;
_pixelMapData
[
13
]
=
c4g
<
0
?
0
:
c4g
>
255
?
255
:
c4g
;
_pixelMapData
[
14
]
=
c4b
<
0
?
0
:
c4b
>
255
?
255
:
c4b
;
_pixelMapContext
.
putImageData
(
_pixelMapImage
,
0
,
0
);
_pixelMapContext
.
putImageData
(
_pixelMapImage
,
0
,
0
);
_gradientMapContext
.
drawImage
(
_pixelMap
,
0
,
0
);
_gradientMapContext
.
drawImage
(
_pixelMap
,
0
,
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录