Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
ad73c981
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,体验更适合开发者的 AI 搜索 >>
提交
ad73c981
编写于
9月 09, 2010
作者:
N
Nicolas Garcia Belmonte
提交者:
Mr.doob
9月 09, 2010
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* Enable Scene light object management
* Add lighting code in the scene rendering loop
上级
d342239c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
53 addition
and
5 deletion
+53
-5
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+32
-3
src/scenes/Scene.js
src/scenes/Scene.js
+21
-2
未找到文件。
src/renderers/WebGLRenderer.js
浏览文件 @
ad73c981
...
...
@@ -30,9 +30,10 @@ THREE.WebGLRenderer = function () {
this
.
render
=
function
(
scene
,
camera
)
{
var
face
,
faceColor
,
object
,
material
,
normal
,
var
face
,
faceColor
,
object
,
material
,
normal
,
lightColor
,
lightDirection
,
light
,
vertexArray
,
faceArray
,
colorArray
,
normalArray
,
vertexIndex
,
o
,
ol
,
f
,
fl
,
m
,
ml
,
i
,
v1
,
v2
,
v3
,
v4
;
o
,
ol
,
f
,
fl
,
m
,
ml
,
i
,
v1
,
v2
,
v3
,
v4
,
l
,
ll
;
if
(
this
.
autoClear
)
{
...
...
@@ -40,7 +41,30 @@ THREE.WebGLRenderer = function () {
}
for
(
o
=
0
,
ol
=
scene
.
objects
.
length
;
o
<
ol
;
o
++
)
{
//lighting
_gl
.
uniform1i
(
_program
.
enableLighting
,
scene
.
lights
.
length
);
for
(
l
=
0
,
ll
=
scene
.
lights
.
length
;
l
<
ll
;
l
++
)
{
light
=
scene
.
lights
[
l
];
if
(
light
instanceof
THREE
.
AmbientLight
)
{
lightColor
=
light
.
color
;
_gl
.
uniform3f
(
_program
.
ambientColor
,
lightColor
.
r
,
lightColor
.
g
,
lightColor
.
b
);
}
else
if
(
light
instanceof
THREE
.
DirectionalLight
)
{
lightColor
=
light
.
color
;
lightDirection
=
light
.
direction
;
_gl
.
uniform3f
(
_program
.
lightingDirection
,
lightDirection
.
x
,
lightDirection
.
y
,
lightDirection
.
z
);
_gl
.
uniform3f
(
_program
.
directionalColor
,
lightColor
.
r
,
lightColor
.
g
,
lightColor
.
b
);
}
}
for
(
o
=
0
,
ol
=
scene
.
objects
.
length
;
o
<
ol
;
o
++
)
{
object
=
scene
.
objects
[
o
];
...
...
@@ -291,6 +315,11 @@ THREE.WebGLRenderer = function () {
_program
.
projectionMatrix
=
_gl
.
getUniformLocation
(
_program
,
"
projectionMatrix
"
);
_program
.
normalMatrix
=
_gl
.
getUniformLocation
(
_program
,
"
normalMatrix
"
);
_program
.
enableLighting
=
_gl
.
getUniformLocation
(
program
,
'
enableLighting
'
);
_program
.
ambientColor
=
_gl
.
getUniformLocation
(
program
,
'
ambientColor
'
);
_program
.
directionalColor
=
_gl
.
getUniformLocation
(
program
,
'
directionalColor
'
);
_program
.
lightingDirection
=
_gl
.
getUniformLocation
(
program
,
'
lightingDirection
'
);
_program
.
color
=
_gl
.
getAttribLocation
(
_program
,
"
color
"
);
_gl
.
enableVertexAttribArray
(
_program
.
color
);
...
...
src/scenes/Scene.js
浏览文件 @
ad73c981
...
...
@@ -5,7 +5,7 @@
THREE
.
Scene
=
function
()
{
this
.
objects
=
[];
//
this.lights = [];
this
.
lights
=
[];
this
.
addObject
=
function
(
object
)
{
...
...
@@ -24,7 +24,26 @@ THREE.Scene = function () {
}
}
}
};
this
.
addLight
=
function
(
light
)
{
this
.
lights
.
push
(
light
);
};
this
.
removeLight
=
function
(
light
)
{
for
(
var
i
=
0
,
l
=
this
.
lights
.
length
;
i
<
l
;
i
++
)
{
if
(
light
==
this
.
lights
[
i
]
)
{
this
.
lights
.
splice
(
i
,
1
);
return
;
}
}
};
// Deprecated
this
.
add
=
function
(
object
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录