Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
4901440e
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,发现更多精彩内容 >>
提交
4901440e
编写于
11月 19, 2010
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merging alteredq's branch
上级
d961ee52
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
364 addition
and
231 deletion
+364
-231
build/Three.js
build/Three.js
+88
-87
build/ThreeDebug.js
build/ThreeDebug.js
+89
-88
examples/lights_pointlights_gl.html
examples/lights_pointlights_gl.html
+10
-2
examples/materials_cubemap.html
examples/materials_cubemap.html
+3
-2
examples/materials_cubemap_escher.html
examples/materials_cubemap_escher.html
+1
-1
examples/materials_gl.html
examples/materials_gl.html
+25
-15
examples/materials_multimaterials.html
examples/materials_multimaterials.html
+3
-3
examples/obj_convert_test.html
examples/obj_convert_test.html
+3
-3
src/materials/MeshBasicMaterial.js
src/materials/MeshBasicMaterial.js
+16
-0
src/materials/MeshLambertMaterial.js
src/materials/MeshLambertMaterial.js
+16
-0
src/materials/MeshPhongMaterial.js
src/materials/MeshPhongMaterial.js
+29
-9
src/materials/textures/Texture.js
src/materials/textures/Texture.js
+3
-0
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+78
-21
未找到文件。
build/Three.js
浏览文件 @
4901440e
此差异已折叠。
点击以展开。
build/ThreeDebug.js
浏览文件 @
4901440e
此差异已折叠。
点击以展开。
examples/lights_pointlights_gl.html
浏览文件 @
4901440e
...
...
@@ -28,10 +28,14 @@
a
:hover
{
color
:
#0080ff
;
}
#log
{
color
:
#fff
;
position
:
absolute
;
top
:
50px
;
text-align
:
left
;
display
:
block
;
z-index
:
100
;
pointer-events
:
none
;
}
</style>
</head>
<body>
<pre
id=
"log"
></pre>
<div
id=
"container"
></div>
<div
id=
"info"
>
<a
href=
"http://github.com/mrdoob/three.js"
target=
"_blank"
>
three.js
</a>
- point lights WebGL demo.
<br
/>
...
...
@@ -124,7 +128,7 @@
scene
.
addObject
(
l3
);
//renderer = new THREE.CanvasRenderer();
renderer
=
new
THREE
.
WebGLRenderer
(
);
renderer
=
new
THREE
.
WebGLRenderer
(
scene
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
container
.
appendChild
(
renderer
.
domElement
);
...
...
@@ -162,7 +166,11 @@
}
function
log
()
{
function
log
(
text
)
{
var
e
=
document
.
getElementById
(
"
log
"
);
e
.
innerHTML
=
text
+
"
<br/>
"
+
e
.
innerHTML
;
}
</script>
...
...
examples/materials_cubemap.html
浏览文件 @
4901440e
...
...
@@ -17,7 +17,7 @@
a
:hover
{
color
:
#0080ff
;
}
canvas
{
pointer-events
:
none
;
z-index
:
10
;
position
:
relative
;
}
#log
{
position
:
absolute
;
top
:
50px
;
text-align
:
left
;
display
:
block
;
z-index
:
100
}
#log
{
position
:
absolute
;
top
:
50px
;
text-align
:
left
;
display
:
block
;
z-index
:
100
;
pointer-events
:
none
;
}
#d
{
text-align
:
center
;
margin
:
1em
0
-7.5em
0
;
z-index
:
1000
;
position
:
relative
;
display
:
block
}
.button
{
background
:
orange
;
color
:
#fff
;
padding
:
0.2em
0.5em
;
cursor
:
pointer
}
.inactive
{
background
:
#999
;
color
:
#eee
}
...
...
@@ -103,7 +103,8 @@
var
images
=
loadImageArray
(
urls
);
var
cubeMaterial3
=
new
THREE
.
MeshLambertMaterial
(
{
color
:
0xffaa00
,
env_map
:
new
THREE
.
TextureCube
(
images
)
}
);
//var cubeMaterial3 = new THREE.MeshPhongMaterial( { color: 0x000000, specular:0xaa0000, env_map: new THREE.TextureCube( images ), combine: THREE.Mix, reflectivity: 0.25 } );
var
cubeMaterial3
=
new
THREE
.
MeshLambertMaterial
(
{
color
:
0xff6600
,
env_map
:
new
THREE
.
TextureCube
(
images
),
combine
:
THREE
.
Mix
,
reflectivity
:
0.3
}
);
var
cubeMaterial2
=
new
THREE
.
MeshLambertMaterial
(
{
color
:
0xffee00
,
env_map
:
new
THREE
.
TextureCube
(
images
)
}
);
var
cubeMaterial1
=
new
THREE
.
MeshLambertMaterial
(
{
color
:
0xffffff
,
env_map
:
new
THREE
.
TextureCube
(
images
)
}
)
...
...
examples/materials_cubemap_escher.html
浏览文件 @
4901440e
...
...
@@ -16,7 +16,7 @@
a
{
color
:
#ff0080
;
text-decoration
:
none
;
}
a
:hover
{
color
:
#0080ff
;
}
#log
{
position
:
absolute
;
top
:
50px
;
text-align
:
left
;
display
:
block
;
z-index
:
100
}
#log
{
position
:
absolute
;
top
:
50px
;
text-align
:
left
;
display
:
block
;
z-index
:
100
;
pointer-events
:
none
;
}
#d
{
text-align
:
center
;
margin
:
1em
auto
-9.0em
;
z-index
:
1000
;
position
:
relative
;
display
:
block
;
background
:
rgba
(
0
,
0
,
0
,
0.75
);
padding
:
0.25em
;
width
:
300px
;
border-radius
:
10px
;
-webkit-box-shadow
:
0px
0px
10px
rgba
(
0
,
0
,
0
,
0.5
)
}
</style>
...
...
examples/materials_gl.html
浏览文件 @
4901440e
...
...
@@ -10,10 +10,13 @@
margin
:
0px
;
overflow
:
hidden
;
}
#log
{
color
:
#fff
;
position
:
absolute
;
top
:
50px
;
text-align
:
left
;
display
:
block
;
z-index
:
100
;
pointer-events
:
none
;
}
</style>
</head>
<body>
<pre
id=
"log"
></pre>
<script
type=
"text/javascript"
src=
"../build/Three.js"
></script>
<script
type=
"text/javascript"
src=
"../src/extras/primitives/Sphere.js"
></script>
...
...
@@ -77,19 +80,19 @@
materials
.
push
(
{
material
:
new
THREE
.
MeshBasicMaterial
(
{
color
:
0x665500
,
blending
:
THREE
.
AdditiveBlending
}
),
overdraw
:
false
,
doubleSided
:
true
}
);
//materials.push( { material: new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.SubtractiveBlending } ), overdraw: false, doubleSided: true } );
materials
.
push
(
{
material
:
new
THREE
.
MeshLambertMaterial
(
{
color
:
0xdddddd
,
shading
:
THREE
.
SmoothShading
}
),
overdraw
:
true
,
doubleSided
:
false
}
);
materials
.
push
(
{
material
:
new
THREE
.
MeshLambertMaterial
(
{
color
:
0xdddddd
,
shading
:
THREE
.
SmoothShading
}
),
overdraw
:
true
,
doubleSided
:
false
}
);
materials
.
push
(
{
material
:
new
THREE
.
MeshPhongMaterial
(
{
ambient
:
0x030303
,
color
:
0xdddddd
,
specular
:
0x009900
,
shininess
:
30
,
shading
:
THREE
.
SmoothShading
}
),
overdraw
:
true
,
doubleSided
:
false
}
);
materials
.
push
(
{
material
:
new
THREE
.
MeshNormalMaterial
(
{
shading
:
THREE
.
SmoothShading
}
),
overdraw
:
true
,
doubleSided
:
false
}
);
materials
.
push
(
{
material
:
new
THREE
.
MeshBasicMaterial
(
{
color
:
0xffaa00
,
wireframe
:
true
}
),
overdraw
:
false
,
doubleSided
:
true
}
);
materials
.
push
(
{
material
:
new
THREE
.
MeshBasicMaterial
(
{
color
:
0xffaa00
,
wireframe
:
true
}
),
overdraw
:
false
,
doubleSided
:
true
}
);
materials
.
push
(
{
material
:
new
THREE
.
MeshDepthMaterial
(
{
near
:
1
,
far
:
2000
}
),
overdraw
:
true
,
doubleSided
:
false
}
);
materials
.
push
(
{
material
:
new
THREE
.
MeshBasicMaterial
(
{
map
:
generatedTexture
}
),
overdraw
:
true
,
doubleSided
:
false
}
);
materials
.
push
(
{
material
:
new
THREE
.
MeshLambertMaterial
(
{
map
:
generatedTexture
}
),
overdraw
:
true
,
doubleSided
:
false
}
);
materials
.
push
(
{
material
:
new
THREE
.
MeshLambertMaterial
(
{
map
:
generatedTexture
}
),
overdraw
:
true
,
doubleSided
:
false
}
);
// Extra mesh to be broken down for MeshFaceMaterial
var
geometry2
=
new
Sphere
(
70
,
32
,
16
,
true
);
// Extra mesh to be broken down for MeshFaceMaterial
var
geometry2
=
new
Sphere
(
70
,
32
,
16
,
true
);
for
(
var
i
=
0
,
l
=
geometry2
.
faces
.
length
;
i
<
l
;
i
++
)
{
var
face
=
geometry2
.
faces
[
i
];
...
...
@@ -101,14 +104,14 @@
objects
=
[];
var
sphere
,
geometry
;
var
sphere
,
geometry
;
for
(
var
i
=
0
,
l
=
materials
.
length
;
i
<
l
;
i
++
)
{
geometry
=
materials
[
i
].
material
instanceof
THREE
.
MeshFaceMaterial
?
geometry2
:
geometry1
;
sphere
=
new
THREE
.
Mesh
(
geometry
,
materials
[
i
].
material
);
geometry
=
materials
[
i
].
material
instanceof
THREE
.
MeshFaceMaterial
?
geometry2
:
geometry1
;
sphere
=
new
THREE
.
Mesh
(
geometry
,
materials
[
i
].
material
);
sphere
.
overdraw
=
materials
[
i
].
overdraw
;
sphere
.
doubleSided
=
materials
[
i
].
doubleSided
;
...
...
@@ -142,7 +145,7 @@
pointLight
=
new
THREE
.
PointLight
(
0xffffff
,
1
);
scene
.
addLight
(
pointLight
);
renderer
=
new
THREE
.
WebGLRenderer
();
renderer
=
new
THREE
.
WebGLRenderer
(
scene
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
container
.
appendChild
(
renderer
.
domElement
);
...
...
@@ -224,6 +227,13 @@
stats
.
update
();
}
function
log
(
text
)
{
var
e
=
document
.
getElementById
(
"
log
"
);
e
.
innerHTML
=
text
+
"
<br/>
"
+
e
.
innerHTML
;
}
</script>
...
...
examples/materials_multimaterials.html
浏览文件 @
4901440e
...
...
@@ -15,7 +15,7 @@
h1
{
}
a
{
color
:
skyblue
}
canvas
{
pointer-events
:
none
;
z-index
:
10
;
position
:
relative
;
}
#log
{
position
:
absolute
;
top
:
50px
;
text-align
:
left
;
display
:
block
;
z-index
:
1
00
}
#log
{
position
:
absolute
;
top
:
50px
;
text-align
:
left
;
display
:
block
;
z-index
:
1
;
pointer-events
:
none
;
}
#d
{
text-align
:
center
;
margin
:
1em
0
-15.7em
0
;
z-index
:
0
;
position
:
relative
;
display
:
block
}
.button
{
background
:
#000
;
color
:
#fff
;
padding
:
0.2em
0.5em
;
cursor
:
pointer
}
.inactive
{
background
:
#999
;
color
:
#eee
}
...
...
@@ -40,7 +40,7 @@
</div>
<
div
id=
"log"
></div
>
<
pre
id=
"log"
></pre
>
<script
type=
"text/javascript"
src=
"../build/Three.js"
></script>
...
...
@@ -153,7 +153,7 @@
if
(
render_gl
)
{
try
{
webglRenderer
=
new
THREE
.
WebGLRenderer
();
webglRenderer
=
new
THREE
.
WebGLRenderer
(
scene
);
webglRenderer
.
setSize
(
SCREEN_WIDTH
,
SCREEN_HEIGHT
);
container
.
appendChild
(
webglRenderer
.
domElement
);
has_gl
=
1
;
...
...
examples/obj_convert_test.html
浏览文件 @
4901440e
...
...
@@ -15,7 +15,7 @@
h1
{
}
a
{
color
:
skyblue
}
canvas
{
pointer-events
:
none
;
z-index
:
10
;
position
:
relative
;
}
#log
{
position
:
absolute
;
top
:
0
;
display
:
block
;
text-align
:
left
;
z-index
:
1000
}
#log
{
position
:
absolute
;
top
:
0
;
display
:
block
;
text-align
:
left
;
z-index
:
1000
;
pointer-events
:
none
;
}
#d
{
text-align
:
center
;
margin
:
1em
0
-15.7em
0
;
z-index
:
0
;
position
:
relative
;
display
:
block
}
.button
{
background
:
#000
;
color
:
#fff
;
padding
:
0.2em
0.5em
;
cursor
:
pointer
}
.inactive
{
background
:
#999
;
color
:
#eee
}
...
...
@@ -170,7 +170,7 @@
if
(
render_gl
)
{
try
{
webglRenderer
=
new
THREE
.
WebGLRenderer
();
webglRenderer
=
new
THREE
.
WebGLRenderer
(
scene
);
webglRenderer
.
setFaceCulling
(
0
);
webglRenderer
.
setSize
(
SCREEN_WIDTH
,
SCREEN_HEIGHT
);
container
.
appendChild
(
webglRenderer
.
domElement
);
...
...
@@ -283,7 +283,7 @@
}
function
log
(
text
)
{
function
log
(
text
)
{
var
e
=
document
.
getElementById
(
"
log
"
);
e
.
innerHTML
=
text
+
"
<br/>
"
+
e
.
innerHTML
;
...
...
src/materials/MeshBasicMaterial.js
浏览文件 @
4901440e
...
...
@@ -5,8 +5,12 @@
* parameters = {
* color: <hex>,
* map: new THREE.Texture( <Image> ),
* env_map: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ),
* combine: THREE.Multiply,
* reflectivity: <float>,
* refraction_ratio: <float>,
* opacity: <float>,
* shading: THREE.SmoothShading,
* blending: THREE.NormalBlending,
...
...
@@ -21,8 +25,12 @@ THREE.MeshBasicMaterial = function ( parameters ) {
this
.
color
=
new
THREE
.
Color
(
0xeeeeee
);
this
.
map
=
null
;
this
.
env_map
=
null
;
this
.
combine
=
THREE
.
Multiply
;
this
.
reflectivity
=
1
;
this
.
refraction_ratio
=
0.98
;
this
.
opacity
=
1
;
this
.
shading
=
THREE
.
SmoothShading
;
this
.
blending
=
THREE
.
NormalBlending
;
...
...
@@ -33,8 +41,12 @@ THREE.MeshBasicMaterial = function ( parameters ) {
if
(
parameters
.
color
!==
undefined
)
this
.
color
.
setHex
(
parameters
.
color
);
if
(
parameters
.
map
!==
undefined
)
this
.
map
=
parameters
.
map
;
if
(
parameters
.
env_map
!==
undefined
)
this
.
env_map
=
parameters
.
env_map
;
if
(
parameters
.
combine
!==
undefined
)
this
.
combine
=
parameters
.
combine
;
if
(
parameters
.
reflectivity
!==
undefined
)
this
.
reflectivity
=
parameters
.
reflectivity
;
if
(
parameters
.
refraction_ratio
!==
undefined
)
this
.
refraction_ratio
=
parameters
.
refraction_ratio
;
if
(
parameters
.
opacity
!==
undefined
)
this
.
opacity
=
parameters
.
opacity
;
if
(
parameters
.
shading
!==
undefined
)
this
.
shading
=
parameters
.
shading
;
if
(
parameters
.
blending
!==
undefined
)
this
.
blending
=
parameters
.
blending
;
...
...
@@ -49,8 +61,12 @@ THREE.MeshBasicMaterial = function ( parameters ) {
'
id:
'
+
this
.
id
+
'
<br/>
'
+
'
color:
'
+
this
.
color
+
'
<br/>
'
+
'
map:
'
+
this
.
map
+
'
<br/>
'
+
'
env_map:
'
+
this
.
env_map
+
'
<br/>
'
+
'
combine:
'
+
this
.
combine
+
'
<br/>
'
+
'
reflectivity:
'
+
this
.
reflectivity
+
'
<br/>
'
+
'
refraction_ratio:
'
+
this
.
refraction_ratio
+
'
<br/>
'
+
'
opacity:
'
+
this
.
opacity
+
'
<br/>
'
+
'
blending:
'
+
this
.
blending
+
'
<br/>
'
+
'
wireframe:
'
+
this
.
wireframe
+
'
<br/>
'
+
...
...
src/materials/MeshLambertMaterial.js
浏览文件 @
4901440e
...
...
@@ -5,8 +5,12 @@
* parameters = {
* color: <hex>,
* map: new THREE.Texture( <Image> ),
* env_map: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ),
* combine: THREE.Multiply,
* reflectivity: <float>,
* refraction_ratio: <float>,
* opacity: <float>,
* shading: THREE.SmoothShading,
* blending: THREE.NormalBlending,
...
...
@@ -21,8 +25,12 @@ THREE.MeshLambertMaterial = function ( parameters ) {
this
.
color
=
new
THREE
.
Color
(
0xeeeeee
);
this
.
map
=
null
;
this
.
env_map
=
null
;
this
.
combine
=
THREE
.
Multiply
;
this
.
reflectivity
=
1
;
this
.
refraction_ratio
=
0.98
;
this
.
opacity
=
1
;
this
.
shading
=
THREE
.
SmoothShading
;
this
.
blending
=
THREE
.
NormalBlending
;
...
...
@@ -33,8 +41,12 @@ THREE.MeshLambertMaterial = function ( parameters ) {
if
(
parameters
.
color
!==
undefined
)
this
.
color
.
setHex
(
parameters
.
color
);
if
(
parameters
.
map
!==
undefined
)
this
.
map
=
parameters
.
map
;
if
(
parameters
.
env_map
!==
undefined
)
this
.
env_map
=
parameters
.
env_map
;
if
(
parameters
.
combine
!==
undefined
)
this
.
combine
=
parameters
.
combine
;
if
(
parameters
.
reflectivity
!==
undefined
)
this
.
reflectivity
=
parameters
.
reflectivity
;
if
(
parameters
.
refraction_ratio
!==
undefined
)
this
.
refraction_ratio
=
parameters
.
refraction_ratio
;
if
(
parameters
.
opacity
!==
undefined
)
this
.
opacity
=
parameters
.
opacity
;
if
(
parameters
.
shading
!==
undefined
)
this
.
shading
=
parameters
.
shading
;
if
(
parameters
.
blending
!==
undefined
)
this
.
blending
=
parameters
.
blending
;
...
...
@@ -49,8 +61,12 @@ THREE.MeshLambertMaterial = function ( parameters ) {
'
id:
'
+
this
.
id
+
'
<br/>
'
+
'
color:
'
+
this
.
color
+
'
<br/>
'
+
'
map:
'
+
this
.
map
+
'
<br/>
'
+
'
env_map:
'
+
this
.
env_map
+
'
<br/>
'
+
'
combine:
'
+
this
.
combine
+
'
<br/>
'
+
'
reflectivity:
'
+
this
.
reflectivity
+
'
<br/>
'
+
'
refraction_ratio:
'
+
this
.
refraction_ratio
+
'
<br/>
'
+
'
opacity:
'
+
this
.
opacity
+
'
<br/>
'
+
'
shading:
'
+
this
.
shading
+
'
<br/>
'
+
'
blending:
'
+
this
.
blending
+
'
<br/>
'
+
...
...
src/materials/MeshPhongMaterial.js
浏览文件 @
4901440e
...
...
@@ -3,14 +3,19 @@
* @author alteredq / http://alteredqualia.com/
*
* parameters = {
* ambient: <hex>,
* color: <hex>,
* ambient: <hex>,
* specular: <hex>,
* shininess: <float>,
* map: new THREE.Texture( <Image> ),
* specular_map: new THREE.Texture( <Image> ),
* env_map: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ),
*
shininess: <float>
,
*
combine: THREE.Multiply
,
* reflectivity: <float>,
* refraction_ratio: <float>,
* opacity: <float>,
* shading: THREE.SmoothShading,
* blending: THREE.NormalBlending,
...
...
@@ -24,13 +29,18 @@ THREE.MeshPhongMaterial = function ( parameters ) {
this
.
id
=
THREE
.
MeshPhongMaterialCounter
.
value
++
;
this
.
color
=
new
THREE
.
Color
(
0xeeeeee
);
this
.
map
=
null
;
this
.
ambient
=
new
THREE
.
Color
(
0x050505
);
this
.
specular
=
new
THREE
.
Color
(
0x111111
);
this
.
shininess
=
30
;
this
.
map
=
null
;
this
.
specular_map
=
null
;
this
.
env_map
=
null
;
this
.
shininess
=
30
;
this
.
combine
=
THREE
.
Multiply
;
this
.
reflectivity
=
1
;
this
.
refraction_ratio
=
0.98
;
this
.
opacity
=
1
;
this
.
shading
=
THREE
.
SmoothShading
;
this
.
blending
=
THREE
.
NormalBlending
;
...
...
@@ -40,13 +50,18 @@ THREE.MeshPhongMaterial = function ( parameters ) {
if
(
parameters
)
{
if
(
parameters
.
color
!==
undefined
)
this
.
color
=
new
THREE
.
Color
(
parameters
.
color
);
if
(
parameters
.
map
!==
undefined
)
this
.
map
=
parameters
.
map
;
if
(
parameters
.
ambient
!==
undefined
)
this
.
ambient
=
new
THREE
.
Color
(
parameters
.
ambient
);
if
(
parameters
.
specular
!==
undefined
)
this
.
specular
=
new
THREE
.
Color
(
parameters
.
specular
);
if
(
parameters
.
shininess
!==
undefined
)
this
.
shininess
=
parameters
.
shininess
;
if
(
parameters
.
map
!==
undefined
)
this
.
map
=
parameters
.
map
;
if
(
parameters
.
specular_map
!==
undefined
)
this
.
specular_map
=
parameters
.
specular_map
;
if
(
parameters
.
env_map
!==
undefined
)
this
.
env_map
=
parameters
.
env_map
;
if
(
parameters
.
shininess
!==
undefined
)
this
.
shininess
=
parameters
.
shininess
;
if
(
parameters
.
combine
!==
undefined
)
this
.
combine
=
parameters
.
combine
;
if
(
parameters
.
reflectivity
!==
undefined
)
this
.
reflectivity
=
parameters
.
reflectivity
;
if
(
parameters
.
refraction_ratio
!==
undefined
)
this
.
refraction_ratio
=
parameters
.
refraction_ratio
;
if
(
parameters
.
opacity
!==
undefined
)
this
.
opacity
=
parameters
.
opacity
;
if
(
parameters
.
shading
!==
undefined
)
this
.
shading
=
parameters
.
shading
;
if
(
parameters
.
blending
!==
undefined
)
this
.
blending
=
parameters
.
blending
;
...
...
@@ -60,13 +75,18 @@ THREE.MeshPhongMaterial = function ( parameters ) {
return
'
THREE.MeshPhongMaterial (<br/>
'
+
'
id:
'
+
this
.
id
+
'
<br/>
'
+
'
color:
'
+
this
.
color
+
'
<br/>
'
+
'
map:
'
+
this
.
map
+
'
<br/>
'
+
'
env_map:
'
+
this
.
env_map
+
'
<br/>
'
+
'
ambient:
'
+
this
.
ambient
+
'
<br/>
'
+
'
specular:
'
+
this
.
specular
+
'
<br/>
'
+
'
specular_map:
'
+
this
.
specular_map
+
'
<br/>
'
+
'
shininess:
'
+
this
.
shininess
+
'
<br/>
'
+
'
map:
'
+
this
.
map
+
'
<br/>
'
+
'
specular_map:
'
+
this
.
specular_map
+
'
<br/>
'
+
'
env_map:
'
+
this
.
env_map
+
'
<br/>
'
+
'
combine:
'
+
this
.
combine
+
'
<br/>
'
+
'
reflectivity:
'
+
this
.
reflectivity
+
'
<br/>
'
+
'
refraction_ratio:
'
+
this
.
refraction_ratio
+
'
<br/>
'
+
'
opacity:
'
+
this
.
opacity
+
'
<br/>
'
+
'
shading:
'
+
this
.
shading
+
'
<br/>
'
+
'
wireframe:
'
+
this
.
wireframe
+
'
<br/>
'
+
...
...
src/materials/textures/Texture.js
浏览文件 @
4901440e
...
...
@@ -22,3 +22,6 @@ THREE.Texture = function ( image, mapping ) {
THREE
.
UVMapping
=
0
;
THREE
.
ReflectionMap
=
1
;
THREE
.
RefractionMap
=
2
;
THREE
.
Multiply
=
0
;
THREE
.
Mix
=
1
;
src/renderers/WebGLRenderer.js
浏览文件 @
4901440e
...
...
@@ -20,7 +20,7 @@ THREE.WebGLRenderer = function ( scene ) {
BASIC
=
0
,
LAMBERT
=
1
,
PHONG
=
2
,
DEPTH
=
3
,
NORMAL
=
4
,
// material constants used in shader
maxLightCount
=
allocateLights
(
scene
,
5
);
maxLightCount
=
allocateLights
(
scene
,
4
);
this
.
domElement
=
_canvas
;
this
.
autoClear
=
true
;
...
...
@@ -382,7 +382,8 @@ THREE.WebGLRenderer = function ( scene ) {
var
mColor
,
mOpacity
,
mReflectivity
,
mWireframe
,
mLineWidth
,
mBlending
,
mAmbient
,
mSpecular
,
mShininess
,
mMap
,
envMap
;
mMap
,
envMap
,
mixEnvMap
,
mRefractionRatio
,
useRefract
;
if
(
material
instanceof
THREE
.
MeshPhongMaterial
||
material
instanceof
THREE
.
MeshLambertMaterial
||
...
...
@@ -390,7 +391,6 @@ THREE.WebGLRenderer = function ( scene ) {
mColor
=
material
.
color
;
mOpacity
=
material
.
opacity
;
mReflectivity
=
material
.
reflectivity
;
mWireframe
=
material
.
wireframe
;
mLineWidth
=
material
.
wireframe_linewidth
;
...
...
@@ -399,9 +399,21 @@ THREE.WebGLRenderer = function ( scene ) {
mMap
=
material
.
map
;
envMap
=
material
.
env_map
;
mixEnvMap
=
material
.
combine
==
THREE
.
Mix
;
mReflectivity
=
material
.
reflectivity
;
useRefract
=
material
.
env_map
&&
material
.
env_map
.
mapping
==
THREE
.
RefractionMap
;
mRefractionRatio
=
material
.
refraction_ratio
;
_gl
.
uniform4f
(
_program
.
mColor
,
mColor
.
r
*
mOpacity
,
mColor
.
g
*
mOpacity
,
mColor
.
b
*
mOpacity
,
mOpacity
);
_gl
.
uniform1i
(
_program
.
mixEnvMap
,
mixEnvMap
);
_gl
.
uniform1f
(
_program
.
mReflectivity
,
mReflectivity
);
_gl
.
uniform1i
(
_program
.
useRefract
,
useRefract
);
_gl
.
uniform1f
(
_program
.
mRefractionRatio
,
mRefractionRatio
);
}
if
(
material
instanceof
THREE
.
MeshNormalMaterial
)
{
...
...
@@ -824,6 +836,7 @@ THREE.WebGLRenderer = function ( scene ) {
"
uniform bool enableMap;
"
,
"
uniform bool enableCubeMap;
"
,
"
uniform bool mixEnvMap;
"
,
"
uniform samplerCube tCube;
"
,
"
uniform float mReflectivity;
"
,
...
...
@@ -874,7 +887,7 @@ THREE.WebGLRenderer = function ( scene ) {
"
if ( enableCubeMap ) {
"
,
"
cubeColor =
mReflectivity *
textureCube( tCube, vReflect );
"
,
"
cubeColor = textureCube( tCube, vReflect );
"
,
"
}
"
,
...
...
@@ -909,7 +922,7 @@ THREE.WebGLRenderer = function ( scene ) {
maxPointLights
?
"
vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
maxPointLights
?
"
vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
maxPointLights
?
"
for( int i = 0; i <
pointLightNumber
; i++ ) {
"
:
""
,
maxPointLights
?
"
for( int i = 0; i <
MAX_POINT_LIGHTS
; i++ ) {
"
:
""
,
maxPointLights
?
"
vec3 pointVector = normalize( vPointLightVector[ i ] );
"
:
""
,
maxPointLights
?
"
vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );
"
:
""
,
...
...
@@ -942,7 +955,7 @@ THREE.WebGLRenderer = function ( scene ) {
maxDirLights
?
"
vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
maxDirLights
?
"
vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
maxDirLights
?
"
for( int i = 0; i <
directionalLightNumber
; i++ ) {
"
:
""
,
maxDirLights
?
"
for( int i = 0; i <
MAX_DIR_LIGHTS
; i++ ) {
"
:
""
,
maxDirLights
?
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
:
""
,
...
...
@@ -970,19 +983,43 @@ THREE.WebGLRenderer = function ( scene ) {
// looks nicer with weighting
"
gl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );
"
,
"
if ( mixEnvMap ) {
"
,
"
gl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );
"
,
"
} else {
"
,
"
gl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );
"
,
"
}
"
,
// Lambert: diffuse lighting
"
} else if ( material == 1 ) {
"
,
"
gl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );
"
,
"
if ( mixEnvMap ) {
"
,
"
gl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );
"
,
"
} else {
"
,
"
gl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );
"
,
"
}
"
,
// Basic: unlit color / texture
"
} else {
"
,
"
gl_FragColor = mColor * mapColor * cubeColor;
"
,
"
if ( mixEnvMap ) {
"
,
"
gl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );
"
,
"
} else {
"
,
"
gl_FragColor = mColor * mapColor * cubeColor;
"
,
"
}
"
,
"
}
"
,
...
...
@@ -1006,6 +1043,7 @@ THREE.WebGLRenderer = function ( scene ) {
"
uniform vec3 cameraPosition;
"
,
"
uniform bool enableLighting;
"
,
"
uniform bool useRefract;
"
,
"
uniform int pointLightNumber;
"
,
"
uniform int directionalLightNumber;
"
,
...
...
@@ -1034,6 +1072,7 @@ THREE.WebGLRenderer = function ( scene ) {
"
varying vec3 vViewPosition;
"
,
"
varying vec3 vReflect;
"
,
"
uniform float mRefractionRatio;
"
,
"
void main(void) {
"
,
...
...
@@ -1061,7 +1100,7 @@ THREE.WebGLRenderer = function ( scene ) {
// directional lights
maxDirLights
?
"
for( int i = 0; i <
directionalLightNumber
; i++ ) {
"
:
""
,
maxDirLights
?
"
for( int i = 0; i <
MAX_DIR_LIGHTS
; i++ ) {
"
:
""
,
maxDirLights
?
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
:
""
,
maxDirLights
?
"
float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );
"
:
""
,
maxDirLights
?
"
vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;
"
:
""
,
...
...
@@ -1069,7 +1108,7 @@ THREE.WebGLRenderer = function ( scene ) {
// point lights
maxPointLights
?
"
for( int i = 0; i <
pointLightNumber
; i++ ) {
"
:
""
,
maxPointLights
?
"
for( int i = 0; i <
MAX_POINT_LIGHTS
; i++ ) {
"
:
""
,
maxPointLights
?
"
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
"
:
""
,
maxPointLights
?
"
vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );
"
:
""
,
maxPointLights
?
"
float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );
"
:
""
,
...
...
@@ -1081,8 +1120,16 @@ THREE.WebGLRenderer = function ( scene ) {
"
vNormal = transformedNormal;
"
,
"
vUv = uv;
"
,
"
vReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );
"
,
"
if ( useRefract ) {
"
,
"
vReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );
"
,
"
} else {
"
,
"
vReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );
"
,
"
}
"
,
"
gl_Position = projectionMatrix * mvPosition;
"
,
"
}
"
];
...
...
@@ -1107,8 +1154,8 @@ THREE.WebGLRenderer = function ( scene ) {
alert
(
"
Could not initialise shaders
"
);
//
alert( "VALIDATE_STATUS: " + _gl.getProgramParameter( _program, _gl.VALIDATE_STATUS ) );
//
alert( _gl.getError() );
alert
(
"
VALIDATE_STATUS:
"
+
_gl
.
getProgramParameter
(
_program
,
_gl
.
VALIDATE_STATUS
)
);
alert
(
_gl
.
getError
()
);
}
...
...
@@ -1165,19 +1212,29 @@ THREE.WebGLRenderer = function ( scene ) {
// texture (diffuse map)
_program
.
enableMap
=
_gl
.
getUniformLocation
(
_program
,
"
enableMap
"
);
_gl
.
uniform1i
(
_program
.
enableMap
,
0
);
_gl
.
uniform1i
(
_program
.
enableMap
,
0
);
_program
.
tMap
=
_gl
.
getUniformLocation
(
_program
,
"
tMap
"
);
_gl
.
uniform1i
(
_program
.
tMap
,
0
);
_gl
.
uniform1i
(
_program
.
tMap
,
0
);
// cube texture
_program
.
enableCubeMap
=
_gl
.
getUniformLocation
(
_program
,
"
enableCubeMap
"
);
_gl
.
uniform1i
(
_program
.
enableCubeMap
,
0
);
_gl
.
uniform1i
(
_program
.
enableCubeMap
,
0
);
_program
.
tCube
=
_gl
.
getUniformLocation
(
_program
,
"
tCube
"
);
_gl
.
uniform1i
(
_program
.
tCube
,
1
);
// it's important to use non-zero texture unit, otherwise it doesn't work
_gl
.
uniform1i
(
_program
.
tCube
,
1
);
// it's important to use non-zero texture unit, otherwise it doesn't work
_program
.
mixEnvMap
=
_gl
.
getUniformLocation
(
_program
,
"
mixEnvMap
"
);
_gl
.
uniform1i
(
_program
.
mixEnvMap
,
0
);
// refraction
_program
.
mRefractionRatio
=
_gl
.
getUniformLocation
(
_program
,
'
mRefractionRatio
'
);
_program
.
useRefract
=
_gl
.
getUniformLocation
(
_program
,
"
useRefract
"
);
_gl
.
uniform1i
(
_program
.
useRefract
,
0
);
// material properties (Depth)
_program
.
m2Near
=
_gl
.
getUniformLocation
(
_program
,
'
m2Near
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录