Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
8c5bc528
T
three.js
项目概览
车家大少爷
/
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,发现更多精彩内容 >>
提交
8c5bc528
编写于
10月 10, 2015
作者:
B
Ben Houston
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cleaner and more GC efficient.
上级
7985c8b0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
77 addition
and
53 deletion
+77
-53
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+77
-53
未找到文件。
src/renderers/WebGLRenderer.js
浏览文件 @
8c5bc528
...
@@ -2422,7 +2422,7 @@ THREE.WebGLRenderer = function ( parameters ) {
...
@@ -2422,7 +2422,7 @@ THREE.WebGLRenderer = function ( parameters ) {
var
l
,
ll
,
light
,
var
l
,
ll
,
light
,
r
=
0
,
g
=
0
,
b
=
0
,
r
=
0
,
g
=
0
,
b
=
0
,
color
,
skyColor
,
groundColor
,
color
,
intensity
,
intensity
,
distance
,
distance
,
...
@@ -2430,17 +2430,10 @@ THREE.WebGLRenderer = function ( parameters ) {
...
@@ -2430,17 +2430,10 @@ THREE.WebGLRenderer = function ( parameters ) {
viewMatrix
=
camera
.
matrixWorldInverse
,
viewMatrix
=
camera
.
matrixWorldInverse
,
function
adjustArray
(
array
,
newLength
)
{
zlights
.
directional
=
[];
if
(
array
.
length
!==
newLength
)
{
zlights
.
point
=
[];
return
Array
(
newLength
);
zlights
.
spot
=
[];
}
zlights
.
hemi
=
[];
return
array
;
}
var
directionalLights
=
adjustArray
(
zlights
.
directional
);
var
pointLights
=
adjustArray
(
zlights
.
point
);
var
spotLights
=
adjustArray
(
zlights
.
spot
);
var
hemisphereLights
=
adjustArray
(
zlights
.
hemi
);
for
(
l
=
0
,
ll
=
lights
.
length
;
l
<
ll
;
l
++
)
{
for
(
l
=
0
,
ll
=
lights
.
length
;
l
<
ll
;
l
++
)
{
...
@@ -2462,10 +2455,18 @@ THREE.WebGLRenderer = function ( parameters ) {
...
@@ -2462,10 +2455,18 @@ THREE.WebGLRenderer = function ( parameters ) {
}
else
if
(
light
instanceof
THREE
.
DirectionalLight
)
{
}
else
if
(
light
instanceof
THREE
.
DirectionalLight
)
{
var
directionalLight
=
directionalLights
[
i
];
if
(
!
light
.
__webglUniforms
)
{
light
.
__webglUniforms
=
{
position
:
new
THREE
.
Vector3
(),
color
:
new
THREE
.
Color
(),
distance
:
0
}
}
var
lightUniforms
=
directionalLights
[
i
]
=
light
.
__webglUniforms
;
if
(
!
light
.
visible
)
{
if
(
!
light
.
visible
)
{
directionlLight
.
color
=
new
THREE
.
Color
(
0x00000
0
);
lightUniforms
.
color
.
setRGB
(
0
,
0
,
0
);
continue
;
continue
;
}
}
...
@@ -2474,77 +2475,100 @@ THREE.WebGLRenderer = function ( parameters ) {
...
@@ -2474,77 +2475,100 @@ THREE.WebGLRenderer = function ( parameters ) {
_direction
.
sub
(
_vector3
);
_direction
.
sub
(
_vector3
);
_direction
.
transformDirection
(
viewMatrix
);
_direction
.
transformDirection
(
viewMatrix
);
directionlLight
.
position
=
_direction
.
clone
(
);
lightUniforms
.
position
.
copy
(
_direction
);
directionlLight
.
color
=
color
.
clone
(
).
multiplyScalar
(
intensity
);
lightUniforms
.
color
.
copy
(
color
).
multiplyScalar
(
intensity
);
directionlLight
.
distance
=
distance
;
lightUniforms
.
distance
=
distance
;
}
else
if
(
light
instanceof
THREE
.
PointLight
)
{
}
else
if
(
light
instanceof
THREE
.
PointLight
)
{
if
(
!
light
.
visible
)
continue
;
if
(
!
light
.
__webglUniforms
)
{
light
.
__webglUniforms
=
{
position
:
new
THREE
.
Vector3
(),
color
:
new
THREE
.
Color
(),
distance
:
0
,
decay
:
0
}
}
var
lightUniforms
=
pointLights
[
i
]
=
light
.
__webglUniforms
;
if
(
!
light
.
visible
)
{
lightUniforms
.
color
.
setRGB
(
0
,
0
,
0
);
continue
;
}
_vector3
.
setFromMatrixPosition
(
light
.
matrixWorld
);
_vector3
.
setFromMatrixPosition
(
light
.
matrixWorld
);
_vector3
.
applyMatrix4
(
viewMatrix
);
_vector3
.
applyMatrix4
(
viewMatrix
);
var
pointLight
=
pointLights
[
i
];
lightUniforms
.
position
.
copy
(
_vector3
);
lightUniforms
.
color
.
copy
(
color
).
multiplyScalar
(
intensity
);
pointLight
.
position
=
_vector3
.
clone
();
lightUniforms
.
distance
=
distance
;
pointLight
.
color
=
color
.
clone
().
multiplyScalar
(
intensity
);
lightUniforms
.
decay
=
(
light
.
distance
===
0
)
?
0.0
:
light
.
decay
;
pointLight
.
distance
=
distance
;
pointLight
.
decay
=
(
light
.
distance
===
0
)
?
0.0
:
light
.
decay
;
}
else
if
(
light
instanceof
THREE
.
SpotLight
)
{
}
else
if
(
light
instanceof
THREE
.
SpotLight
)
{
if
(
!
light
.
visible
)
continue
;
if
(
!
light
.
__webglUniforms
)
{
light
.
__webglUniforms
=
{
position
:
new
THREE
.
Vector3
(),
direction
:
new
THREE
.
Vector3
(),
color
:
new
THREE
.
Color
(),
distance
:
0
,
decay
:
0
,
angleCos
:
0
}
}
var
lightUniforms
=
spotLights
[
i
]
=
light
.
__webglUniforms
;
var
spotLight
=
spotLights
[
i
];
if
(
!
light
.
visible
)
{
lightUniforms
.
color
.
setRGB
(
0
,
0
,
0
);
continue
;
}
_direction
.
setFromMatrixPosition
(
light
.
matrixWorld
);
_direction
.
setFromMatrixPosition
(
light
.
matrixWorld
);
_vector3
.
copy
(
_direction
).
applyMatrix4
(
viewMatrix
);
_vector3
.
copy
(
_direction
).
applyMatrix4
(
viewMatrix
);
spotLight
.
position
=
_vector3
.
clone
(
);
lightUniforms
.
position
.
copy
(
_vector3
);
spotLight
.
color
=
color
.
clone
(
).
multiplyScalar
(
intensity
);
lightUniforms
.
color
.
copy
(
color
).
multiplyScalar
(
intensity
);
spotLight
.
distance
=
distance
;
lightUniforms
.
distance
=
distance
;
_vector3
.
setFromMatrixPosition
(
light
.
target
.
matrixWorld
);
_vector3
.
setFromMatrixPosition
(
light
.
target
.
matrixWorld
);
_direction
.
sub
(
_vector3
);
_direction
.
sub
(
_vector3
);
_direction
.
transformDirection
(
viewMatrix
);
_direction
.
transformDirection
(
viewMatrix
);
spotLight
.
direction
=
_direction
.
clone
(
);
lightUniforms
.
direction
.
copy
(
_direction
);
spotLight
.
angleCos
=
Math
.
cos
(
light
.
angle
);
lightUniforms
.
angleCos
=
Math
.
cos
(
light
.
angle
);
spotLight
.
exponent
=
light
.
exponent
;
lightUniforms
.
exponent
=
light
.
exponent
;
spotLight
.
decay
=
(
light
.
distance
===
0
)
?
0.0
:
light
.
decay
;
lightUniforms
.
decay
=
(
light
.
distance
===
0
)
?
0.0
:
light
.
decay
;
}
else
if
(
light
instanceof
THREE
.
HemisphereLight
)
{
}
else
if
(
light
instanceof
THREE
.
HemisphereLight
)
{
if
(
!
light
.
visible
)
continue
;
if
(
!
light
.
__webglUniforms
)
{
light
.
__webglUniforms
=
{
position
:
new
THREE
.
Vector3
(),
skyColor
:
new
THREE
.
Color
(),
groundColor
:
new
THREE
.
Color
()
}
}
var
lightUniforms
=
hemisphereLights
[
i
]
=
light
.
__webglUniforms
;
if
(
!
light
.
visible
)
{
lightUniforms
.
skyColor
.
setRGB
(
0
,
0
,
0
);
continue
;
}
_direction
.
setFromMatrixPosition
(
light
.
matrixWorld
);
_direction
.
setFromMatrixPosition
(
light
.
matrixWorld
);
_direction
.
transformDirection
(
viewMatrix
);
_direction
.
transformDirection
(
viewMatrix
);
var
hemisphereLight
=
hemisphereLights
[
i
];
lightUniforms
.
position
.
copy
(
_direction
);
lightUniforms
.
skyColor
.
copy
(
light
.
color
).
multiplyScalar
(
intensity
);
spotLight
.
position
=
_direction
.
clone
();
lightUniforms
.
groundColor
.
copy
(
groundColor
).
multiplyScalar
(
intensity
);
spotLight
.
skyColor
=
light
.
color
.
clone
().
multiplyScalar
(
intensity
);
spotLight
.
groundColor
=
light
.
groundColor
.
clone
().
multiplyScalar
(
intensity
);
}
}
}
}
// null eventual remains from removed lights
// (this is to avoid if in shader)
for
(
l
=
dirLength
*
3
,
ll
=
Math
.
max
(
dirColors
.
length
,
dirCount
*
3
);
l
<
ll
;
l
++
)
dirColors
[
l
]
=
0.0
;
for
(
l
=
pointLength
*
3
,
ll
=
Math
.
max
(
pointColors
.
length
,
pointCount
*
3
);
l
<
ll
;
l
++
)
pointColors
[
l
]
=
0.0
;
for
(
l
=
spotLength
*
3
,
ll
=
Math
.
max
(
spotColors
.
length
,
spotCount
*
3
);
l
<
ll
;
l
++
)
spotColors
[
l
]
=
0.0
;
for
(
l
=
hemiLength
*
3
,
ll
=
Math
.
max
(
hemiSkyColors
.
length
,
hemiCount
*
3
);
l
<
ll
;
l
++
)
hemiSkyColors
[
l
]
=
0.0
;
for
(
l
=
hemiLength
*
3
,
ll
=
Math
.
max
(
hemiGroundColors
.
length
,
hemiCount
*
3
);
l
<
ll
;
l
++
)
hemiGroundColors
[
l
]
=
0.0
;
zlights
.
directional
.
length
=
dirLength
;
zlights
.
point
.
length
=
pointLength
;
zlights
.
spot
.
length
=
spotLength
;
zlights
.
hemi
.
length
=
hemiLength
;
zlights
.
ambient
[
0
]
=
r
;
zlights
.
ambient
[
0
]
=
r
;
zlights
.
ambient
[
1
]
=
g
;
zlights
.
ambient
[
1
]
=
g
;
zlights
.
ambient
[
2
]
=
b
;
zlights
.
ambient
[
2
]
=
b
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录