Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
ebaa3ae3
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,发现更多精彩内容 >>
提交
ebaa3ae3
编写于
12月 27, 2010
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
I knew it wasn't going to work.
上级
7e1321d0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
30 deletion
+44
-30
examples/materials_normalmap2.html
examples/materials_normalmap2.html
+37
-20
src/core/Geometry.js
src/core/Geometry.js
+7
-10
未找到文件。
examples/materials_normalmap2.html
浏览文件 @
ebaa3ae3
...
...
@@ -105,6 +105,8 @@
var
windowHalfX
=
window
.
innerWidth
/
2
;
var
windowHalfY
=
window
.
innerHeight
/
2
;
var
r
=
0.0
;
document
.
addEventListener
(
'
mousemove
'
,
onDocumentMouseMove
,
false
);
init
();
...
...
@@ -122,55 +124,65 @@
// LIGHTS
ambientLight
=
new
THREE
.
AmbientLight
(
0x
444444
);
ambientLight
=
new
THREE
.
AmbientLight
(
0x
050505
);
scene
.
addLight
(
ambientLight
);
pointLight
=
new
THREE
.
PointLight
(
0xffffff
);
pointLight
.
position
.
z
=
600
;
pointLight
=
new
THREE
.
PointLight
(
0x999999
);
pointLight
.
position
.
z
=
10000
;
scene
.
addLight
(
pointLight
);
directionalLight
=
new
THREE
.
DirectionalLight
(
0x
ffffff
);
directionalLight
.
position
.
x
=
1
;
directionalLight
.
position
.
y
=
1
;
directionalLight
.
position
.
z
=
-
1
;
directionalLight
=
new
THREE
.
DirectionalLight
(
0x
bbbbbb
);
directionalLight
.
position
.
x
=
0
;
directionalLight
.
position
.
y
=
0
;
directionalLight
.
position
.
z
=
1
;
directionalLight
.
position
.
normalize
();
scene
.
addLight
(
directionalLight
);
//
material parameters
//
light representation
var
ambient
=
0x444444
,
diffuse
=
0x555555
,
specular
=
0x181820
,
shininess
=
2
;
var
sphere
=
new
Sphere
(
100
,
16
,
8
);
lightMesh
=
new
THREE
.
Mesh
(
sphere
,
new
THREE
.
MeshBasicMaterial
(
{
color
:
0xffaa00
}
)
);
lightMesh
.
position
=
pointLight
.
position
;
lightMesh
.
scale
.
x
=
lightMesh
.
scale
.
y
=
lightMesh
.
scale
.
z
=
0.05
;
scene
.
addObject
(
lightMesh
);
// material parameters
var
ambient
=
0x020202
,
diffuse
=
0x666666
,
specular
=
0x444444
,
shininess
=
2
;
var
fragment_shader
=
ShaderUtils
.
lib
[
"
normal
"
].
fragment_shader
;
var
vertex_shader
=
ShaderUtils
.
lib
[
"
normal
"
].
vertex_shader
;
var
uniforms
=
ShaderUtils
.
lib
[
"
normal
"
].
uniforms
;
uniforms
[
"
tNormal
"
].
texture
=
ImageUtils
.
loadTexture
(
"
obj/leeperrysmith/Infinite-Level_02_Tangent_SmoothUV.jpg
"
);
uniforms
[
"
uNormalScale
"
].
value
=
-
0.75
;
uniforms
[
"
tDiffuse
"
].
texture
=
ImageUtils
.
loadTexture
(
"
obj/leeperrysmith/Map-COL.jpg
"
);
uniforms
[
"
enableAO
"
].
value
=
false
;
uniforms
[
"
enableDiffuse
"
].
value
=
true
;
uniforms
[
"
uPointLightPos
"
].
value
=
pointLight
.
position
;
uniforms
[
"
uPointLightColor
"
].
value
=
pointLight
.
color
;
uniforms
[
"
uDirLightPos
"
].
value
=
directionalLight
.
position
;
uniforms
[
"
uDirLightColor
"
].
value
=
directionalLight
.
color
;
uniforms
[
"
uAmbientLightColor
"
].
value
=
ambientLight
.
color
;
uniforms
[
"
uDiffuseColor
"
].
value
.
setHex
(
diffuse
);
uniforms
[
"
uSpecularColor
"
].
value
.
setHex
(
specular
);
uniforms
[
"
uAmbientColor
"
].
value
.
setHex
(
ambient
);
uniforms
[
"
uShininess
"
].
value
=
shininess
;
var
material
=
new
THREE
.
MeshShaderMaterial
(
{
fragment_shader
:
fragment_shader
,
vertex_shader
:
vertex_shader
,
uniforms
:
uniforms
}
);
vertex_shader
:
vertex_shader
,
uniforms
:
uniforms
}
);
//var material = new THREE.MeshLambertMaterial( { map: ImageUtils.loadTexture( "obj/leeperrysmith/Map-COL.jpg" ) } );
//var material = new THREE.MeshPhongMaterial( { color: diffuse, specular: specular, ambient: ambient, shininess: shininess, map: ImageUtils.loadTexture( "obj/leeperrysmith/Map-COL.jpg" ) } );
loader
=
new
THREE
.
Loader
(
true
);
document
.
body
.
appendChild
(
loader
.
statusDomElement
);
...
...
@@ -221,6 +233,11 @@
}
lightMesh
.
position
.
x
=
500
*
Math
.
cos
(
r
);
lightMesh
.
position
.
z
=
500
*
Math
.
sin
(
r
);
r
+=
0.01
;
webglRenderer
.
render
(
scene
,
camera
);
if
(
statsEnabled
)
stats
.
update
();
...
...
src/core/Geometry.js
浏览文件 @
ebaa3ae3
...
...
@@ -192,15 +192,15 @@ THREE.Geometry.prototype = {
}
function
handleTriangle
(
context
,
a
,
b
,
c
)
{
function
handleTriangle
(
context
,
a
,
b
,
c
,
ua
,
ub
,
uc
)
{
vA
=
context
.
vertices
[
a
].
position
;
vB
=
context
.
vertices
[
b
].
position
;
vC
=
context
.
vertices
[
c
].
position
;
uvA
=
uv
[
0
];
uvB
=
uv
[
1
];
uvC
=
uv
[
2
];
uvA
=
uv
[
ua
];
uvB
=
uv
[
ub
];
uvC
=
uv
[
uc
];
x1
=
vB
.
x
-
vA
.
x
;
x2
=
vC
.
x
-
vA
.
x
;
...
...
@@ -239,7 +239,7 @@ THREE.Geometry.prototype = {
if
(
face
instanceof
THREE
.
Face3
)
{
handleTriangle
(
this
,
face
.
a
,
face
.
b
,
face
.
c
);
handleTriangle
(
this
,
face
.
a
,
face
.
b
,
face
.
c
,
0
,
1
,
2
);
this
.
vertices
[
face
.
a
].
normal
.
copy
(
face
.
vertexNormals
[
0
]
);
this
.
vertices
[
face
.
b
].
normal
.
copy
(
face
.
vertexNormals
[
1
]
);
...
...
@@ -248,11 +248,8 @@ THREE.Geometry.prototype = {
}
else
if
(
face
instanceof
THREE
.
Face4
)
{
handleTriangle
(
this
,
face
.
a
,
face
.
b
,
face
.
c
);
// this messes up everything
// quads need to be handled differently
//handleTriangle( this, face.a, face.c, face.d );
handleTriangle
(
this
,
face
.
a
,
face
.
b
,
face
.
c
,
0
,
1
,
2
);
handleTriangle
(
this
,
face
.
a
,
face
.
b
,
face
.
d
,
0
,
1
,
3
);
this
.
vertices
[
face
.
a
].
normal
.
copy
(
face
.
vertexNormals
[
0
]
);
this
.
vertices
[
face
.
b
].
normal
.
copy
(
face
.
vertexNormals
[
1
]
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录