Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
ab360240
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,发现更多精彩内容 >>
提交
ab360240
编写于
12月 31, 2010
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactored common uniforms out from basic / lambert / phong shaders into UniformsLib.
上级
ecad27eb
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
236 addition
and
239 deletion
+236
-239
build/Three.js
build/Three.js
+78
-80
build/ThreeDebug.js
build/ThreeDebug.js
+79
-81
build/ThreeExtras.js
build/ThreeExtras.js
+11
-13
src/materials/Uniforms.js
src/materials/Uniforms.js
+20
-0
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+48
-65
未找到文件。
build/Three.js
浏览文件 @
ab360240
此差异已折叠。
点击以展开。
build/ThreeDebug.js
浏览文件 @
ab360240
此差异已折叠。
点击以展开。
build/ThreeExtras.js
浏览文件 @
ab360240
...
...
@@ -91,8 +91,8 @@ THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.Particle
THREE
.
ParticleCircleMaterial
.
prototype
=
{
toString
:
function
(){
return
"
THREE.ParticleCircleMaterial (<br/>color:
"
+
this
.
color
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>)
"
}};
THREE
.
ParticleDOMMaterial
=
function
(
a
){
this
.
domElement
=
a
};
THREE
.
ParticleDOMMaterial
.
prototype
=
{
toString
:
function
(){
return
"
THREE.ParticleDOMMaterial ( domElement:
"
+
this
.
domElement
+
"
)
"
}};
THREE
.
Texture
=
function
(
a
,
c
,
f
,
e
,
i
,
k
){
this
.
image
=
a
;
this
.
mapping
=
c
!==
undefined
?
c
:
new
THREE
.
UVMapping
;
this
.
wrap_s
=
f
!==
undefined
?
f
:
THREE
.
ClampToEdgeWrapping
;
this
.
wrap_t
=
e
!==
undefined
?
e
:
THREE
.
ClampToEdgeWrapping
;
this
.
mag_filter
=
i
!==
undefined
?
i
:
THREE
.
LinearFilter
;
this
.
min_filter
=
k
!==
undefined
?
k
:
THREE
.
LinearMipMapLinearFilter
};
THREE
.
Texture
.
prototype
=
{
clone
:
function
(){
return
new
THREE
.
Texture
(
this
.
image
,
this
.
mapping
,
this
.
wrap_s
,
this
.
wrap_t
,
this
.
mag_filter
,
this
.
min_filter
)},
toString
:
function
(){
return
"
THREE.Texture (<br/>image:
"
+
this
.
image
+
"
<br/>wrap_s:
"
+
this
.
wrap_s
+
"
<br/>wrap_t:
"
+
this
.
wrap_t
+
"
<br/>mag_filter:
"
+
this
.
mag_filter
+
"
<br/>min_filter:
"
+
this
.
min_filter
+
"
<br/>)
"
}};
THREE
.
MultiplyOperation
=
0
;
THREE
.
MixOperation
=
1
;
THREE
.
RepeatWrapping
=
0
;
THREE
.
ClampToEdgeWrapping
=
1
;
THREE
.
MirroredRepeatWrapping
=
2
;
THREE
.
NearestFilter
=
3
;
THREE
.
NearestMipMapNearestFilter
=
4
;
THREE
.
NearestMipMapLinearFilter
=
5
;
THREE
.
LinearFilter
=
6
;
THREE
.
LinearMipMapNearestFilter
=
7
;
THREE
.
LinearMipMapLinearFilter
=
8
;
var
Uniforms
=
{
clone
:
function
(
a
){
var
c
,
f
,
e
,
i
=
{};
for
(
c
in
a
){
i
[
c
]
=
{};
for
(
f
in
a
[
c
]){
e
=
a
[
c
][
f
];
i
[
c
][
f
]
=
e
instanceof
THREE
.
Color
||
e
instanceof
THREE
.
Vector3
||
e
instanceof
THREE
.
Texture
?
e
.
clone
():
e
}}
return
i
}
};
THREE
.
CubeReflectionMapping
=
function
(){};
THREE
.
CubeRefractionMapping
=
function
(){};
THREE
.
LatitudeReflectionMapping
=
function
(){
};
THREE
.
LatitudeRefractionMapping
=
function
(){};
THREE
.
SphericalReflectionMapping
=
function
(){};
THREE
.
SphericalRefractionMapping
=
function
(){};
THREE
.
UVMapping
=
function
(){};
THREE
.
NearestFilter
=
3
;
THREE
.
NearestMipMapNearestFilter
=
4
;
THREE
.
NearestMipMapLinearFilter
=
5
;
THREE
.
LinearFilter
=
6
;
THREE
.
LinearMipMapNearestFilter
=
7
;
THREE
.
LinearMipMapLinearFilter
=
8
;
var
Uniforms
=
{
clone
:
function
(
a
){
var
c
,
f
,
e
,
i
=
{};
for
(
c
in
a
){
i
[
c
]
=
{};
for
(
f
in
a
[
c
]){
e
=
a
[
c
][
f
];
i
[
c
][
f
]
=
e
instanceof
THREE
.
Color
||
e
instanceof
THREE
.
Vector3
||
e
instanceof
THREE
.
Texture
?
e
.
clone
():
e
}}
return
i
}
,
merge
:
function
(
a
){
var
c
,
f
,
e
,
i
=
{};
for
(
c
=
0
;
c
<
a
.
length
;
c
++
){
e
=
this
.
clone
(
a
[
c
]);
for
(
f
in
e
)
i
[
f
]
=
e
[
f
]}
return
i
}
};
THREE
.
CubeReflectionMapping
=
function
(){};
THREE
.
CubeRefractionMapping
=
function
(){};
THREE
.
LatitudeReflectionMapping
=
function
(){};
THREE
.
LatitudeRefractionMapping
=
function
(){};
THREE
.
SphericalReflectionMapping
=
function
(){};
THREE
.
SphericalRefractionMapping
=
function
(){};
THREE
.
UVMapping
=
function
(){};
THREE
.
Scene
=
function
(){
this
.
objects
=
[];
this
.
lights
=
[];
this
.
fog
=
null
;
this
.
addObject
=
function
(
a
){
this
.
objects
.
indexOf
(
a
)
===-
1
&&
this
.
objects
.
push
(
a
)};
this
.
removeObject
=
function
(
a
){
a
=
this
.
objects
.
indexOf
(
a
);
a
!==-
1
&&
this
.
objects
.
splice
(
a
,
1
)};
this
.
addLight
=
function
(
a
){
this
.
lights
.
indexOf
(
a
)
===-
1
&&
this
.
lights
.
push
(
a
)};
this
.
removeLight
=
function
(
a
){
a
=
this
.
lights
.
indexOf
(
a
);
a
!==-
1
&&
this
.
lights
.
splice
(
a
,
1
)};
this
.
toString
=
function
(){
return
"
THREE.Scene (
"
+
this
.
objects
+
"
)
"
}};
THREE
.
Fog
=
function
(
a
,
c
,
f
){
this
.
color
=
new
THREE
.
Color
(
a
);
this
.
near
=
c
||
1
;
this
.
far
=
f
||
1
E3
};
THREE
.
FogExp2
=
function
(
a
,
c
){
this
.
color
=
new
THREE
.
Color
(
a
);
this
.
density
=
c
||
2.5
E
-
4
};
THREE
.
Projector
=
function
(){
function
a
(
q
,
t
){
return
t
.
z
-
q
.
z
}
function
c
(
q
,
t
){
var
F
=
0
,
y
=
1
,
H
=
q
.
z
+
q
.
w
,
G
=
t
.
z
+
t
.
w
,
D
=-
q
.
z
+
q
.
w
,
M
=-
t
.
z
+
t
.
w
;
if
(
H
>=
0
&&
G
>=
0
&&
D
>=
0
&&
M
>=
0
)
return
true
;
else
if
(
H
<
0
&&
G
<
0
||
D
<
0
&&
M
<
0
)
return
false
;
else
{
if
(
H
<
0
)
F
=
Math
.
max
(
F
,
H
/
(
H
-
G
));
else
if
(
G
<
0
)
y
=
Math
.
min
(
y
,
H
/
(
H
-
G
));
if
(
D
<
0
)
F
=
Math
.
max
(
F
,
D
/
(
D
-
M
));
else
if
(
M
<
0
)
y
=
Math
.
min
(
y
,
D
/
(
D
-
M
));
if
(
y
<
F
)
return
false
;
else
{
q
.
lerpSelf
(
t
,
F
);
t
.
lerpSelf
(
q
,
1
-
y
);
return
true
}}}
var
f
,
e
,
i
=
[],
k
,
d
,
m
,
l
=
[],
n
,
w
,
E
=
[],
s
,
x
,
B
=
[],
C
=
new
THREE
.
Vector4
,
L
=
new
THREE
.
Vector4
,
u
=
new
THREE
.
Matrix4
,
...
...
@@ -176,19 +176,17 @@ envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vRe
map_pars_fragment
:
"
#ifdef USE_MAP
\n
varying vec2 vUv;
\n
uniform sampler2D map;
\n
#endif
"
,
map_pars_vertex
:
"
#ifdef USE_MAP
\n
varying vec2 vUv;
\n
#endif
"
,
map_fragment
:
"
#ifdef USE_MAP
\n
mapColor = texture2D( map, vUv );
\n
#endif
"
,
map_vertex
:
"
#ifdef USE_MAP
\n
vUv = uv;
\n
#endif
"
,
lights_pars_vertex
:
"
uniform bool enableLighting;
\n
uniform vec3 ambientLightColor;
\n
#if MAX_DIR_LIGHTS > 0
\n
uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
\n
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
\n
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
\n
#ifdef PHONG
\n
varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];
\n
#endif
\n
#endif
"
,
lights_vertex
:
"
if ( !enableLighting ) {
\n
vLightWeighting = vec3( 1.0 );
\n
} else {
\n
vLightWeighting = ambientLightColor;
\n
#if MAX_DIR_LIGHTS > 0
\n
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
\n
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
\n
float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );
\n
vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;
\n
}
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {
\n
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
\n
vec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );
\n
float pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );
\n
vLightWeighting += pointLightColor[ i ] * pointLightWeighting;
\n
#ifdef PHONG
\n
vPointLightVector[ i ] = pointLightVector;
\n
#endif
\n
}
\n
#endif
\n
}
"
,
lights_pars_fragment
:
"
#if MAX_DIR_LIGHTS > 0
\n
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];
\n
#endif
\n
varying vec3 vViewPosition;
\n
varying vec3 vNormal;
"
,
lights_fragment
:
"
vec3 normal = normalize( vNormal );
\n
vec3 viewPosition = normalize( vViewPosition );
\n
vec4 mSpecular = vec4( specular, opacity );
\n
#if MAX_POINT_LIGHTS > 0
\n
vec4 pointDiffuse = vec4( 0.0 );
\n
vec4 pointSpecular = vec4( 0.0 );
\n
for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {
\n
vec3 pointVector = normalize( vPointLightVector[ i ] );
\n
vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );
\n
float pointDotNormalHalf = dot( normal, pointHalfVector );
\n
float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );
\n
float pointSpecularWeight = 0.0;
\n
if ( pointDotNormalHalf >= 0.0 )
\n
pointSpecularWeight = pow( pointDotNormalHalf, shininess );
\n
pointDiffuse += mColor * pointDiffuseWeight;
\n
pointSpecular += mSpecular * pointSpecularWeight;
\n
}
\n
#endif
\n
#if MAX_DIR_LIGHTS > 0
\n
vec4 dirDiffuse = vec4( 0.0 );
\n
vec4 dirSpecular = vec4( 0.0 );
\n
for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {
\n
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
\n
vec3 dirVector = normalize( lDirection.xyz );
\n
vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );
\n
float dirDotNormalHalf = dot( normal, dirHalfVector );
\n
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
\n
float dirSpecularWeight = 0.0;
\n
if ( dirDotNormalHalf >= 0.0 )
\n
dirSpecularWeight = pow( dirDotNormalHalf, shininess );
\n
dirDiffuse += mColor * dirDiffuseWeight;
\n
dirSpecular += mSpecular * dirSpecularWeight;
\n
}
\n
#endif
\n
vec4 totalLight = vec4( ambient, opacity );
\n
#if MAX_DIR_LIGHTS > 0
\n
totalLight += dirDiffuse + dirSpecular;
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
totalLight += pointDiffuse + pointSpecular;
\n
#endif
"
};
THREE
.
UniformsLib
=
{
common
:{
color
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
15658734
)},
opacity
:{
type
:
"
f
"
,
value
:
1
},
map
:{
type
:
"
t
"
,
value
:
0
,
texture
:
null
},
env_map
:{
type
:
"
t
"
,
value
:
1
,
texture
:
null
},
useRefract
:{
type
:
"
i
"
,
value
:
0
},
reflectivity
:{
type
:
"
f
"
,
value
:
1
},
refraction_ratio
:{
type
:
"
f
"
,
value
:
0.98
},
combine
:{
type
:
"
i
"
,
value
:
0
},
fogDensity
:{
type
:
"
f
"
,
value
:
2.5
E
-
4
},
fogNear
:{
type
:
"
f
"
,
value
:
1
},
fogFar
:{
type
:
"
f
"
,
value
:
2
E3
},
fogColor
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
16777215
)}},
lights
:{
enableLighting
:{
type
:
"
i
"
,
value
:
1
},
ambientLightColor
:{
type
:
"
fv
"
,
value
:[]},
directionalLightDirection
:{
type
:
"
fv
"
,
value
:[]},
directionalLightColor
:{
type
:
"
fv
"
,
value
:[]},
pointLightPosition
:{
type
:
"
fv
"
,
value
:[]},
pointLightColor
:{
type
:
"
fv
"
,
value
:[]}}};
THREE
.
ShaderLib
=
{
depth
:{
uniforms
:{
mNear
:{
type
:
"
f
"
,
value
:
1
},
mFar
:{
type
:
"
f
"
,
value
:
2
E3
}},
fragment_shader
:
"
uniform float mNear;
\n
uniform float mFar;
\n
void main() {
\n
float depth = gl_FragCoord.z / gl_FragCoord.w;
\n
float color = 1.0 - smoothstep( mNear, mFar, depth );
\n
gl_FragColor = vec4( vec3( color ), 1.0 );
\n
}
"
,
vertex_shader
:
"
void main() {
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
\n
}
"
},
normal
:{
uniforms
:{},
fragment_shader
:
"
varying vec3 vNormal;
\n
void main() {
\n
gl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );
\n
}
"
,
vertex_shader
:
"
varying vec3 vNormal;
\n
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
\n
vNormal = normalize( normalMatrix * normal );
\n
gl_Position = projectionMatrix * mvPosition;
\n
}
"
},
basic
:{
uniforms
:{
color
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
15658734
)},
opacity
:{
type
:
"
f
"
,
value
:
1
},
map
:{
type
:
"
t
"
,
value
:
0
,
texture
:
null
},
env_map
:{
type
:
"
t
"
,
value
:
1
,
texture
:
null
},
useRefract
:{
type
:
"
i
"
,
value
:
0
},
reflectivity
:{
type
:
"
f
"
,
value
:
1
},
refraction_ratio
:{
type
:
"
f
"
,
value
:
0.98
},
combine
:{
type
:
"
i
"
,
value
:
0
},
fogDensity
:{
type
:
"
f
"
,
value
:
2.5
E
-
4
},
fogNear
:{
type
:
"
f
"
,
value
:
1
},
fogFar
:{
type
:
"
f
"
,
value
:
2
E3
},
fogColor
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
16777215
)}},
fragment_shader
:[
"
uniform vec3 color;
\n
uniform float opacity;
"
,
THREE
.
Snippets
.
map_pars_fragment
,
THREE
.
Snippets
.
envmap_pars_fragment
,
THREE
.
Snippets
.
fog_pars_fragment
,
"
void main() {
\n
vec4 mColor = vec4( color, opacity );
\n
vec4 mapColor = vec4( 1.0 );
\n
vec4 cubeColor = vec4( 1.0 );
"
,
THREE
.
Snippets
.
map_fragment
,
"
gl_FragColor = mColor * mapColor;
"
,
THREE
.
Snippets
.
envmap_fragment
,
THREE
.
Snippets
.
fog_fragment
,
"
}
"
].
join
(
"
\n
"
),
vertex_shader
:[
THREE
.
Snippets
.
map_pars_vertex
,
THREE
.
Snippets
.
envmap_pars_vertex
,
"
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
THREE
.
Snippets
.
map_vertex
,
THREE
.
Snippets
.
envmap_vertex
,
"
gl_Position = projectionMatrix * mvPosition;
\n
}
"
].
join
(
"
\n
"
)},
lambert
:{
uniforms
:{
color
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
15658734
)},
opacity
:{
type
:
"
f
"
,
value
:
1
},
map
:{
type
:
"
t
"
,
value
:
0
,
texture
:
null
},
env_map
:{
type
:
"
t
"
,
value
:
1
,
texture
:
null
},
useRefract
:{
type
:
"
i
"
,
value
:
0
},
reflectivity
:{
type
:
"
f
"
,
value
:
1
},
refraction_ratio
:{
type
:
"
f
"
,
value
:
0.98
},
combine
:{
type
:
"
i
"
,
value
:
0
},
fogDensity
:{
type
:
"
f
"
,
value
:
2.5
E
-
4
},
fogNear
:{
type
:
"
f
"
,
value
:
1
},
fogFar
:{
type
:
"
f
"
,
value
:
2
E3
},
fogColor
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
16777215
)},
enableLighting
:{
type
:
"
i
"
,
value
:
1
},
ambientLightColor
:{
type
:
"
fv
"
,
value
:[]},
directionalLightDirection
:{
type
:
"
fv
"
,
value
:[]},
directionalLightColor
:{
type
:
"
fv
"
,
value
:[]},
pointLightPosition
:{
type
:
"
fv
"
,
value
:[]},
pointLightColor
:{
type
:
"
fv
"
,
value
:[]}},
fragment_shader
:[
"
uniform vec3 color;
\n
uniform float opacity;
\n
varying vec3 vLightWeighting;
"
,
vertex_shader
:
"
varying vec3 vNormal;
\n
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
\n
vNormal = normalize( normalMatrix * normal );
\n
gl_Position = projectionMatrix * mvPosition;
\n
}
"
},
basic
:{
uniforms
:
THREE
.
UniformsLib
.
common
,
fragment_shader
:[
"
uniform vec3 color;
\n
uniform float opacity;
"
,
THREE
.
Snippets
.
map_pars_fragment
,
THREE
.
Snippets
.
envmap_pars_fragment
,
THREE
.
Snippets
.
fog_pars_fragment
,
"
void main() {
\n
vec4 mColor = vec4( color, opacity );
\n
vec4 mapColor = vec4( 1.0 );
\n
vec4 cubeColor = vec4( 1.0 );
"
,
THREE
.
Snippets
.
map_fragment
,
"
gl_FragColor = mColor * mapColor;
"
,
THREE
.
Snippets
.
envmap_fragment
,
THREE
.
Snippets
.
fog_fragment
,
"
}
"
].
join
(
"
\n
"
),
vertex_shader
:[
THREE
.
Snippets
.
map_pars_vertex
,
THREE
.
Snippets
.
envmap_pars_vertex
,
"
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
THREE
.
Snippets
.
map_vertex
,
THREE
.
Snippets
.
envmap_vertex
,
"
gl_Position = projectionMatrix * mvPosition;
\n
}
"
].
join
(
"
\n
"
)},
lambert
:{
uniforms
:
Uniforms
.
merge
([
THREE
.
UniformsLib
.
common
,
THREE
.
UniformsLib
.
lights
]),
fragment_shader
:[
"
uniform vec3 color;
\n
uniform float opacity;
\n
varying vec3 vLightWeighting;
"
,
THREE
.
Snippets
.
map_pars_fragment
,
THREE
.
Snippets
.
envmap_pars_fragment
,
THREE
.
Snippets
.
fog_pars_fragment
,
"
void main() {
\n
vec4 mColor = vec4( color, opacity );
\n
vec4 mapColor = vec4( 1.0 );
\n
vec4 cubeColor = vec4( 1.0 );
"
,
THREE
.
Snippets
.
map_fragment
,
"
gl_FragColor = mColor * mapColor * vec4( vLightWeighting, 1.0 );
"
,
THREE
.
Snippets
.
envmap_fragment
,
THREE
.
Snippets
.
fog_fragment
,
"
}
"
].
join
(
"
\n
"
),
vertex_shader
:[
"
varying vec3 vLightWeighting;
"
,
THREE
.
Snippets
.
map_pars_vertex
,
THREE
.
Snippets
.
envmap_pars_vertex
,
THREE
.
Snippets
.
lights_pars_vertex
,
"
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
THREE
.
Snippets
.
map_vertex
,
THREE
.
Snippets
.
envmap_vertex
,
"
vec3 transformedNormal = normalize( normalMatrix * normal );
"
,
THREE
.
Snippets
.
lights_vertex
,
"
gl_Position = projectionMatrix * mvPosition;
\n
}
"
].
join
(
"
\n
"
)},
phong
:{
uniforms
:{
color
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
15658734
)},
opacity
:{
type
:
"
f
"
,
value
:
1
},
map
:{
type
:
"
t
"
,
value
:
0
,
texture
:
null
},
ambient
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
328965
)},
specular
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
1118481
)},
shininess
:{
type
:
"
f
"
,
value
:
30
},
env_map
:{
type
:
"
t
"
,
value
:
1
,
texture
:
null
},
useRefract
:{
type
:
"
i
"
,
value
:
0
},
reflectivity
:{
type
:
"
f
"
,
value
:
1
},
refraction_ratio
:{
type
:
"
f
"
,
value
:
0.98
},
combine
:{
type
:
"
i
"
,
value
:
0
},
fogDensity
:{
type
:
"
f
"
,
value
:
2.5
E
-
4
},
fogNear
:{
type
:
"
f
"
,
value
:
1
},
fogFar
:{
type
:
"
f
"
,
value
:
2
E3
},
fogColor
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
16777215
)},
enableLighting
:{
type
:
"
i
"
,
value
:
1
},
ambientLightColor
:{
type
:
"
fv
"
,
value
:[]},
directionalLightDirection
:{
type
:
"
fv
"
,
value
:[]},
directionalLightColor
:{
type
:
"
fv
"
,
value
:[]},
pointLightPosition
:{
type
:
"
fv
"
,
value
:[]},
pointLightColor
:{
type
:
"
fv
"
,
value
:[]}},
fragment_shader
:[
"
uniform vec3 color;
\n
uniform float opacity;
\n
uniform vec3 ambient;
\n
uniform vec3 specular;
\n
uniform float shininess;
\n
varying vec3 vLightWeighting;
"
,
THREE
.
Snippets
.
map_pars_fragment
,
THREE
.
Snippets
.
envmap_pars_fragment
,
THREE
.
Snippets
.
fog_pars_fragment
,
THREE
.
Snippets
.
lights_pars_fragment
,
"
void main() {
\n
vec4 mColor = vec4( color, opacity );
\n
vec4 mapColor = vec4( 1.0 );
\n
vec4 cubeColor = vec4( 1.0 );
"
,
THREE
.
Snippets
.
map_fragment
,
THREE
.
Snippets
.
lights_fragment
,
"
gl_FragColor = mapColor * totalLight * vec4( vLightWeighting, 1.0 );
"
,
THREE
.
Snippets
.
envmap_fragment
,
THREE
.
Snippets
.
fog_fragment
,
"
}
"
].
join
(
"
\n
"
),
vertex_shader
:[
"
#define PHONG
\n
varying vec3 vLightWeighting;
\n
varying vec3 vViewPosition;
\n
varying vec3 vNormal;
"
,
THREE
.
Snippets
.
map_pars_vertex
,
THREE
.
Snippets
.
envmap_pars_vertex
,
THREE
.
Snippets
.
lights_pars_vertex
,
"
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
THREE
.
Snippets
.
map_vertex
,
THREE
.
Snippets
.
envmap_vertex
,
"
#ifndef USE_ENVMAP
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
#endif
\n
vViewPosition = cameraPosition - mPosition.xyz;
\n
vec3 transformedNormal = normalize( normalMatrix * normal );
\n
vNormal = transformedNormal;
"
,
THREE
.
Snippets
.
lights_vertex
,
"
gl_Position = projectionMatrix * mvPosition;
\n
}
"
].
join
(
"
\n
"
)}};
THREE
.
RenderableObject
=
function
(){
this
.
z
=
this
.
object
=
null
};
THREE
.
RenderableFace3
=
function
(){
this
.
z
=
null
;
this
.
v1
=
new
THREE
.
Vertex
;
this
.
v2
=
new
THREE
.
Vertex
;
this
.
v3
=
new
THREE
.
Vertex
;
this
.
centroidWorld
=
new
THREE
.
Vector3
;
this
.
centroidScreen
=
new
THREE
.
Vector3
;
this
.
normalWorld
=
new
THREE
.
Vector3
;
this
.
vertexNormalsWorld
=
[];
this
.
faceMaterials
=
this
.
meshMaterials
=
null
;
this
.
overdraw
=
false
;
this
.
uvs
=
[
null
,
null
,
null
]};
THREE
.
RenderableParticle
=
function
(){
this
.
rotation
=
this
.
z
=
this
.
y
=
this
.
x
=
null
;
this
.
scale
=
new
THREE
.
Vector2
;
this
.
materials
=
null
};
THREE
.
RenderableLine
=
function
(){
this
.
z
=
null
;
this
.
v1
=
new
THREE
.
Vertex
;
this
.
v2
=
new
THREE
.
Vertex
;
this
.
materials
=
null
};
THREE
.
Snippets
.
lights_pars_vertex
,
"
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
THREE
.
Snippets
.
map_vertex
,
THREE
.
Snippets
.
envmap_vertex
,
"
vec3 transformedNormal = normalize( normalMatrix * normal );
"
,
THREE
.
Snippets
.
lights_vertex
,
"
gl_Position = projectionMatrix * mvPosition;
\n
}
"
].
join
(
"
\n
"
)},
phong
:{
uniforms
:
Uniforms
.
merge
([
THREE
.
UniformsLib
.
common
,
THREE
.
UniformsLib
.
lights
,{
ambient
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
328965
)},
specular
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
1118481
)},
shininess
:{
type
:
"
f
"
,
value
:
30
}}]),
fragment_shader
:[
"
uniform vec3 color;
\n
uniform float opacity;
\n
uniform vec3 ambient;
\n
uniform vec3 specular;
\n
uniform float shininess;
\n
varying vec3 vLightWeighting;
"
,
THREE
.
Snippets
.
map_pars_fragment
,
THREE
.
Snippets
.
envmap_pars_fragment
,
THREE
.
Snippets
.
fog_pars_fragment
,
THREE
.
Snippets
.
lights_pars_fragment
,
"
void main() {
\n
vec4 mColor = vec4( color, opacity );
\n
vec4 mapColor = vec4( 1.0 );
\n
vec4 cubeColor = vec4( 1.0 );
"
,
THREE
.
Snippets
.
map_fragment
,
THREE
.
Snippets
.
lights_fragment
,
"
gl_FragColor = mapColor * totalLight * vec4( vLightWeighting, 1.0 );
"
,
THREE
.
Snippets
.
envmap_fragment
,
THREE
.
Snippets
.
fog_fragment
,
"
}
"
].
join
(
"
\n
"
),
vertex_shader
:[
"
#define PHONG
\n
varying vec3 vLightWeighting;
\n
varying vec3 vViewPosition;
\n
varying vec3 vNormal;
"
,
THREE
.
Snippets
.
map_pars_vertex
,
THREE
.
Snippets
.
envmap_pars_vertex
,
THREE
.
Snippets
.
lights_pars_vertex
,
"
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
THREE
.
Snippets
.
map_vertex
,
THREE
.
Snippets
.
envmap_vertex
,
"
#ifndef USE_ENVMAP
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
#endif
\n
vViewPosition = cameraPosition - mPosition.xyz;
\n
vec3 transformedNormal = normalize( normalMatrix * normal );
\n
vNormal = transformedNormal;
"
,
THREE
.
Snippets
.
lights_vertex
,
"
gl_Position = projectionMatrix * mvPosition;
\n
}
"
].
join
(
"
\n
"
)}};
THREE
.
RenderableObject
=
function
(){
this
.
z
=
this
.
object
=
null
};
THREE
.
RenderableFace3
=
function
(){
this
.
z
=
null
;
this
.
v1
=
new
THREE
.
Vertex
;
this
.
v2
=
new
THREE
.
Vertex
;
this
.
v3
=
new
THREE
.
Vertex
;
this
.
centroidWorld
=
new
THREE
.
Vector3
;
this
.
centroidScreen
=
new
THREE
.
Vector3
;
this
.
normalWorld
=
new
THREE
.
Vector3
;
this
.
vertexNormalsWorld
=
[];
this
.
faceMaterials
=
this
.
meshMaterials
=
null
;
this
.
overdraw
=
false
;
this
.
uvs
=
[
null
,
null
,
null
]};
THREE
.
RenderableParticle
=
function
(){
this
.
rotation
=
this
.
z
=
this
.
y
=
this
.
x
=
null
;
this
.
scale
=
new
THREE
.
Vector2
;
this
.
materials
=
null
};
THREE
.
RenderableLine
=
function
(){
this
.
z
=
null
;
this
.
v1
=
new
THREE
.
Vertex
;
this
.
v2
=
new
THREE
.
Vertex
;
this
.
materials
=
null
};
var
GeometryUtils
=
{
merge
:
function
(
a
,
c
){
var
f
=
c
instanceof
THREE
.
Mesh
,
e
=
a
.
vertices
.
length
,
i
=
f
?
c
.
geometry
:
c
,
k
=
a
.
vertices
,
d
=
i
.
vertices
,
m
=
a
.
faces
,
l
=
i
.
faces
,
n
=
a
.
uvs
;
i
=
i
.
uvs
;
f
&&
c
.
updateMatrix
();
for
(
var
w
=
0
,
E
=
d
.
length
;
w
<
E
;
w
++
){
var
s
=
new
THREE
.
Vertex
(
d
[
w
].
position
.
clone
());
f
&&
c
.
matrix
.
multiplyVector3
(
s
.
position
);
k
.
push
(
s
)}
w
=
0
;
for
(
E
=
l
.
length
;
w
<
E
;
w
++
){
d
=
l
[
w
];
var
x
,
B
=
d
.
vertexNormals
;
if
(
d
instanceof
THREE
.
Face3
)
x
=
new
THREE
.
Face3
(
d
.
a
+
e
,
d
.
b
+
e
,
d
.
c
+
e
);
else
if
(
d
instanceof
THREE
.
Face4
)
x
=
new
THREE
.
Face4
(
d
.
a
+
e
,
d
.
b
+
e
,
d
.
c
+
e
,
d
.
d
+
e
);
x
.
centroid
.
copy
(
d
.
centroid
);
x
.
normal
.
copy
(
d
.
normal
);
f
=
0
;
for
(
k
=
B
.
length
;
f
<
k
;
f
++
){
s
=
B
[
f
];
x
.
vertexNormals
.
push
(
s
.
clone
())}
x
.
materials
=
d
.
materials
.
slice
();
m
.
push
(
x
)}
w
=
0
;
for
(
E
=
i
.
length
;
w
<
E
;
w
++
){
e
=
i
[
w
];
m
=
[];
f
=
0
;
for
(
k
=
e
.
length
;
f
<
k
;
f
++
)
m
.
push
(
new
THREE
.
UV
(
e
[
f
].
u
,
e
[
f
].
v
));
n
.
push
(
m
)}}},
ImageUtils
=
{
loadTexture
:
function
(
a
,
c
){
var
f
=
new
Image
;
f
.
onload
=
function
(){
this
.
loaded
=
true
};
f
.
src
=
a
;
return
new
THREE
.
Texture
(
f
,
c
)},
loadArray
:
function
(
a
){
var
c
,
f
,
e
=
[];
c
=
e
.
loadCount
=
0
;
for
(
f
=
a
.
length
;
c
<
f
;
++
c
){
e
[
c
]
=
new
Image
;
e
[
c
].
loaded
=
0
;
e
[
c
].
onload
=
function
(){
e
.
loadCount
+=
1
;
this
.
loaded
=
true
};
e
[
c
].
src
=
a
[
c
]}
return
e
}},
SceneUtils
=
{
addMesh
:
function
(
a
,
c
,
f
,
e
,
i
,
k
,
d
,
m
,
l
,
n
){
c
=
new
THREE
.
Mesh
(
c
,
n
);
c
.
scale
.
x
=
c
.
scale
.
y
=
c
.
scale
.
z
=
f
;
c
.
position
.
x
=
e
;
c
.
position
.
y
=
i
;
c
.
position
.
z
=
k
;
c
.
rotation
.
x
=
d
;
c
.
rotation
.
y
=
m
;
c
.
rotation
.
z
=
l
;
a
.
addObject
(
c
);
return
c
},
addPanoramaCubeWebGL
:
function
(
a
,
c
,
f
){
var
e
=
ShaderUtils
.
lib
.
cube
;
e
.
uniforms
.
tCube
.
texture
=
f
;
f
=
new
THREE
.
MeshShaderMaterial
({
fragment_shader
:
e
.
fragment_shader
,
vertex_shader
:
e
.
vertex_shader
,
...
...
src/materials/Uniforms.js
浏览文件 @
ab360240
...
...
@@ -30,6 +30,26 @@ var Uniforms = {
return
uniforms_dst
;
},
merge
:
function
(
uniforms
)
{
var
u
,
p
,
tmp
,
merged
=
{};
for
(
u
=
0
;
u
<
uniforms
.
length
;
u
++
)
{
tmp
=
this
.
clone
(
uniforms
[
u
]
);
for
(
p
in
tmp
)
{
merged
[
p
]
=
tmp
[
p
];
}
}
return
merged
;
}
};
src/renderers/WebGLRenderer.js
浏览文件 @
ab360240
...
...
@@ -1549,6 +1549,40 @@ THREE.Snippets = {
};
THREE
.
UniformsLib
=
{
common
:
{
"
color
"
:
{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
0xeeeeee
)
},
"
opacity
"
:
{
type
:
"
f
"
,
value
:
1
},
"
map
"
:
{
type
:
"
t
"
,
value
:
0
,
texture
:
null
},
"
env_map
"
:
{
type
:
"
t
"
,
value
:
1
,
texture
:
null
},
"
useRefract
"
:
{
type
:
"
i
"
,
value
:
0
},
"
reflectivity
"
:
{
type
:
"
f
"
,
value
:
1
},
"
refraction_ratio
"
:
{
type
:
"
f
"
,
value
:
0.98
},
"
combine
"
:
{
type
:
"
i
"
,
value
:
0
},
"
fogDensity
"
:
{
type
:
"
f
"
,
value
:
0.00025
},
"
fogNear
"
:
{
type
:
"
f
"
,
value
:
1
},
"
fogFar
"
:
{
type
:
"
f
"
,
value
:
2000
},
"
fogColor
"
:
{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
0xffffff
)
}
},
lights
:
{
"
enableLighting
"
:
{
type
:
"
i
"
,
value
:
1
},
"
ambientLightColor
"
:
{
type
:
"
fv
"
,
value
:
[]
},
"
directionalLightDirection
"
:
{
type
:
"
fv
"
,
value
:
[]
},
"
directionalLightColor
"
:
{
type
:
"
fv
"
,
value
:
[]
},
"
pointLightPosition
"
:
{
type
:
"
fv
"
,
value
:
[]
},
"
pointLightColor
"
:
{
type
:
"
fv
"
,
value
:
[]
}
}
};
THREE
.
ShaderLib
=
{
'
depth
'
:
{
...
...
@@ -1617,23 +1651,9 @@ THREE.ShaderLib = {
},
'
basic
'
:
{
uniforms
:
{
"
color
"
:
{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
0xeeeeee
)
},
"
opacity
"
:
{
type
:
"
f
"
,
value
:
1
},
"
map
"
:
{
type
:
"
t
"
,
value
:
0
,
texture
:
null
},
"
env_map
"
:
{
type
:
"
t
"
,
value
:
1
,
texture
:
null
},
"
useRefract
"
:
{
type
:
"
i
"
,
value
:
0
},
"
reflectivity
"
:
{
type
:
"
f
"
,
value
:
1
},
"
refraction_ratio
"
:
{
type
:
"
f
"
,
value
:
0.98
},
"
combine
"
:
{
type
:
"
i
"
,
value
:
0
},
"
fogDensity
"
:
{
type
:
"
f
"
,
value
:
0.00025
},
"
fogNear
"
:
{
type
:
"
f
"
,
value
:
1
},
"
fogFar
"
:
{
type
:
"
f
"
,
value
:
2000
},
"
fogColor
"
:
{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
0xffffff
)
}
},
uniforms
:
THREE
.
UniformsLib
[
"
common
"
],
fragment_shader
:
[
"
uniform vec3 color;
"
,
...
...
@@ -1682,28 +1702,8 @@ THREE.ShaderLib = {
'
lambert
'
:
{
uniforms
:
{
"
color
"
:
{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
0xeeeeee
)
},
"
opacity
"
:
{
type
:
"
f
"
,
value
:
1
},
"
map
"
:
{
type
:
"
t
"
,
value
:
0
,
texture
:
null
},
"
env_map
"
:
{
type
:
"
t
"
,
value
:
1
,
texture
:
null
},
"
useRefract
"
:
{
type
:
"
i
"
,
value
:
0
},
"
reflectivity
"
:
{
type
:
"
f
"
,
value
:
1
},
"
refraction_ratio
"
:
{
type
:
"
f
"
,
value
:
0.98
},
"
combine
"
:
{
type
:
"
i
"
,
value
:
0
},
"
fogDensity
"
:
{
type
:
"
f
"
,
value
:
0.00025
},
"
fogNear
"
:
{
type
:
"
f
"
,
value
:
1
},
"
fogFar
"
:
{
type
:
"
f
"
,
value
:
2000
},
"
fogColor
"
:
{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
0xffffff
)
},
"
enableLighting
"
:
{
type
:
"
i
"
,
value
:
1
},
"
ambientLightColor
"
:
{
type
:
"
fv
"
,
value
:
[]
},
"
directionalLightDirection
"
:
{
type
:
"
fv
"
,
value
:
[]
},
"
directionalLightColor
"
:
{
type
:
"
fv
"
,
value
:
[]
},
"
pointLightPosition
"
:
{
type
:
"
fv
"
,
value
:
[]
},
"
pointLightColor
"
:
{
type
:
"
fv
"
,
value
:
[]
}
},
uniforms
:
Uniforms
.
merge
(
[
THREE
.
UniformsLib
[
"
common
"
],
THREE
.
UniformsLib
[
"
lights
"
]
]
),
fragment_shader
:
[
...
...
@@ -1762,32 +1762,15 @@ THREE.ShaderLib = {
'
phong
'
:
{
uniforms
:
{
"
color
"
:
{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
0xeeeeee
)
},
"
opacity
"
:
{
type
:
"
f
"
,
value
:
1
},
"
map
"
:
{
type
:
"
t
"
,
value
:
0
,
texture
:
null
},
"
ambient
"
:
{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
0x050505
)
},
"
specular
"
:
{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
0x111111
)
},
"
shininess
"
:
{
type
:
"
f
"
,
value
:
30
},
"
env_map
"
:
{
type
:
"
t
"
,
value
:
1
,
texture
:
null
},
"
useRefract
"
:
{
type
:
"
i
"
,
value
:
0
},
"
reflectivity
"
:
{
type
:
"
f
"
,
value
:
1
},
"
refraction_ratio
"
:
{
type
:
"
f
"
,
value
:
0.98
},
"
combine
"
:
{
type
:
"
i
"
,
value
:
0
},
"
fogDensity
"
:
{
type
:
"
f
"
,
value
:
0.00025
},
"
fogNear
"
:
{
type
:
"
f
"
,
value
:
1
},
"
fogFar
"
:
{
type
:
"
f
"
,
value
:
2000
},
"
fogColor
"
:
{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
0xffffff
)
},
"
enableLighting
"
:
{
type
:
"
i
"
,
value
:
1
},
"
ambientLightColor
"
:
{
type
:
"
fv
"
,
value
:
[]
},
"
directionalLightDirection
"
:
{
type
:
"
fv
"
,
value
:
[]
},
"
directionalLightColor
"
:
{
type
:
"
fv
"
,
value
:
[]
},
"
pointLightPosition
"
:
{
type
:
"
fv
"
,
value
:
[]
},
"
pointLightColor
"
:
{
type
:
"
fv
"
,
value
:
[]
}
},
uniforms
:
Uniforms
.
merge
(
[
THREE
.
UniformsLib
[
"
common
"
],
THREE
.
UniformsLib
[
"
lights
"
],
{
"
ambient
"
:
{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
0x050505
)
},
"
specular
"
:
{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
0x111111
)
},
"
shininess
"
:
{
type
:
"
f
"
,
value
:
30
}
}
]
),
fragment_shader
:
[
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录