Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
b6bce4f6
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,发现更多精彩内容 >>
提交
b6bce4f6
编写于
1月 31, 2012
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added handling of morph normals also for Phong material.
上级
a372d5ee
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
20 addition
and
16 deletion
+20
-16
build/Three.js
build/Three.js
+4
-4
build/custom/ThreeCanvas.js
build/custom/ThreeCanvas.js
+1
-1
build/custom/ThreeSVG.js
build/custom/ThreeSVG.js
+1
-1
build/custom/ThreeWebGL.js
build/custom/ThreeWebGL.js
+4
-4
examples/webgl_morphnormals.html
examples/webgl_morphnormals.html
+3
-3
src/materials/MeshPhongMaterial.js
src/materials/MeshPhongMaterial.js
+1
-0
src/renderers/WebGLShaders.js
src/renderers/WebGLShaders.js
+6
-3
未找到文件。
build/Three.js
浏览文件 @
b6bce4f6
...
...
@@ -121,7 +121,7 @@ THREE.MultiplyOperation;this.reflectivity=void 0!==a.reflectivity?a.reflectivity
a
.
wireframeLinejoin
:
"
round
"
;
this
.
vertexColors
=
void
0
!==
a
.
vertexColors
?
a
.
vertexColors
:
!
1
;
this
.
skinning
=
void
0
!==
a
.
skinning
?
a
.
skinning
:
!
1
;
this
.
morphTargets
=
void
0
!==
a
.
morphTargets
?
a
.
morphTargets
:
!
1
;
this
.
morphNormals
=
void
0
!==
a
.
morphNormals
?
a
.
morphNormals
:
!
1
};
THREE
.
MeshLambertMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
MeshLambertMaterial
.
prototype
.
constructor
=
THREE
.
MeshLambertMaterial
;
THREE
.
MeshPhongMaterial
=
function
(
a
){
THREE
.
Material
.
call
(
this
,
a
);
a
=
a
||
{};
this
.
color
=
void
0
!==
a
.
color
?
new
THREE
.
Color
(
a
.
color
):
new
THREE
.
Color
(
16777215
);
this
.
ambient
=
void
0
!==
a
.
ambient
?
new
THREE
.
Color
(
a
.
ambient
):
new
THREE
.
Color
(
16777215
);
this
.
specular
=
void
0
!==
a
.
specular
?
new
THREE
.
Color
(
a
.
specular
):
new
THREE
.
Color
(
1118481
);
this
.
shininess
=
void
0
!==
a
.
shininess
?
a
.
shininess
:
30
;
this
.
metal
=
void
0
!==
a
.
metal
?
a
.
metal
:
!
1
;
this
.
perPixel
=
void
0
!==
a
.
perPixel
?
a
.
perPixel
:
!
1
;
this
.
wrapAround
=
void
0
!==
a
.
wrapAround
?
a
.
wrapAround
:
!
1
;
this
.
wrapRGB
=
new
THREE
.
Vector3
(
1
,
1
,
1
);
this
.
map
=
void
0
!==
a
.
map
?
a
.
map
:
null
;
this
.
lightMap
=
void
0
!==
a
.
lightMap
?
a
.
lightMap
:
null
;
this
.
envMap
=
void
0
!==
a
.
envMap
?
a
.
envMap
:
null
;
this
.
combine
=
void
0
!==
a
.
combine
?
a
.
combine
:
THREE
.
MultiplyOperation
;
this
.
reflectivity
=
void
0
!==
a
.
reflectivity
?
a
.
reflectivity
:
1
;
this
.
refractionRatio
=
void
0
!==
a
.
refractionRatio
?
a
.
refractionRatio
:
0.98
;
this
.
fog
=
void
0
!==
a
.
fog
?
a
.
fog
:
!
0
;
this
.
shading
=
void
0
!==
a
.
shading
?
a
.
shading
:
THREE
.
SmoothShading
;
this
.
wireframe
=
void
0
!==
a
.
wireframe
?
a
.
wireframe
:
!
1
;
this
.
wireframeLinewidth
=
void
0
!==
a
.
wireframeLinewidth
?
a
.
wireframeLinewidth
:
1
;
this
.
wireframeLinecap
=
void
0
!==
a
.
wireframeLinecap
?
a
.
wireframeLinecap
:
"
round
"
;
this
.
wireframeLinejoin
=
void
0
!==
a
.
wireframeLinejoin
?
a
.
wireframeLinejoin
:
"
round
"
;
this
.
vertexColors
=
void
0
!==
a
.
vertexColors
?
a
.
vertexColors
:
!
1
;
this
.
skinning
=
void
0
!==
a
.
skinning
?
a
.
skinning
:
!
1
;
this
.
morphTargets
=
void
0
!==
a
.
morphTargets
?
a
.
morphTargets
:
!
1
};
THREE
.
MeshPhongMaterial
.
prototype
=
new
THREE
.
Material
;
!
1
;
this
.
wireframeLinewidth
=
void
0
!==
a
.
wireframeLinewidth
?
a
.
wireframeLinewidth
:
1
;
this
.
wireframeLinecap
=
void
0
!==
a
.
wireframeLinecap
?
a
.
wireframeLinecap
:
"
round
"
;
this
.
wireframeLinejoin
=
void
0
!==
a
.
wireframeLinejoin
?
a
.
wireframeLinejoin
:
"
round
"
;
this
.
vertexColors
=
void
0
!==
a
.
vertexColors
?
a
.
vertexColors
:
!
1
;
this
.
skinning
=
void
0
!==
a
.
skinning
?
a
.
skinning
:
!
1
;
this
.
morphTargets
=
void
0
!==
a
.
morphTargets
?
a
.
morphTargets
:
!
1
;
this
.
morphNormals
=
void
0
!==
a
.
morphNormals
?
a
.
morphNormals
:
!
1
};
THREE
.
MeshPhongMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
MeshPhongMaterial
.
prototype
.
constructor
=
THREE
.
MeshPhongMaterial
;
THREE
.
MeshDepthMaterial
=
function
(
a
){
THREE
.
Material
.
call
(
this
,
a
);
a
=
a
||
{};
this
.
shading
=
void
0
!==
a
.
shading
?
a
.
shading
:
THREE
.
SmoothShading
;
this
.
wireframe
=
void
0
!==
a
.
wireframe
?
a
.
wireframe
:
!
1
;
this
.
wireframeLinewidth
=
void
0
!==
a
.
wireframeLinewidth
?
a
.
wireframeLinewidth
:
1
};
THREE
.
MeshDepthMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
MeshDepthMaterial
.
prototype
.
constructor
=
THREE
.
MeshDepthMaterial
;
THREE
.
MeshNormalMaterial
=
function
(
a
){
THREE
.
Material
.
call
(
this
,
a
);
a
=
a
||
{};
this
.
shading
=
a
.
shading
?
a
.
shading
:
THREE
.
FlatShading
;
this
.
wireframe
=
a
.
wireframe
?
a
.
wireframe
:
!
1
;
this
.
wireframeLinewidth
=
a
.
wireframeLinewidth
?
a
.
wireframeLinewidth
:
1
};
THREE
.
MeshNormalMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
MeshNormalMaterial
.
prototype
.
constructor
=
THREE
.
MeshNormalMaterial
;
THREE
.
MeshFaceMaterial
=
function
(){};
THREE
.
MeshShaderMaterial
=
function
(
a
){
console
.
warn
(
"
DEPRECATED: MeshShaderMaterial() is now ShaderMaterial().
"
);
return
new
THREE
.
ShaderMaterial
(
a
)};
...
...
@@ -204,13 +204,13 @@ THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#i
envmap_fragment
:
"
#ifdef USE_ENVMAP
\n
vec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * vReflect.x, vReflect.yz ) );
\n
#ifdef GAMMA_INPUT
\n
cubeColor.xyz *= cubeColor.xyz;
\n
#endif
\n
if ( combine == 1 ) {
\n
gl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity );
\n
} else {
\n
gl_FragColor.xyz = gl_FragColor.xyz * cubeColor.xyz;
\n
}
\n
#endif
"
,
envmap_pars_vertex
:
"
#ifdef USE_ENVMAP
\n
varying vec3 vReflect;
\n
uniform float refractionRatio;
\n
uniform bool useRefract;
\n
#endif
"
,
envmap_vertex
:
"
#ifdef USE_ENVMAP
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
vec3 nWorld = mat3( objectMatrix[ 0 ].xyz, objectMatrix[ 1 ].xyz, objectMatrix[ 2 ].xyz ) * normal;
\n
if ( useRefract ) {
\n
vReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );
\n
} else {
\n
vReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );
\n
}
\n
#endif
"
,
map_particle_pars_fragment
:
"
#ifdef USE_MAP
\n
uniform sampler2D map;
\n
#endif
"
,
map_particle_fragment
:
"
#ifdef USE_MAP
\n
gl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );
\n
#endif
"
,
map_pars_vertex
:
"
#ifdef USE_MAP
\n
varying vec2 vUv;
\n
uniform vec4 offsetRepeat;
\n
#endif
"
,
map_pars_fragment
:
"
#ifdef USE_MAP
\n
varying vec2 vUv;
\n
uniform sampler2D map;
\n
#endif
"
,
map_vertex
:
"
#ifdef USE_MAP
\n
vUv = uv * offsetRepeat.zw + offsetRepeat.xy;
\n
#endif
"
,
map_fragment
:
"
#ifdef USE_MAP
\n
#ifdef GAMMA_INPUT
\n
vec4 texelColor = texture2D( map, vUv );
\n
texelColor.xyz *= texelColor.xyz;
\n
gl_FragColor = gl_FragColor * texelColor;
\n
#else
\n
gl_FragColor = gl_FragColor * texture2D( map, vUv );
\n
#endif
\n
#endif
"
,
lightmap_pars_fragment
:
"
#ifdef USE_LIGHTMAP
\n
varying vec2 vUv2;
\n
uniform sampler2D lightMap;
\n
#endif
"
,
lightmap_pars_vertex
:
"
#ifdef USE_LIGHTMAP
\n
varying vec2 vUv2;
\n
#endif
"
,
lightmap_fragment
:
"
#ifdef USE_LIGHTMAP
\n
gl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );
\n
#endif
"
,
lightmap_vertex
:
"
#ifdef USE_LIGHTMAP
\n
vUv2 = uv2;
\n
#endif
"
,
lights_lambert_pars_vertex
:
"
uniform vec3 ambient;
\n
uniform vec3 diffuse;
\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
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
\n
#endif
\n
#ifdef WRAP_AROUND
\n
uniform vec3 wrapRGB;
\n
#endif
"
,
lights_lambert_vertex
:
"
vLightWeighting = vec3( 0.0 );
\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
vec3 dirVector = normalize( lDirection.xyz );
\n
#ifdef WRAP_AROUND
\n
float directionalLightWeightingFull = max( dot( transformedNormal, dirVector ), 0.0 );
\n
float directionalLightWeightingHalf = max( 0.5 * dot( transformedNormal, dirVector ) + 0.5, 0.0 );
\n
vec3 directionalLightWeighting = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );
\n
#else
\n
float directionalLightWeighting = max( dot( transformedNormal, dirVector ), 0.0 );
\n
#endif
\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 lVector = lPosition.xyz - mvPosition.xyz;
\n
float lDistance = 1.0;
\n
if ( pointLightDistance[ i ] > 0.0 )
\n
lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
\n
lVector = normalize( lVector );
\n
#ifdef WRAP_AROUND
\n
float pointLightWeightingFull = max( dot( transformedNormal, lVector ), 0.0 );
\n
float pointLightWeightingHalf = max( 0.5 * dot( transformedNormal, lVector ) + 0.5, 0.0 );
\n
vec3 pointLightWeighting = mix( vec3 ( pointLightWeightingFull ), vec3( pointLightWeightingHalf ), wrapRGB );
\n
#else
\n
float pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );
\n
#endif
\n
vLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;
\n
}
\n
#endif
\n
vLightWeighting = vLightWeighting * diffuse + ambient * ambientLightColor;
"
,
lights_lambert_vertex
:
"
vLightWeighting = vec3( 0.0 );
\n
#if MAX_DIR_LIGHTS > 0
\n
transformedNormal = normalize( transformedNormal );
\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
#ifdef WRAP_AROUND
\n
float directionalLightWeightingFull = max( dot( transformedNormal, dirVector ), 0.0 );
\n
float directionalLightWeightingHalf = max( 0.5 * dot( transformedNormal, dirVector ) + 0.5, 0.0 );
\n
vec3 directionalLightWeighting = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );
\n
#else
\n
float directionalLightWeighting = max( dot( transformedNormal, dirVector ), 0.0 );
\n
#endif
\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 lVector = lPosition.xyz - mvPosition.xyz;
\n
float lDistance = 1.0;
\n
if ( pointLightDistance[ i ] > 0.0 )
\n
lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
\n
lVector = normalize( lVector );
\n
#ifdef WRAP_AROUND
\n
float pointLightWeightingFull = max( dot( transformedNormal, lVector ), 0.0 );
\n
float pointLightWeightingHalf = max( 0.5 * dot( transformedNormal, lVector ) + 0.5, 0.0 );
\n
vec3 pointLightWeighting = mix( vec3 ( pointLightWeightingFull ), vec3( pointLightWeightingHalf ), wrapRGB );
\n
#else
\n
float pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );
\n
#endif
\n
vLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;
\n
}
\n
#endif
\n
vLightWeighting = vLightWeighting * diffuse + ambient * ambientLightColor;
"
,
lights_phong_pars_vertex
:
"
#if MAX_POINT_LIGHTS > 0
\n
#ifndef PHONG_PER_PIXEL
\n
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
\n
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
#endif
"
,
lights_phong_vertex
:
"
#if MAX_POINT_LIGHTS > 0
\n
#ifndef PHONG_PER_PIXEL
\n
for( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
\n
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
\n
vec3 lVector = lPosition.xyz - mvPosition.xyz;
\n
float lDistance = 1.0;
\n
if ( pointLightDistance[ i ] > 0.0 )
\n
lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
\n
vPointLight[ i ] = vec4( lVector, lDistance );
\n
}
\n
#endif
\n
#endif
"
,
lights_phong_pars_fragment
:
"
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
#ifdef PHONG_PER_PIXEL
\n
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
\n
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
\n
#else
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
#endif
\n
#ifdef WRAP_AROUND
\n
uniform vec3 wrapRGB;
\n
#endif
\n
varying vec3 vViewPosition;
\n
varying vec3 vNormal;
"
,
lights_phong_fragment
:
"
vec3 normal = normalize( vNormal );
\n
vec3 viewPosition = normalize( vViewPosition );
\n
#if MAX_POINT_LIGHTS > 0
\n
vec3 pointDiffuse = vec3( 0.0 );
\n
vec3 pointSpecular = vec3( 0.0 );
\n
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
\n
#ifdef PHONG_PER_PIXEL
\n
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
\n
vec3 lVector = lPosition.xyz + vViewPosition.xyz;
\n
float lDistance = 1.0;
\n
if ( pointLightDistance[ i ] > 0.0 )
\n
lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
\n
lVector = normalize( lVector );
\n
#else
\n
vec3 lVector = normalize( vPointLight[ i ].xyz );
\n
float lDistance = vPointLight[ i ].w;
\n
#endif
\n
#ifdef WRAP_AROUND
\n
float pointDiffuseWeightFull = max( dot( normal, lVector ), 0.0 );
\n
float pointDiffuseWeightHalf = max( 0.5 * dot( normal, lVector ) + 0.5, 0.0 );
\n
vec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );
\n
#else
\n
float pointDiffuseWeight = max( dot( normal, lVector ), 0.0 );
\n
#endif
\n
pointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;
\n
vec3 pointHalfVector = normalize( lVector + viewPosition );
\n
float pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );
\n
float pointSpecularWeight = max( pow( pointDotNormalHalf, shininess ), 0.0 );
\n
#ifdef PHYSICALLY_BASED_SHADING
\n
vec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( lVector, pointHalfVector ), 5.0 );
\n
pointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;
\n
#else
\n
pointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;
\n
#endif
\n
}
\n
#endif
\n
#if MAX_DIR_LIGHTS > 0
\n
vec3 dirDiffuse = vec3( 0.0 );
\n
vec3 dirSpecular = vec3( 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
#ifdef WRAP_AROUND
\n
float dirDiffuseWeightFull = max( dot( normal, dirVector ), 0.0 );
\n
float dirDiffuseWeightHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );
\n
vec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );
\n
#else
\n
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
\n
#endif
\n
dirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;
\n
vec3 dirHalfVector = normalize( dirVector + viewPosition );
\n
float dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );
\n
float dirSpecularWeight = max( pow( dirDotNormalHalf, shininess ), 0.0 );
\n
#ifdef PHYSICALLY_BASED_SHADING
\n
vec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( dirVector, dirHalfVector ), 5.0 );
\n
dirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;
\n
#else
\n
dirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;
\n
#endif
\n
}
\n
#endif
\n
vec3 totalDiffuse = vec3( 0.0 );
\n
vec3 totalSpecular = vec3( 0.0 );
\n
#if MAX_DIR_LIGHTS > 0
\n
totalDiffuse += dirDiffuse;
\n
totalSpecular += dirSpecular;
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
totalDiffuse += pointDiffuse;
\n
totalSpecular += pointSpecular;
\n
#endif
\n
#ifdef METAL
\n
gl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient + totalSpecular );
\n
#else
\n
gl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient ) + totalSpecular;
\n
#endif
"
,
color_pars_fragment
:
"
#ifdef USE_COLOR
\n
varying vec3 vColor;
\n
#endif
"
,
color_fragment
:
"
#ifdef USE_COLOR
\n
gl_FragColor = gl_FragColor * vec4( vColor, opacity );
\n
#endif
"
,
color_pars_vertex
:
"
#ifdef USE_COLOR
\n
varying vec3 vColor;
\n
#endif
"
,
color_vertex
:
"
#ifdef USE_COLOR
\n
#ifdef GAMMA_INPUT
\n
vColor = color * color;
\n
#else
\n
vColor = color;
\n
#endif
\n
#endif
"
,
skinning_pars_vertex
:
"
#ifdef USE_SKINNING
\n
uniform mat4 boneGlobalMatrices[ MAX_BONES ];
\n
#endif
"
,
skinning_vertex
:
"
#ifdef USE_SKINNING
\n
gl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;
\n
gl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;
\n
gl_Position = projectionMatrix * modelViewMatrix * gl_Position;
\n
#endif
"
,
morphtarget_pars_vertex
:
"
#ifdef USE_MORPHTARGETS
\n
#ifndef USE_MORPHNORMALS
\n
uniform float morphTargetInfluences[ 8 ];
\n
#else
\n
uniform float morphTargetInfluences[ 4 ];
\n
#endif
\n
#endif
"
,
morphtarget_vertex
:
"
#ifdef USE_MORPHTARGETS
\n
vec3 morphed = vec3( 0.0 );
\n
morphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];
\n
morphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];
\n
morphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];
\n
morphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];
\n
#ifndef USE_MORPHNORMALS
\n
morphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];
\n
morphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];
\n
morphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];
\n
morphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];
\n
#endif
\n
morphed += position;
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );
\n
#endif
"
,
default_vertex
:
"
#ifndef USE_MORPHTARGETS
\n
#ifndef USE_SKINNING
\n
gl_Position = projectionMatrix * mvPosition;
\n
#endif
\n
#endif
"
,
morphnormal_vertex
:
"
#ifdef USE_MORPHNORMALS
\n
vec3 morphedNormal = vec3( 0.0 );
\n
morphedNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];
\n
morphedNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];
\n
morphedNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];
\n
morphedNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];
\n
morphedNormal += normal;
\n
vec3 transformedNormal = normal
ize( normalMatrix * morphedNormal );
\n
#else
\n
vec3 transformedNormal = normalize( normalMatrix * normal )
;
\n
#endif
"
,
default_vertex
:
"
#ifndef USE_MORPHTARGETS
\n
#ifndef USE_SKINNING
\n
gl_Position = projectionMatrix * mvPosition;
\n
#endif
\n
#endif
"
,
morphnormal_vertex
:
"
#ifdef USE_MORPHNORMALS
\n
vec3 morphedNormal = vec3( 0.0 );
\n
morphedNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];
\n
morphedNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];
\n
morphedNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];
\n
morphedNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];
\n
morphedNormal += normal;
\n
vec3 transformedNormal = normal
Matrix * morphedNormal;
\n
#else
\n
vec3 transformedNormal = normalMatrix * normal
;
\n
#endif
"
,
shadowmap_pars_fragment
:
"
#ifdef USE_SHADOWMAP
\n
uniform sampler2D shadowMap[ MAX_SHADOWS ];
\n
uniform vec2 shadowMapSize[ MAX_SHADOWS ];
\n
uniform float shadowDarkness[ MAX_SHADOWS ];
\n
uniform float shadowBias[ MAX_SHADOWS ];
\n
varying vec4 vShadowCoord[ MAX_SHADOWS ];
\n
float unpackDepth( const in vec4 rgba_depth ) {
\n
const vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );
\n
float depth = dot( rgba_depth, bit_shift );
\n
return depth;
\n
}
\n
#endif
"
,
shadowmap_fragment
:
"
#ifdef USE_SHADOWMAP
\n
#ifdef SHADOWMAP_DEBUG
\n
vec3 frustumColors[3];
\n
frustumColors[0] = vec3( 1.0, 0.5, 0.0 );
\n
frustumColors[1] = vec3( 0.0, 1.0, 0.8 );
\n
frustumColors[2] = vec3( 0.0, 0.5, 1.0 );
\n
#endif
\n
#ifdef SHADOWMAP_CASCADE
\n
int inFrustumCount = 0;
\n
#endif
\n
float fDepth;
\n
vec3 shadowColor = vec3( 1.0 );
\n
for( int i = 0; i < MAX_SHADOWS; i ++ ) {
\n
vec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;
\n
bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
\n
bool inFrustum = all( inFrustumVec );
\n
#ifdef SHADOWMAP_CASCADE
\n
inFrustumCount += int( inFrustum );
\n
bvec3 frustumTestVec = bvec3( inFrustum, inFrustumCount == 1, shadowCoord.z <= 1.0 );
\n
#else
\n
bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
\n
#endif
\n
bool frustumTest = all( frustumTestVec );
\n
if ( frustumTest ) {
\n
shadowCoord.z += shadowBias[ i ];
\n
#ifdef SHADOWMAP_SOFT
\n
float shadow = 0.0;
\n
const float shadowDelta = 1.0 / 9.0;
\n
float xPixelOffset = 1.0 / shadowMapSize[ i ].x;
\n
float yPixelOffset = 1.0 / shadowMapSize[ i ].y;
\n
float dx0 = -1.25 * xPixelOffset;
\n
float dy0 = -1.25 * yPixelOffset;
\n
float dx1 = 1.25 * xPixelOffset;
\n
float dy1 = 1.25 * yPixelOffset;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );
\n
#else
\n
vec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );
\n
float fDepth = unpackDepth( rgbaDepth );
\n
if ( fDepth < shadowCoord.z )
\n
shadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );
\n
#endif
\n
}
\n
#ifdef SHADOWMAP_DEBUG
\n
#ifdef SHADOWMAP_CASCADE
\n
if ( inFrustum && inFrustumCount == 1 ) gl_FragColor.xyz *= frustumColors[ i ];
\n
#else
\n
if ( inFrustum ) gl_FragColor.xyz *= frustumColors[ i ];
\n
#endif
\n
#endif
\n
}
\n
#ifdef GAMMA_OUTPUT
\n
shadowColor *= shadowColor;
\n
#endif
\n
gl_FragColor.xyz = gl_FragColor.xyz * shadowColor;
\n
#endif
"
,
shadowmap_pars_vertex
:
"
#ifdef USE_SHADOWMAP
\n
varying vec4 vShadowCoord[ MAX_SHADOWS ];
\n
uniform mat4 shadowMatrix[ MAX_SHADOWS ];
\n
#endif
"
,
shadowmap_vertex
:
"
#ifdef USE_SHADOWMAP
\n
for( int i = 0; i < MAX_SHADOWS; i ++ ) {
\n
#ifdef USE_MORPHTARGETS
\n
vShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( morphed, 1.0 );
\n
#else
\n
vShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );
\n
#endif
\n
}
\n
#endif
"
,
alphatest_fragment
:
"
#ifdef ALPHATEST
\n
if ( gl_FragColor.a < ALPHATEST ) discard;
\n
#endif
"
,
linear_to_gamma_fragment
:
"
#ifdef GAMMA_OUTPUT
\n
gl_FragColor.xyz = sqrt( gl_FragColor.xyz );
\n
#endif
"
};
...
...
@@ -227,7 +227,7 @@ THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.S
THREE
.
ShaderChunk
.
morphnormal_vertex
,
THREE
.
ShaderChunk
.
lights_lambert_vertex
,
THREE
.
ShaderChunk
.
skinning_vertex
,
THREE
.
ShaderChunk
.
morphtarget_vertex
,
THREE
.
ShaderChunk
.
default_vertex
,
THREE
.
ShaderChunk
.
shadowmap_vertex
,
"
}
"
].
join
(
"
\n
"
),
fragmentShader
:[
"
uniform float opacity;
\n
varying vec3 vLightWeighting;
"
,
THREE
.
ShaderChunk
.
color_pars_fragment
,
THREE
.
ShaderChunk
.
map_pars_fragment
,
THREE
.
ShaderChunk
.
lightmap_pars_fragment
,
THREE
.
ShaderChunk
.
envmap_pars_fragment
,
THREE
.
ShaderChunk
.
fog_pars_fragment
,
THREE
.
ShaderChunk
.
shadowmap_pars_fragment
,
"
void main() {
\n
gl_FragColor = vec4( vec3 ( 1.0 ), opacity );
"
,
THREE
.
ShaderChunk
.
map_fragment
,
THREE
.
ShaderChunk
.
alphatest_fragment
,
"
gl_FragColor.xyz = gl_FragColor.xyz * vLightWeighting;
"
,
THREE
.
ShaderChunk
.
lightmap_fragment
,
THREE
.
ShaderChunk
.
color_fragment
,
THREE
.
ShaderChunk
.
envmap_fragment
,
THREE
.
ShaderChunk
.
shadowmap_fragment
,
THREE
.
ShaderChunk
.
linear_to_gamma_fragment
,
THREE
.
ShaderChunk
.
fog_fragment
,
"
}
"
].
join
(
"
\n
"
)},
phong
:{
uniforms
:
THREE
.
UniformsUtils
.
merge
([
THREE
.
UniformsLib
.
common
,
THREE
.
UniformsLib
.
fog
,
THREE
.
UniformsLib
.
lights
,
THREE
.
UniformsLib
.
shadowmap
,{
ambient
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
328965
)},
specular
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
1118481
)},
shininess
:{
type
:
"
f
"
,
value
:
30
},
wrapRGB
:{
type
:
"
v3
"
,
value
:
new
THREE
.
Vector3
(
1
,
1
,
1
)}}]),
vertexShader
:[
"
varying vec3 vViewPosition;
\n
varying vec3 vNormal;
"
,
THREE
.
ShaderChunk
.
map_pars_vertex
,
THREE
.
ShaderChunk
.
lightmap_pars_vertex
,
THREE
.
ShaderChunk
.
envmap_pars_vertex
,
THREE
.
ShaderChunk
.
lights_phong_pars_vertex
,
THREE
.
ShaderChunk
.
color_pars_vertex
,
THREE
.
ShaderChunk
.
skinning_pars_vertex
,
THREE
.
ShaderChunk
.
morphtarget_pars_vertex
,
THREE
.
ShaderChunk
.
shadowmap_pars_vertex
,
"
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
THREE
.
ShaderChunk
.
map_vertex
,
THREE
.
ShaderChunk
.
lightmap_vertex
,
THREE
.
ShaderChunk
.
envmap_vertex
,
THREE
.
ShaderChunk
.
color_vertex
,
"
#ifndef USE_ENVMAP
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
#endif
\n
vViewPosition = -mvPosition.xyz;
\n
vec3 transformedNormal = normalMatrix * normal;
\n
vNormal = transformedNormal;
"
,
THREE
.
ShaderChunk
.
lights_phong_vertex
,
THREE
.
ShaderChunk
.
morphtarget_pars_vertex
,
THREE
.
ShaderChunk
.
shadowmap_pars_vertex
,
"
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
THREE
.
ShaderChunk
.
map_vertex
,
THREE
.
ShaderChunk
.
lightmap_vertex
,
THREE
.
ShaderChunk
.
envmap_vertex
,
THREE
.
ShaderChunk
.
color_vertex
,
"
#ifndef USE_ENVMAP
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
#endif
\n
vViewPosition = -mvPosition.xyz;
"
,
THREE
.
ShaderChunk
.
morphnormal_vertex
,
"
vNormal = transformedNormal;
"
,
THREE
.
ShaderChunk
.
lights_phong_vertex
,
THREE
.
ShaderChunk
.
skinning_vertex
,
THREE
.
ShaderChunk
.
morphtarget_vertex
,
THREE
.
ShaderChunk
.
default_vertex
,
THREE
.
ShaderChunk
.
shadowmap_vertex
,
"
}
"
].
join
(
"
\n
"
),
fragmentShader
:[
"
uniform vec3 diffuse;
\n
uniform float opacity;
\n
uniform vec3 ambient;
\n
uniform vec3 specular;
\n
uniform float shininess;
"
,
THREE
.
ShaderChunk
.
color_pars_fragment
,
THREE
.
ShaderChunk
.
map_pars_fragment
,
THREE
.
ShaderChunk
.
lightmap_pars_fragment
,
THREE
.
ShaderChunk
.
envmap_pars_fragment
,
THREE
.
ShaderChunk
.
fog_pars_fragment
,
THREE
.
ShaderChunk
.
lights_phong_pars_fragment
,
THREE
.
ShaderChunk
.
shadowmap_pars_fragment
,
"
void main() {
\n
gl_FragColor = vec4( vec3 ( 1.0 ), opacity );
"
,
THREE
.
ShaderChunk
.
map_fragment
,
THREE
.
ShaderChunk
.
alphatest_fragment
,
THREE
.
ShaderChunk
.
lights_phong_fragment
,
THREE
.
ShaderChunk
.
lightmap_fragment
,
THREE
.
ShaderChunk
.
color_fragment
,
THREE
.
ShaderChunk
.
envmap_fragment
,
THREE
.
ShaderChunk
.
shadowmap_fragment
,
THREE
.
ShaderChunk
.
linear_to_gamma_fragment
,
THREE
.
ShaderChunk
.
fog_fragment
,
"
}
"
].
join
(
"
\n
"
)},
particle_basic
:{
uniforms
:
THREE
.
UniformsUtils
.
merge
([
THREE
.
UniformsLib
.
particle
,
THREE
.
UniformsLib
.
shadowmap
]),
vertexShader
:[
"
uniform float size;
\n
uniform float scale;
"
,
THREE
.
ShaderChunk
.
color_pars_vertex
,
THREE
.
ShaderChunk
.
shadowmap_pars_vertex
,
"
void main() {
"
,
THREE
.
ShaderChunk
.
color_vertex
,
"
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
\n
#ifdef USE_SIZEATTENUATION
\n
gl_PointSize = size * ( scale / length( mvPosition.xyz ) );
\n
#else
\n
gl_PointSize = size;
\n
#endif
\n
gl_Position = projectionMatrix * mvPosition;
"
,
THREE
.
ShaderChunk
.
shadowmap_vertex
,
"
}
"
].
join
(
"
\n
"
),
fragmentShader
:[
"
uniform vec3 psColor;
\n
uniform float opacity;
"
,
...
...
build/custom/ThreeCanvas.js
浏览文件 @
b6bce4f6
...
...
@@ -115,7 +115,7 @@ THREE.MultiplyOperation;this.reflectivity=void 0!==a.reflectivity?a.reflectivity
a
.
wireframeLinejoin
:
"
round
"
;
this
.
vertexColors
=
void
0
!==
a
.
vertexColors
?
a
.
vertexColors
:
!
1
;
this
.
skinning
=
void
0
!==
a
.
skinning
?
a
.
skinning
:
!
1
;
this
.
morphTargets
=
void
0
!==
a
.
morphTargets
?
a
.
morphTargets
:
!
1
;
this
.
morphNormals
=
void
0
!==
a
.
morphNormals
?
a
.
morphNormals
:
!
1
};
THREE
.
MeshLambertMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
MeshLambertMaterial
.
prototype
.
constructor
=
THREE
.
MeshLambertMaterial
;
THREE
.
MeshPhongMaterial
=
function
(
a
){
THREE
.
Material
.
call
(
this
,
a
);
a
=
a
||
{};
this
.
color
=
void
0
!==
a
.
color
?
new
THREE
.
Color
(
a
.
color
):
new
THREE
.
Color
(
16777215
);
this
.
ambient
=
void
0
!==
a
.
ambient
?
new
THREE
.
Color
(
a
.
ambient
):
new
THREE
.
Color
(
16777215
);
this
.
specular
=
void
0
!==
a
.
specular
?
new
THREE
.
Color
(
a
.
specular
):
new
THREE
.
Color
(
1118481
);
this
.
shininess
=
void
0
!==
a
.
shininess
?
a
.
shininess
:
30
;
this
.
metal
=
void
0
!==
a
.
metal
?
a
.
metal
:
!
1
;
this
.
perPixel
=
void
0
!==
a
.
perPixel
?
a
.
perPixel
:
!
1
;
this
.
wrapAround
=
void
0
!==
a
.
wrapAround
?
a
.
wrapAround
:
!
1
;
this
.
wrapRGB
=
new
THREE
.
Vector3
(
1
,
1
,
1
);
this
.
map
=
void
0
!==
a
.
map
?
a
.
map
:
null
;
this
.
lightMap
=
void
0
!==
a
.
lightMap
?
a
.
lightMap
:
null
;
this
.
envMap
=
void
0
!==
a
.
envMap
?
a
.
envMap
:
null
;
this
.
combine
=
void
0
!==
a
.
combine
?
a
.
combine
:
THREE
.
MultiplyOperation
;
this
.
reflectivity
=
void
0
!==
a
.
reflectivity
?
a
.
reflectivity
:
1
;
this
.
refractionRatio
=
void
0
!==
a
.
refractionRatio
?
a
.
refractionRatio
:
0.98
;
this
.
fog
=
void
0
!==
a
.
fog
?
a
.
fog
:
!
0
;
this
.
shading
=
void
0
!==
a
.
shading
?
a
.
shading
:
THREE
.
SmoothShading
;
this
.
wireframe
=
void
0
!==
a
.
wireframe
?
a
.
wireframe
:
!
1
;
this
.
wireframeLinewidth
=
void
0
!==
a
.
wireframeLinewidth
?
a
.
wireframeLinewidth
:
1
;
this
.
wireframeLinecap
=
void
0
!==
a
.
wireframeLinecap
?
a
.
wireframeLinecap
:
"
round
"
;
this
.
wireframeLinejoin
=
void
0
!==
a
.
wireframeLinejoin
?
a
.
wireframeLinejoin
:
"
round
"
;
this
.
vertexColors
=
void
0
!==
a
.
vertexColors
?
a
.
vertexColors
:
!
1
;
this
.
skinning
=
void
0
!==
a
.
skinning
?
a
.
skinning
:
!
1
;
this
.
morphTargets
=
void
0
!==
a
.
morphTargets
?
a
.
morphTargets
:
!
1
};
THREE
.
MeshPhongMaterial
.
prototype
=
new
THREE
.
Material
;
!
1
;
this
.
wireframeLinewidth
=
void
0
!==
a
.
wireframeLinewidth
?
a
.
wireframeLinewidth
:
1
;
this
.
wireframeLinecap
=
void
0
!==
a
.
wireframeLinecap
?
a
.
wireframeLinecap
:
"
round
"
;
this
.
wireframeLinejoin
=
void
0
!==
a
.
wireframeLinejoin
?
a
.
wireframeLinejoin
:
"
round
"
;
this
.
vertexColors
=
void
0
!==
a
.
vertexColors
?
a
.
vertexColors
:
!
1
;
this
.
skinning
=
void
0
!==
a
.
skinning
?
a
.
skinning
:
!
1
;
this
.
morphTargets
=
void
0
!==
a
.
morphTargets
?
a
.
morphTargets
:
!
1
;
this
.
morphNormals
=
void
0
!==
a
.
morphNormals
?
a
.
morphNormals
:
!
1
};
THREE
.
MeshPhongMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
MeshPhongMaterial
.
prototype
.
constructor
=
THREE
.
MeshPhongMaterial
;
THREE
.
MeshDepthMaterial
=
function
(
a
){
THREE
.
Material
.
call
(
this
,
a
);
a
=
a
||
{};
this
.
shading
=
void
0
!==
a
.
shading
?
a
.
shading
:
THREE
.
SmoothShading
;
this
.
wireframe
=
void
0
!==
a
.
wireframe
?
a
.
wireframe
:
!
1
;
this
.
wireframeLinewidth
=
void
0
!==
a
.
wireframeLinewidth
?
a
.
wireframeLinewidth
:
1
};
THREE
.
MeshDepthMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
MeshDepthMaterial
.
prototype
.
constructor
=
THREE
.
MeshDepthMaterial
;
THREE
.
MeshNormalMaterial
=
function
(
a
){
THREE
.
Material
.
call
(
this
,
a
);
a
=
a
||
{};
this
.
shading
=
a
.
shading
?
a
.
shading
:
THREE
.
FlatShading
;
this
.
wireframe
=
a
.
wireframe
?
a
.
wireframe
:
!
1
;
this
.
wireframeLinewidth
=
a
.
wireframeLinewidth
?
a
.
wireframeLinewidth
:
1
};
THREE
.
MeshNormalMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
MeshNormalMaterial
.
prototype
.
constructor
=
THREE
.
MeshNormalMaterial
;
THREE
.
MeshFaceMaterial
=
function
(){};
THREE
.
ParticleBasicMaterial
=
function
(
a
){
THREE
.
Material
.
call
(
this
,
a
);
a
=
a
||
{};
this
.
color
=
void
0
!==
a
.
color
?
new
THREE
.
Color
(
a
.
color
):
new
THREE
.
Color
(
16777215
);
this
.
map
=
void
0
!==
a
.
map
?
a
.
map
:
null
;
this
.
size
=
void
0
!==
a
.
size
?
a
.
size
:
1
;
this
.
sizeAttenuation
=
void
0
!==
a
.
sizeAttenuation
?
a
.
sizeAttenuation
:
!
0
;
this
.
vertexColors
=
void
0
!==
a
.
vertexColors
?
a
.
vertexColors
:
!
1
;
this
.
fog
=
void
0
!==
a
.
fog
?
a
.
fog
:
!
0
};
THREE
.
ParticleBasicMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
ParticleBasicMaterial
.
prototype
.
constructor
=
THREE
.
ParticleBasicMaterial
;
...
...
build/custom/ThreeSVG.js
浏览文件 @
b6bce4f6
...
...
@@ -115,7 +115,7 @@ THREE.MultiplyOperation;this.reflectivity=void 0!==a.reflectivity?a.reflectivity
a
.
wireframeLinejoin
:
"
round
"
;
this
.
vertexColors
=
void
0
!==
a
.
vertexColors
?
a
.
vertexColors
:
!
1
;
this
.
skinning
=
void
0
!==
a
.
skinning
?
a
.
skinning
:
!
1
;
this
.
morphTargets
=
void
0
!==
a
.
morphTargets
?
a
.
morphTargets
:
!
1
;
this
.
morphNormals
=
void
0
!==
a
.
morphNormals
?
a
.
morphNormals
:
!
1
};
THREE
.
MeshLambertMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
MeshLambertMaterial
.
prototype
.
constructor
=
THREE
.
MeshLambertMaterial
;
THREE
.
MeshPhongMaterial
=
function
(
a
){
THREE
.
Material
.
call
(
this
,
a
);
a
=
a
||
{};
this
.
color
=
void
0
!==
a
.
color
?
new
THREE
.
Color
(
a
.
color
):
new
THREE
.
Color
(
16777215
);
this
.
ambient
=
void
0
!==
a
.
ambient
?
new
THREE
.
Color
(
a
.
ambient
):
new
THREE
.
Color
(
16777215
);
this
.
specular
=
void
0
!==
a
.
specular
?
new
THREE
.
Color
(
a
.
specular
):
new
THREE
.
Color
(
1118481
);
this
.
shininess
=
void
0
!==
a
.
shininess
?
a
.
shininess
:
30
;
this
.
metal
=
void
0
!==
a
.
metal
?
a
.
metal
:
!
1
;
this
.
perPixel
=
void
0
!==
a
.
perPixel
?
a
.
perPixel
:
!
1
;
this
.
wrapAround
=
void
0
!==
a
.
wrapAround
?
a
.
wrapAround
:
!
1
;
this
.
wrapRGB
=
new
THREE
.
Vector3
(
1
,
1
,
1
);
this
.
map
=
void
0
!==
a
.
map
?
a
.
map
:
null
;
this
.
lightMap
=
void
0
!==
a
.
lightMap
?
a
.
lightMap
:
null
;
this
.
envMap
=
void
0
!==
a
.
envMap
?
a
.
envMap
:
null
;
this
.
combine
=
void
0
!==
a
.
combine
?
a
.
combine
:
THREE
.
MultiplyOperation
;
this
.
reflectivity
=
void
0
!==
a
.
reflectivity
?
a
.
reflectivity
:
1
;
this
.
refractionRatio
=
void
0
!==
a
.
refractionRatio
?
a
.
refractionRatio
:
0.98
;
this
.
fog
=
void
0
!==
a
.
fog
?
a
.
fog
:
!
0
;
this
.
shading
=
void
0
!==
a
.
shading
?
a
.
shading
:
THREE
.
SmoothShading
;
this
.
wireframe
=
void
0
!==
a
.
wireframe
?
a
.
wireframe
:
!
1
;
this
.
wireframeLinewidth
=
void
0
!==
a
.
wireframeLinewidth
?
a
.
wireframeLinewidth
:
1
;
this
.
wireframeLinecap
=
void
0
!==
a
.
wireframeLinecap
?
a
.
wireframeLinecap
:
"
round
"
;
this
.
wireframeLinejoin
=
void
0
!==
a
.
wireframeLinejoin
?
a
.
wireframeLinejoin
:
"
round
"
;
this
.
vertexColors
=
void
0
!==
a
.
vertexColors
?
a
.
vertexColors
:
!
1
;
this
.
skinning
=
void
0
!==
a
.
skinning
?
a
.
skinning
:
!
1
;
this
.
morphTargets
=
void
0
!==
a
.
morphTargets
?
a
.
morphTargets
:
!
1
};
THREE
.
MeshPhongMaterial
.
prototype
=
new
THREE
.
Material
;
!
1
;
this
.
wireframeLinewidth
=
void
0
!==
a
.
wireframeLinewidth
?
a
.
wireframeLinewidth
:
1
;
this
.
wireframeLinecap
=
void
0
!==
a
.
wireframeLinecap
?
a
.
wireframeLinecap
:
"
round
"
;
this
.
wireframeLinejoin
=
void
0
!==
a
.
wireframeLinejoin
?
a
.
wireframeLinejoin
:
"
round
"
;
this
.
vertexColors
=
void
0
!==
a
.
vertexColors
?
a
.
vertexColors
:
!
1
;
this
.
skinning
=
void
0
!==
a
.
skinning
?
a
.
skinning
:
!
1
;
this
.
morphTargets
=
void
0
!==
a
.
morphTargets
?
a
.
morphTargets
:
!
1
;
this
.
morphNormals
=
void
0
!==
a
.
morphNormals
?
a
.
morphNormals
:
!
1
};
THREE
.
MeshPhongMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
MeshPhongMaterial
.
prototype
.
constructor
=
THREE
.
MeshPhongMaterial
;
THREE
.
MeshDepthMaterial
=
function
(
a
){
THREE
.
Material
.
call
(
this
,
a
);
a
=
a
||
{};
this
.
shading
=
void
0
!==
a
.
shading
?
a
.
shading
:
THREE
.
SmoothShading
;
this
.
wireframe
=
void
0
!==
a
.
wireframe
?
a
.
wireframe
:
!
1
;
this
.
wireframeLinewidth
=
void
0
!==
a
.
wireframeLinewidth
?
a
.
wireframeLinewidth
:
1
};
THREE
.
MeshDepthMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
MeshDepthMaterial
.
prototype
.
constructor
=
THREE
.
MeshDepthMaterial
;
THREE
.
MeshNormalMaterial
=
function
(
a
){
THREE
.
Material
.
call
(
this
,
a
);
a
=
a
||
{};
this
.
shading
=
a
.
shading
?
a
.
shading
:
THREE
.
FlatShading
;
this
.
wireframe
=
a
.
wireframe
?
a
.
wireframe
:
!
1
;
this
.
wireframeLinewidth
=
a
.
wireframeLinewidth
?
a
.
wireframeLinewidth
:
1
};
THREE
.
MeshNormalMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
MeshNormalMaterial
.
prototype
.
constructor
=
THREE
.
MeshNormalMaterial
;
THREE
.
MeshFaceMaterial
=
function
(){};
THREE
.
ParticleBasicMaterial
=
function
(
a
){
THREE
.
Material
.
call
(
this
,
a
);
a
=
a
||
{};
this
.
color
=
void
0
!==
a
.
color
?
new
THREE
.
Color
(
a
.
color
):
new
THREE
.
Color
(
16777215
);
this
.
map
=
void
0
!==
a
.
map
?
a
.
map
:
null
;
this
.
size
=
void
0
!==
a
.
size
?
a
.
size
:
1
;
this
.
sizeAttenuation
=
void
0
!==
a
.
sizeAttenuation
?
a
.
sizeAttenuation
:
!
0
;
this
.
vertexColors
=
void
0
!==
a
.
vertexColors
?
a
.
vertexColors
:
!
1
;
this
.
fog
=
void
0
!==
a
.
fog
?
a
.
fog
:
!
0
};
THREE
.
ParticleBasicMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
ParticleBasicMaterial
.
prototype
.
constructor
=
THREE
.
ParticleBasicMaterial
;
...
...
build/custom/ThreeWebGL.js
浏览文件 @
b6bce4f6
...
...
@@ -120,7 +120,7 @@ THREE.MultiplyOperation;this.reflectivity=void 0!==a.reflectivity?a.reflectivity
a
.
wireframeLinejoin
:
"
round
"
;
this
.
vertexColors
=
void
0
!==
a
.
vertexColors
?
a
.
vertexColors
:
!
1
;
this
.
skinning
=
void
0
!==
a
.
skinning
?
a
.
skinning
:
!
1
;
this
.
morphTargets
=
void
0
!==
a
.
morphTargets
?
a
.
morphTargets
:
!
1
;
this
.
morphNormals
=
void
0
!==
a
.
morphNormals
?
a
.
morphNormals
:
!
1
};
THREE
.
MeshLambertMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
MeshLambertMaterial
.
prototype
.
constructor
=
THREE
.
MeshLambertMaterial
;
THREE
.
MeshPhongMaterial
=
function
(
a
){
THREE
.
Material
.
call
(
this
,
a
);
a
=
a
||
{};
this
.
color
=
void
0
!==
a
.
color
?
new
THREE
.
Color
(
a
.
color
):
new
THREE
.
Color
(
16777215
);
this
.
ambient
=
void
0
!==
a
.
ambient
?
new
THREE
.
Color
(
a
.
ambient
):
new
THREE
.
Color
(
16777215
);
this
.
specular
=
void
0
!==
a
.
specular
?
new
THREE
.
Color
(
a
.
specular
):
new
THREE
.
Color
(
1118481
);
this
.
shininess
=
void
0
!==
a
.
shininess
?
a
.
shininess
:
30
;
this
.
metal
=
void
0
!==
a
.
metal
?
a
.
metal
:
!
1
;
this
.
perPixel
=
void
0
!==
a
.
perPixel
?
a
.
perPixel
:
!
1
;
this
.
wrapAround
=
void
0
!==
a
.
wrapAround
?
a
.
wrapAround
:
!
1
;
this
.
wrapRGB
=
new
THREE
.
Vector3
(
1
,
1
,
1
);
this
.
map
=
void
0
!==
a
.
map
?
a
.
map
:
null
;
this
.
lightMap
=
void
0
!==
a
.
lightMap
?
a
.
lightMap
:
null
;
this
.
envMap
=
void
0
!==
a
.
envMap
?
a
.
envMap
:
null
;
this
.
combine
=
void
0
!==
a
.
combine
?
a
.
combine
:
THREE
.
MultiplyOperation
;
this
.
reflectivity
=
void
0
!==
a
.
reflectivity
?
a
.
reflectivity
:
1
;
this
.
refractionRatio
=
void
0
!==
a
.
refractionRatio
?
a
.
refractionRatio
:
0.98
;
this
.
fog
=
void
0
!==
a
.
fog
?
a
.
fog
:
!
0
;
this
.
shading
=
void
0
!==
a
.
shading
?
a
.
shading
:
THREE
.
SmoothShading
;
this
.
wireframe
=
void
0
!==
a
.
wireframe
?
a
.
wireframe
:
!
1
;
this
.
wireframeLinewidth
=
void
0
!==
a
.
wireframeLinewidth
?
a
.
wireframeLinewidth
:
1
;
this
.
wireframeLinecap
=
void
0
!==
a
.
wireframeLinecap
?
a
.
wireframeLinecap
:
"
round
"
;
this
.
wireframeLinejoin
=
void
0
!==
a
.
wireframeLinejoin
?
a
.
wireframeLinejoin
:
"
round
"
;
this
.
vertexColors
=
void
0
!==
a
.
vertexColors
?
a
.
vertexColors
:
!
1
;
this
.
skinning
=
void
0
!==
a
.
skinning
?
a
.
skinning
:
!
1
;
this
.
morphTargets
=
void
0
!==
a
.
morphTargets
?
a
.
morphTargets
:
!
1
};
THREE
.
MeshPhongMaterial
.
prototype
=
new
THREE
.
Material
;
!
1
;
this
.
wireframeLinewidth
=
void
0
!==
a
.
wireframeLinewidth
?
a
.
wireframeLinewidth
:
1
;
this
.
wireframeLinecap
=
void
0
!==
a
.
wireframeLinecap
?
a
.
wireframeLinecap
:
"
round
"
;
this
.
wireframeLinejoin
=
void
0
!==
a
.
wireframeLinejoin
?
a
.
wireframeLinejoin
:
"
round
"
;
this
.
vertexColors
=
void
0
!==
a
.
vertexColors
?
a
.
vertexColors
:
!
1
;
this
.
skinning
=
void
0
!==
a
.
skinning
?
a
.
skinning
:
!
1
;
this
.
morphTargets
=
void
0
!==
a
.
morphTargets
?
a
.
morphTargets
:
!
1
;
this
.
morphNormals
=
void
0
!==
a
.
morphNormals
?
a
.
morphNormals
:
!
1
};
THREE
.
MeshPhongMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
MeshPhongMaterial
.
prototype
.
constructor
=
THREE
.
MeshPhongMaterial
;
THREE
.
MeshDepthMaterial
=
function
(
a
){
THREE
.
Material
.
call
(
this
,
a
);
a
=
a
||
{};
this
.
shading
=
void
0
!==
a
.
shading
?
a
.
shading
:
THREE
.
SmoothShading
;
this
.
wireframe
=
void
0
!==
a
.
wireframe
?
a
.
wireframe
:
!
1
;
this
.
wireframeLinewidth
=
void
0
!==
a
.
wireframeLinewidth
?
a
.
wireframeLinewidth
:
1
};
THREE
.
MeshDepthMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
MeshDepthMaterial
.
prototype
.
constructor
=
THREE
.
MeshDepthMaterial
;
THREE
.
MeshNormalMaterial
=
function
(
a
){
THREE
.
Material
.
call
(
this
,
a
);
a
=
a
||
{};
this
.
shading
=
a
.
shading
?
a
.
shading
:
THREE
.
FlatShading
;
this
.
wireframe
=
a
.
wireframe
?
a
.
wireframe
:
!
1
;
this
.
wireframeLinewidth
=
a
.
wireframeLinewidth
?
a
.
wireframeLinewidth
:
1
};
THREE
.
MeshNormalMaterial
.
prototype
=
new
THREE
.
Material
;
THREE
.
MeshNormalMaterial
.
prototype
.
constructor
=
THREE
.
MeshNormalMaterial
;
THREE
.
MeshFaceMaterial
=
function
(){};
THREE
.
MeshShaderMaterial
=
function
(
a
){
console
.
warn
(
"
DEPRECATED: MeshShaderMaterial() is now ShaderMaterial().
"
);
return
new
THREE
.
ShaderMaterial
(
a
)};
...
...
@@ -158,13 +158,13 @@ THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#i
envmap_fragment
:
"
#ifdef USE_ENVMAP
\n
vec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * vReflect.x, vReflect.yz ) );
\n
#ifdef GAMMA_INPUT
\n
cubeColor.xyz *= cubeColor.xyz;
\n
#endif
\n
if ( combine == 1 ) {
\n
gl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity );
\n
} else {
\n
gl_FragColor.xyz = gl_FragColor.xyz * cubeColor.xyz;
\n
}
\n
#endif
"
,
envmap_pars_vertex
:
"
#ifdef USE_ENVMAP
\n
varying vec3 vReflect;
\n
uniform float refractionRatio;
\n
uniform bool useRefract;
\n
#endif
"
,
envmap_vertex
:
"
#ifdef USE_ENVMAP
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
vec3 nWorld = mat3( objectMatrix[ 0 ].xyz, objectMatrix[ 1 ].xyz, objectMatrix[ 2 ].xyz ) * normal;
\n
if ( useRefract ) {
\n
vReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );
\n
} else {
\n
vReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );
\n
}
\n
#endif
"
,
map_particle_pars_fragment
:
"
#ifdef USE_MAP
\n
uniform sampler2D map;
\n
#endif
"
,
map_particle_fragment
:
"
#ifdef USE_MAP
\n
gl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );
\n
#endif
"
,
map_pars_vertex
:
"
#ifdef USE_MAP
\n
varying vec2 vUv;
\n
uniform vec4 offsetRepeat;
\n
#endif
"
,
map_pars_fragment
:
"
#ifdef USE_MAP
\n
varying vec2 vUv;
\n
uniform sampler2D map;
\n
#endif
"
,
map_vertex
:
"
#ifdef USE_MAP
\n
vUv = uv * offsetRepeat.zw + offsetRepeat.xy;
\n
#endif
"
,
map_fragment
:
"
#ifdef USE_MAP
\n
#ifdef GAMMA_INPUT
\n
vec4 texelColor = texture2D( map, vUv );
\n
texelColor.xyz *= texelColor.xyz;
\n
gl_FragColor = gl_FragColor * texelColor;
\n
#else
\n
gl_FragColor = gl_FragColor * texture2D( map, vUv );
\n
#endif
\n
#endif
"
,
lightmap_pars_fragment
:
"
#ifdef USE_LIGHTMAP
\n
varying vec2 vUv2;
\n
uniform sampler2D lightMap;
\n
#endif
"
,
lightmap_pars_vertex
:
"
#ifdef USE_LIGHTMAP
\n
varying vec2 vUv2;
\n
#endif
"
,
lightmap_fragment
:
"
#ifdef USE_LIGHTMAP
\n
gl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );
\n
#endif
"
,
lightmap_vertex
:
"
#ifdef USE_LIGHTMAP
\n
vUv2 = uv2;
\n
#endif
"
,
lights_lambert_pars_vertex
:
"
uniform vec3 ambient;
\n
uniform vec3 diffuse;
\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
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
\n
#endif
\n
#ifdef WRAP_AROUND
\n
uniform vec3 wrapRGB;
\n
#endif
"
,
lights_lambert_vertex
:
"
vLightWeighting = vec3( 0.0 );
\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
vec3 dirVector = normalize( lDirection.xyz );
\n
#ifdef WRAP_AROUND
\n
float directionalLightWeightingFull = max( dot( transformedNormal, dirVector ), 0.0 );
\n
float directionalLightWeightingHalf = max( 0.5 * dot( transformedNormal, dirVector ) + 0.5, 0.0 );
\n
vec3 directionalLightWeighting = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );
\n
#else
\n
float directionalLightWeighting = max( dot( transformedNormal, dirVector ), 0.0 );
\n
#endif
\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 lVector = lPosition.xyz - mvPosition.xyz;
\n
float lDistance = 1.0;
\n
if ( pointLightDistance[ i ] > 0.0 )
\n
lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
\n
lVector = normalize( lVector );
\n
#ifdef WRAP_AROUND
\n
float pointLightWeightingFull = max( dot( transformedNormal, lVector ), 0.0 );
\n
float pointLightWeightingHalf = max( 0.5 * dot( transformedNormal, lVector ) + 0.5, 0.0 );
\n
vec3 pointLightWeighting = mix( vec3 ( pointLightWeightingFull ), vec3( pointLightWeightingHalf ), wrapRGB );
\n
#else
\n
float pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );
\n
#endif
\n
vLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;
\n
}
\n
#endif
\n
vLightWeighting = vLightWeighting * diffuse + ambient * ambientLightColor;
"
,
lights_lambert_vertex
:
"
vLightWeighting = vec3( 0.0 );
\n
#if MAX_DIR_LIGHTS > 0
\n
transformedNormal = normalize( transformedNormal );
\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
#ifdef WRAP_AROUND
\n
float directionalLightWeightingFull = max( dot( transformedNormal, dirVector ), 0.0 );
\n
float directionalLightWeightingHalf = max( 0.5 * dot( transformedNormal, dirVector ) + 0.5, 0.0 );
\n
vec3 directionalLightWeighting = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );
\n
#else
\n
float directionalLightWeighting = max( dot( transformedNormal, dirVector ), 0.0 );
\n
#endif
\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 lVector = lPosition.xyz - mvPosition.xyz;
\n
float lDistance = 1.0;
\n
if ( pointLightDistance[ i ] > 0.0 )
\n
lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
\n
lVector = normalize( lVector );
\n
#ifdef WRAP_AROUND
\n
float pointLightWeightingFull = max( dot( transformedNormal, lVector ), 0.0 );
\n
float pointLightWeightingHalf = max( 0.5 * dot( transformedNormal, lVector ) + 0.5, 0.0 );
\n
vec3 pointLightWeighting = mix( vec3 ( pointLightWeightingFull ), vec3( pointLightWeightingHalf ), wrapRGB );
\n
#else
\n
float pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );
\n
#endif
\n
vLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;
\n
}
\n
#endif
\n
vLightWeighting = vLightWeighting * diffuse + ambient * ambientLightColor;
"
,
lights_phong_pars_vertex
:
"
#if MAX_POINT_LIGHTS > 0
\n
#ifndef PHONG_PER_PIXEL
\n
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
\n
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
#endif
"
,
lights_phong_vertex
:
"
#if MAX_POINT_LIGHTS > 0
\n
#ifndef PHONG_PER_PIXEL
\n
for( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
\n
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
\n
vec3 lVector = lPosition.xyz - mvPosition.xyz;
\n
float lDistance = 1.0;
\n
if ( pointLightDistance[ i ] > 0.0 )
\n
lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
\n
vPointLight[ i ] = vec4( lVector, lDistance );
\n
}
\n
#endif
\n
#endif
"
,
lights_phong_pars_fragment
:
"
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
#ifdef PHONG_PER_PIXEL
\n
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
\n
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
\n
#else
\n
varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
\n
#endif
\n
#endif
\n
#ifdef WRAP_AROUND
\n
uniform vec3 wrapRGB;
\n
#endif
\n
varying vec3 vViewPosition;
\n
varying vec3 vNormal;
"
,
lights_phong_fragment
:
"
vec3 normal = normalize( vNormal );
\n
vec3 viewPosition = normalize( vViewPosition );
\n
#if MAX_POINT_LIGHTS > 0
\n
vec3 pointDiffuse = vec3( 0.0 );
\n
vec3 pointSpecular = vec3( 0.0 );
\n
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
\n
#ifdef PHONG_PER_PIXEL
\n
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
\n
vec3 lVector = lPosition.xyz + vViewPosition.xyz;
\n
float lDistance = 1.0;
\n
if ( pointLightDistance[ i ] > 0.0 )
\n
lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
\n
lVector = normalize( lVector );
\n
#else
\n
vec3 lVector = normalize( vPointLight[ i ].xyz );
\n
float lDistance = vPointLight[ i ].w;
\n
#endif
\n
#ifdef WRAP_AROUND
\n
float pointDiffuseWeightFull = max( dot( normal, lVector ), 0.0 );
\n
float pointDiffuseWeightHalf = max( 0.5 * dot( normal, lVector ) + 0.5, 0.0 );
\n
vec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );
\n
#else
\n
float pointDiffuseWeight = max( dot( normal, lVector ), 0.0 );
\n
#endif
\n
pointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;
\n
vec3 pointHalfVector = normalize( lVector + viewPosition );
\n
float pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );
\n
float pointSpecularWeight = max( pow( pointDotNormalHalf, shininess ), 0.0 );
\n
#ifdef PHYSICALLY_BASED_SHADING
\n
vec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( lVector, pointHalfVector ), 5.0 );
\n
pointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;
\n
#else
\n
pointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;
\n
#endif
\n
}
\n
#endif
\n
#if MAX_DIR_LIGHTS > 0
\n
vec3 dirDiffuse = vec3( 0.0 );
\n
vec3 dirSpecular = vec3( 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
#ifdef WRAP_AROUND
\n
float dirDiffuseWeightFull = max( dot( normal, dirVector ), 0.0 );
\n
float dirDiffuseWeightHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );
\n
vec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );
\n
#else
\n
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
\n
#endif
\n
dirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;
\n
vec3 dirHalfVector = normalize( dirVector + viewPosition );
\n
float dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );
\n
float dirSpecularWeight = max( pow( dirDotNormalHalf, shininess ), 0.0 );
\n
#ifdef PHYSICALLY_BASED_SHADING
\n
vec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( dirVector, dirHalfVector ), 5.0 );
\n
dirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;
\n
#else
\n
dirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;
\n
#endif
\n
}
\n
#endif
\n
vec3 totalDiffuse = vec3( 0.0 );
\n
vec3 totalSpecular = vec3( 0.0 );
\n
#if MAX_DIR_LIGHTS > 0
\n
totalDiffuse += dirDiffuse;
\n
totalSpecular += dirSpecular;
\n
#endif
\n
#if MAX_POINT_LIGHTS > 0
\n
totalDiffuse += pointDiffuse;
\n
totalSpecular += pointSpecular;
\n
#endif
\n
#ifdef METAL
\n
gl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient + totalSpecular );
\n
#else
\n
gl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient ) + totalSpecular;
\n
#endif
"
,
color_pars_fragment
:
"
#ifdef USE_COLOR
\n
varying vec3 vColor;
\n
#endif
"
,
color_fragment
:
"
#ifdef USE_COLOR
\n
gl_FragColor = gl_FragColor * vec4( vColor, opacity );
\n
#endif
"
,
color_pars_vertex
:
"
#ifdef USE_COLOR
\n
varying vec3 vColor;
\n
#endif
"
,
color_vertex
:
"
#ifdef USE_COLOR
\n
#ifdef GAMMA_INPUT
\n
vColor = color * color;
\n
#else
\n
vColor = color;
\n
#endif
\n
#endif
"
,
skinning_pars_vertex
:
"
#ifdef USE_SKINNING
\n
uniform mat4 boneGlobalMatrices[ MAX_BONES ];
\n
#endif
"
,
skinning_vertex
:
"
#ifdef USE_SKINNING
\n
gl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;
\n
gl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;
\n
gl_Position = projectionMatrix * modelViewMatrix * gl_Position;
\n
#endif
"
,
morphtarget_pars_vertex
:
"
#ifdef USE_MORPHTARGETS
\n
#ifndef USE_MORPHNORMALS
\n
uniform float morphTargetInfluences[ 8 ];
\n
#else
\n
uniform float morphTargetInfluences[ 4 ];
\n
#endif
\n
#endif
"
,
morphtarget_vertex
:
"
#ifdef USE_MORPHTARGETS
\n
vec3 morphed = vec3( 0.0 );
\n
morphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];
\n
morphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];
\n
morphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];
\n
morphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];
\n
#ifndef USE_MORPHNORMALS
\n
morphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];
\n
morphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];
\n
morphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];
\n
morphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];
\n
#endif
\n
morphed += position;
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );
\n
#endif
"
,
default_vertex
:
"
#ifndef USE_MORPHTARGETS
\n
#ifndef USE_SKINNING
\n
gl_Position = projectionMatrix * mvPosition;
\n
#endif
\n
#endif
"
,
morphnormal_vertex
:
"
#ifdef USE_MORPHNORMALS
\n
vec3 morphedNormal = vec3( 0.0 );
\n
morphedNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];
\n
morphedNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];
\n
morphedNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];
\n
morphedNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];
\n
morphedNormal += normal;
\n
vec3 transformedNormal = normal
ize( normalMatrix * morphedNormal );
\n
#else
\n
vec3 transformedNormal = normalize( normalMatrix * normal )
;
\n
#endif
"
,
default_vertex
:
"
#ifndef USE_MORPHTARGETS
\n
#ifndef USE_SKINNING
\n
gl_Position = projectionMatrix * mvPosition;
\n
#endif
\n
#endif
"
,
morphnormal_vertex
:
"
#ifdef USE_MORPHNORMALS
\n
vec3 morphedNormal = vec3( 0.0 );
\n
morphedNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];
\n
morphedNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];
\n
morphedNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];
\n
morphedNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];
\n
morphedNormal += normal;
\n
vec3 transformedNormal = normal
Matrix * morphedNormal;
\n
#else
\n
vec3 transformedNormal = normalMatrix * normal
;
\n
#endif
"
,
shadowmap_pars_fragment
:
"
#ifdef USE_SHADOWMAP
\n
uniform sampler2D shadowMap[ MAX_SHADOWS ];
\n
uniform vec2 shadowMapSize[ MAX_SHADOWS ];
\n
uniform float shadowDarkness[ MAX_SHADOWS ];
\n
uniform float shadowBias[ MAX_SHADOWS ];
\n
varying vec4 vShadowCoord[ MAX_SHADOWS ];
\n
float unpackDepth( const in vec4 rgba_depth ) {
\n
const vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );
\n
float depth = dot( rgba_depth, bit_shift );
\n
return depth;
\n
}
\n
#endif
"
,
shadowmap_fragment
:
"
#ifdef USE_SHADOWMAP
\n
#ifdef SHADOWMAP_DEBUG
\n
vec3 frustumColors[3];
\n
frustumColors[0] = vec3( 1.0, 0.5, 0.0 );
\n
frustumColors[1] = vec3( 0.0, 1.0, 0.8 );
\n
frustumColors[2] = vec3( 0.0, 0.5, 1.0 );
\n
#endif
\n
#ifdef SHADOWMAP_CASCADE
\n
int inFrustumCount = 0;
\n
#endif
\n
float fDepth;
\n
vec3 shadowColor = vec3( 1.0 );
\n
for( int i = 0; i < MAX_SHADOWS; i ++ ) {
\n
vec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;
\n
bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
\n
bool inFrustum = all( inFrustumVec );
\n
#ifdef SHADOWMAP_CASCADE
\n
inFrustumCount += int( inFrustum );
\n
bvec3 frustumTestVec = bvec3( inFrustum, inFrustumCount == 1, shadowCoord.z <= 1.0 );
\n
#else
\n
bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
\n
#endif
\n
bool frustumTest = all( frustumTestVec );
\n
if ( frustumTest ) {
\n
shadowCoord.z += shadowBias[ i ];
\n
#ifdef SHADOWMAP_SOFT
\n
float shadow = 0.0;
\n
const float shadowDelta = 1.0 / 9.0;
\n
float xPixelOffset = 1.0 / shadowMapSize[ i ].x;
\n
float yPixelOffset = 1.0 / shadowMapSize[ i ].y;
\n
float dx0 = -1.25 * xPixelOffset;
\n
float dy0 = -1.25 * yPixelOffset;
\n
float dx1 = 1.25 * xPixelOffset;
\n
float dy1 = 1.25 * yPixelOffset;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );
\n
if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
\n
shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );
\n
#else
\n
vec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );
\n
float fDepth = unpackDepth( rgbaDepth );
\n
if ( fDepth < shadowCoord.z )
\n
shadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );
\n
#endif
\n
}
\n
#ifdef SHADOWMAP_DEBUG
\n
#ifdef SHADOWMAP_CASCADE
\n
if ( inFrustum && inFrustumCount == 1 ) gl_FragColor.xyz *= frustumColors[ i ];
\n
#else
\n
if ( inFrustum ) gl_FragColor.xyz *= frustumColors[ i ];
\n
#endif
\n
#endif
\n
}
\n
#ifdef GAMMA_OUTPUT
\n
shadowColor *= shadowColor;
\n
#endif
\n
gl_FragColor.xyz = gl_FragColor.xyz * shadowColor;
\n
#endif
"
,
shadowmap_pars_vertex
:
"
#ifdef USE_SHADOWMAP
\n
varying vec4 vShadowCoord[ MAX_SHADOWS ];
\n
uniform mat4 shadowMatrix[ MAX_SHADOWS ];
\n
#endif
"
,
shadowmap_vertex
:
"
#ifdef USE_SHADOWMAP
\n
for( int i = 0; i < MAX_SHADOWS; i ++ ) {
\n
#ifdef USE_MORPHTARGETS
\n
vShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( morphed, 1.0 );
\n
#else
\n
vShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );
\n
#endif
\n
}
\n
#endif
"
,
alphatest_fragment
:
"
#ifdef ALPHATEST
\n
if ( gl_FragColor.a < ALPHATEST ) discard;
\n
#endif
"
,
linear_to_gamma_fragment
:
"
#ifdef GAMMA_OUTPUT
\n
gl_FragColor.xyz = sqrt( gl_FragColor.xyz );
\n
#endif
"
};
...
...
@@ -181,7 +181,7 @@ THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.S
THREE
.
ShaderChunk
.
morphnormal_vertex
,
THREE
.
ShaderChunk
.
lights_lambert_vertex
,
THREE
.
ShaderChunk
.
skinning_vertex
,
THREE
.
ShaderChunk
.
morphtarget_vertex
,
THREE
.
ShaderChunk
.
default_vertex
,
THREE
.
ShaderChunk
.
shadowmap_vertex
,
"
}
"
].
join
(
"
\n
"
),
fragmentShader
:[
"
uniform float opacity;
\n
varying vec3 vLightWeighting;
"
,
THREE
.
ShaderChunk
.
color_pars_fragment
,
THREE
.
ShaderChunk
.
map_pars_fragment
,
THREE
.
ShaderChunk
.
lightmap_pars_fragment
,
THREE
.
ShaderChunk
.
envmap_pars_fragment
,
THREE
.
ShaderChunk
.
fog_pars_fragment
,
THREE
.
ShaderChunk
.
shadowmap_pars_fragment
,
"
void main() {
\n
gl_FragColor = vec4( vec3 ( 1.0 ), opacity );
"
,
THREE
.
ShaderChunk
.
map_fragment
,
THREE
.
ShaderChunk
.
alphatest_fragment
,
"
gl_FragColor.xyz = gl_FragColor.xyz * vLightWeighting;
"
,
THREE
.
ShaderChunk
.
lightmap_fragment
,
THREE
.
ShaderChunk
.
color_fragment
,
THREE
.
ShaderChunk
.
envmap_fragment
,
THREE
.
ShaderChunk
.
shadowmap_fragment
,
THREE
.
ShaderChunk
.
linear_to_gamma_fragment
,
THREE
.
ShaderChunk
.
fog_fragment
,
"
}
"
].
join
(
"
\n
"
)},
phong
:{
uniforms
:
THREE
.
UniformsUtils
.
merge
([
THREE
.
UniformsLib
.
common
,
THREE
.
UniformsLib
.
fog
,
THREE
.
UniformsLib
.
lights
,
THREE
.
UniformsLib
.
shadowmap
,{
ambient
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
328965
)},
specular
:{
type
:
"
c
"
,
value
:
new
THREE
.
Color
(
1118481
)},
shininess
:{
type
:
"
f
"
,
value
:
30
},
wrapRGB
:{
type
:
"
v3
"
,
value
:
new
THREE
.
Vector3
(
1
,
1
,
1
)}}]),
vertexShader
:[
"
varying vec3 vViewPosition;
\n
varying vec3 vNormal;
"
,
THREE
.
ShaderChunk
.
map_pars_vertex
,
THREE
.
ShaderChunk
.
lightmap_pars_vertex
,
THREE
.
ShaderChunk
.
envmap_pars_vertex
,
THREE
.
ShaderChunk
.
lights_phong_pars_vertex
,
THREE
.
ShaderChunk
.
color_pars_vertex
,
THREE
.
ShaderChunk
.
skinning_pars_vertex
,
THREE
.
ShaderChunk
.
morphtarget_pars_vertex
,
THREE
.
ShaderChunk
.
shadowmap_pars_vertex
,
"
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
THREE
.
ShaderChunk
.
map_vertex
,
THREE
.
ShaderChunk
.
lightmap_vertex
,
THREE
.
ShaderChunk
.
envmap_vertex
,
THREE
.
ShaderChunk
.
color_vertex
,
"
#ifndef USE_ENVMAP
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
#endif
\n
vViewPosition = -mvPosition.xyz;
\n
vec3 transformedNormal = normalMatrix * normal;
\n
vNormal = transformedNormal;
"
,
THREE
.
ShaderChunk
.
lights_phong_vertex
,
THREE
.
ShaderChunk
.
morphtarget_pars_vertex
,
THREE
.
ShaderChunk
.
shadowmap_pars_vertex
,
"
void main() {
\n
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
THREE
.
ShaderChunk
.
map_vertex
,
THREE
.
ShaderChunk
.
lightmap_vertex
,
THREE
.
ShaderChunk
.
envmap_vertex
,
THREE
.
ShaderChunk
.
color_vertex
,
"
#ifndef USE_ENVMAP
\n
vec4 mPosition = objectMatrix * vec4( position, 1.0 );
\n
#endif
\n
vViewPosition = -mvPosition.xyz;
"
,
THREE
.
ShaderChunk
.
morphnormal_vertex
,
"
vNormal = transformedNormal;
"
,
THREE
.
ShaderChunk
.
lights_phong_vertex
,
THREE
.
ShaderChunk
.
skinning_vertex
,
THREE
.
ShaderChunk
.
morphtarget_vertex
,
THREE
.
ShaderChunk
.
default_vertex
,
THREE
.
ShaderChunk
.
shadowmap_vertex
,
"
}
"
].
join
(
"
\n
"
),
fragmentShader
:[
"
uniform vec3 diffuse;
\n
uniform float opacity;
\n
uniform vec3 ambient;
\n
uniform vec3 specular;
\n
uniform float shininess;
"
,
THREE
.
ShaderChunk
.
color_pars_fragment
,
THREE
.
ShaderChunk
.
map_pars_fragment
,
THREE
.
ShaderChunk
.
lightmap_pars_fragment
,
THREE
.
ShaderChunk
.
envmap_pars_fragment
,
THREE
.
ShaderChunk
.
fog_pars_fragment
,
THREE
.
ShaderChunk
.
lights_phong_pars_fragment
,
THREE
.
ShaderChunk
.
shadowmap_pars_fragment
,
"
void main() {
\n
gl_FragColor = vec4( vec3 ( 1.0 ), opacity );
"
,
THREE
.
ShaderChunk
.
map_fragment
,
THREE
.
ShaderChunk
.
alphatest_fragment
,
THREE
.
ShaderChunk
.
lights_phong_fragment
,
THREE
.
ShaderChunk
.
lightmap_fragment
,
THREE
.
ShaderChunk
.
color_fragment
,
THREE
.
ShaderChunk
.
envmap_fragment
,
THREE
.
ShaderChunk
.
shadowmap_fragment
,
THREE
.
ShaderChunk
.
linear_to_gamma_fragment
,
THREE
.
ShaderChunk
.
fog_fragment
,
"
}
"
].
join
(
"
\n
"
)},
particle_basic
:{
uniforms
:
THREE
.
UniformsUtils
.
merge
([
THREE
.
UniformsLib
.
particle
,
THREE
.
UniformsLib
.
shadowmap
]),
vertexShader
:[
"
uniform float size;
\n
uniform float scale;
"
,
THREE
.
ShaderChunk
.
color_pars_vertex
,
THREE
.
ShaderChunk
.
shadowmap_pars_vertex
,
"
void main() {
"
,
THREE
.
ShaderChunk
.
color_vertex
,
"
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
\n
#ifdef USE_SIZEATTENUATION
\n
gl_PointSize = size * ( scale / length( mvPosition.xyz ) );
\n
#else
\n
gl_PointSize = size;
\n
#endif
\n
gl_Position = projectionMatrix * mvPosition;
"
,
THREE
.
ShaderChunk
.
shadowmap_vertex
,
"
}
"
].
join
(
"
\n
"
),
fragmentShader
:[
"
uniform vec3 psColor;
\n
uniform float opacity;
"
,
...
...
examples/webgl_morphnormals.html
浏览文件 @
b6bce4f6
...
...
@@ -83,13 +83,13 @@
//
var
loader
=
new
THREE
.
JSONLoader
(
true
);
var
loader
=
new
THREE
.
JSONLoader
();
loader
.
load
(
"
models/animated/flamingo.js
"
,
function
(
geometry
)
{
morphColorsToFaceColors
(
geometry
);
geometry
.
computeVertexNormals
();
var
material
=
new
THREE
.
MeshLambertMaterial
(
{
color
:
0xffffff
,
morphTargets
:
true
,
morphNormals
:
fals
e
,
vertexColors
:
THREE
.
FaceColors
,
shading
:
THREE
.
FlatShading
}
);
var
material
=
new
THREE
.
MeshLambertMaterial
(
{
color
:
0xffffff
,
morphTargets
:
true
,
morphNormals
:
tru
e
,
vertexColors
:
THREE
.
FaceColors
,
shading
:
THREE
.
FlatShading
}
);
var
meshAnim
=
new
THREE
.
MorphAnimMesh
(
geometry
,
material
);
meshAnim
.
duration
=
5000
;
...
...
@@ -107,7 +107,7 @@
morphColorsToFaceColors
(
geometry
);
geometry
.
computeVertexNormals
();
var
material
=
new
THREE
.
Mesh
LambertMaterial
(
{
color
:
0xffffff
,
morphTargets
:
true
,
morphNormals
:
true
,
vertexColors
:
THREE
.
FaceColors
,
shading
:
THREE
.
FlatShading
}
);
var
material
=
new
THREE
.
Mesh
PhongMaterial
(
{
color
:
0xffffff
,
specular
:
0xffffff
,
shininess
:
20
,
morphTargets
:
true
,
morphNormals
:
true
,
vertexColors
:
THREE
.
FaceColors
,
shading
:
THREE
.
SmoothShading
,
perPixel
:
false
}
);
var
meshAnim
=
new
THREE
.
MorphAnimMesh
(
geometry
,
material
);
meshAnim
.
duration
=
5000
;
...
...
src/materials/MeshPhongMaterial.js
浏览文件 @
b6bce4f6
...
...
@@ -71,6 +71,7 @@ THREE.MeshPhongMaterial = function ( parameters ) {
this
.
skinning
=
parameters
.
skinning
!==
undefined
?
parameters
.
skinning
:
false
;
this
.
morphTargets
=
parameters
.
morphTargets
!==
undefined
?
parameters
.
morphTargets
:
false
;
this
.
morphNormals
=
parameters
.
morphNormals
!==
undefined
?
parameters
.
morphNormals
:
false
;
};
...
...
src/renderers/WebGLShaders.js
浏览文件 @
b6bce4f6
...
...
@@ -289,6 +289,8 @@ THREE.ShaderChunk = {
"
#if MAX_DIR_LIGHTS > 0
"
,
"
transformedNormal = normalize( transformedNormal );
"
,
"
for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {
"
,
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
,
...
...
@@ -747,11 +749,11 @@ THREE.ShaderChunk = {
"
morphedNormal += normal;
"
,
"
vec3 transformedNormal = normal
ize( normalMatrix * morphedNormal )
;
"
,
"
vec3 transformedNormal = normal
Matrix * morphedNormal
;
"
,
"
#else
"
,
"
vec3 transformedNormal = normal
ize( normalMatrix * normal )
;
"
,
"
vec3 transformedNormal = normal
Matrix * normal
;
"
,
"
#endif
"
...
...
@@ -1438,7 +1440,8 @@ THREE.ShaderLib = {
"
vViewPosition = -mvPosition.xyz;
"
,
"
vec3 transformedNormal = normalMatrix * normal;
"
,
THREE
.
ShaderChunk
[
"
morphnormal_vertex
"
],
"
vNormal = transformedNormal;
"
,
THREE
.
ShaderChunk
[
"
lights_phong_vertex
"
],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录