Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
141ac28d
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,发现更多精彩内容 >>
提交
141ac28d
编写于
6月 23, 2015
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up.
上级
71008527
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
63 addition
and
59 deletion
+63
-59
src/renderers/webgl/WebGLShadowMap.js
src/renderers/webgl/WebGLShadowMap.js
+2
-1
src/renderers/webgl/WebGLState.js
src/renderers/webgl/WebGLState.js
+36
-35
src/renderers/webgl/plugins/LensFlarePlugin.js
src/renderers/webgl/plugins/LensFlarePlugin.js
+16
-15
src/renderers/webgl/plugins/SpritePlugin.js
src/renderers/webgl/plugins/SpritePlugin.js
+9
-8
未找到文件。
src/renderers/webgl/WebGLShadowMap.js
浏览文件 @
141ac28d
...
...
@@ -6,6 +6,7 @@
THREE
.
WebGLShadowMap
=
function
(
_renderer
,
_lights
,
_objects
)
{
var
_gl
=
_renderer
.
context
,
_state
=
_renderer
.
state
,
_frustum
=
new
THREE
.
Frustum
(),
_projScreenMatrix
=
new
THREE
.
Matrix4
(),
...
...
@@ -99,7 +100,7 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
}
_
renderer
.
state
.
setDepthTest
(
true
);
_state
.
setDepthTest
(
true
);
// preprocess lights
// - skip lights that are not casting shadows
...
...
src/renderers/webgl/WebGLState.js
浏览文件 @
141ac28d
...
...
@@ -160,66 +160,67 @@ THREE.WebGLState = function ( gl, paramThreeToGL ) {
this
.
setDepthFunc
=
function
(
depthFunc
)
{
if
(
currentDepthFunc
!==
depthFunc
)
{
if
(
currentDepthFunc
!==
depthFunc
)
{
if
(
depthFunc
)
{
if
(
depthFunc
)
{
switch
(
depthFunc
)
{
switch
(
depthFunc
)
{
case
THREE
.
NeverDepth
:
case
THREE
.
NeverDepth
:
gl
.
depthFunc
(
gl
.
NEVER
);
break
;
gl
.
depthFunc
(
gl
.
NEVER
);
break
;
case
THREE
.
AlwaysDepth
:
case
THREE
.
AlwaysDepth
:
gl
.
depthFunc
(
gl
.
ALWAYS
);
break
;
gl
.
depthFunc
(
gl
.
ALWAYS
);
break
;
case
THREE
.
LessDepth
:
case
THREE
.
LessDepth
:
gl
.
depthFunc
(
gl
.
LESS
);
break
;
gl
.
depthFunc
(
gl
.
LESS
);
break
;
case
THREE
.
LessEqualDepth
:
case
THREE
.
LessEqualDepth
:
gl
.
depthFunc
(
gl
.
LEQUAL
);
break
;
gl
.
depthFunc
(
gl
.
LEQUAL
);
break
;
case
THREE
.
EqualDepth
:
case
THREE
.
EqualDepth
:
gl
.
depthFunc
(
gl
.
EQUAL
);
break
;
gl
.
depthFunc
(
gl
.
EQUAL
);
break
;
case
THREE
.
GreaterEqualDepth
:
case
THREE
.
GreaterEqualDepth
:
gl
.
depthFunc
(
gl
.
GEQUAL
);
break
;
gl
.
depthFunc
(
gl
.
GEQUAL
);
break
;
case
THREE
.
GreaterDepth
:
case
THREE
.
GreaterDepth
:
gl
.
depthFunc
(
gl
.
GREATER
);
break
;
gl
.
depthFunc
(
gl
.
GREATER
);
break
;
case
THREE
.
NotEqualDepth
:
case
THREE
.
NotEqualDepth
:
gl
.
depthFunc
(
gl
.
NOTEQUAL
);
break
;
gl
.
depthFunc
(
gl
.
NOTEQUAL
);
break
;
default
:
default
:
gl
.
depthFunc
(
gl
.
LEQUAL
);
}
gl
.
depthFunc
(
gl
.
LEQUAL
);
}
else
{
}
gl
.
depthFunc
(
gl
.
LEQUAL
);
}
else
{
gl
.
depthFunc
(
gl
.
LEQUAL
);
}
}
currentDepthFunc
=
depthFunc
;
currentDepthFunc
=
depthFunc
;
}
}
};
...
...
src/renderers/webgl/plugins/LensFlarePlugin.js
浏览文件 @
141ac28d
...
...
@@ -6,6 +6,7 @@
THREE
.
LensFlarePlugin
=
function
(
renderer
,
flares
)
{
var
gl
=
renderer
.
context
;
var
state
=
renderer
.
state
;
var
vertexBuffer
,
elementBuffer
;
var
program
,
attributes
,
uniforms
;
...
...
@@ -43,14 +44,14 @@ THREE.LensFlarePlugin = function ( renderer, flares ) {
tempTexture
=
gl
.
createTexture
();
occlusionTexture
=
gl
.
createTexture
();
renderer
.
state
.
bindTexture
(
gl
.
TEXTURE_2D
,
tempTexture
);
state
.
bindTexture
(
gl
.
TEXTURE_2D
,
tempTexture
);
gl
.
texImage2D
(
gl
.
TEXTURE_2D
,
0
,
gl
.
RGB
,
16
,
16
,
0
,
gl
.
RGB
,
gl
.
UNSIGNED_BYTE
,
null
);
gl
.
texParameteri
(
gl
.
TEXTURE_2D
,
gl
.
TEXTURE_WRAP_S
,
gl
.
CLAMP_TO_EDGE
);
gl
.
texParameteri
(
gl
.
TEXTURE_2D
,
gl
.
TEXTURE_WRAP_T
,
gl
.
CLAMP_TO_EDGE
);
gl
.
texParameteri
(
gl
.
TEXTURE_2D
,
gl
.
TEXTURE_MAG_FILTER
,
gl
.
NEAREST
);
gl
.
texParameteri
(
gl
.
TEXTURE_2D
,
gl
.
TEXTURE_MIN_FILTER
,
gl
.
NEAREST
);
renderer
.
state
.
bindTexture
(
gl
.
TEXTURE_2D
,
occlusionTexture
);
state
.
bindTexture
(
gl
.
TEXTURE_2D
,
occlusionTexture
);
gl
.
texImage2D
(
gl
.
TEXTURE_2D
,
0
,
gl
.
RGBA
,
16
,
16
,
0
,
gl
.
RGBA
,
gl
.
UNSIGNED_BYTE
,
null
);
gl
.
texParameteri
(
gl
.
TEXTURE_2D
,
gl
.
TEXTURE_WRAP_S
,
gl
.
CLAMP_TO_EDGE
);
gl
.
texParameteri
(
gl
.
TEXTURE_2D
,
gl
.
TEXTURE_WRAP_T
,
gl
.
CLAMP_TO_EDGE
);
...
...
@@ -295,10 +296,10 @@ THREE.LensFlarePlugin = function ( renderer, flares ) {
gl
.
useProgram
(
program
);
renderer
.
state
.
initAttributes
();
renderer
.
state
.
enableAttribute
(
attributes
.
vertex
);
renderer
.
state
.
enableAttribute
(
attributes
.
uv
);
renderer
.
state
.
disableUnusedAttributes
();
state
.
initAttributes
();
state
.
enableAttribute
(
attributes
.
vertex
);
state
.
enableAttribute
(
attributes
.
uv
);
state
.
disableUnusedAttributes
();
// loop through all lens flares to update their occlusion and positions
// setup gl and common used attribs/unforms
...
...
@@ -346,10 +347,10 @@ THREE.LensFlarePlugin = function ( renderer, flares ) {
// save current RGB to temp texture
renderer
.
state
.
activeTexture
(
gl
.
TEXTURE0
);
renderer
.
state
.
bindTexture
(
gl
.
TEXTURE_2D
,
null
);
renderer
.
state
.
activeTexture
(
gl
.
TEXTURE1
);
renderer
.
state
.
bindTexture
(
gl
.
TEXTURE_2D
,
tempTexture
);
state
.
activeTexture
(
gl
.
TEXTURE0
);
state
.
bindTexture
(
gl
.
TEXTURE_2D
,
null
);
state
.
activeTexture
(
gl
.
TEXTURE1
);
state
.
bindTexture
(
gl
.
TEXTURE_2D
,
tempTexture
);
gl
.
copyTexImage2D
(
gl
.
TEXTURE_2D
,
0
,
gl
.
RGB
,
screenPositionPixels
.
x
-
8
,
screenPositionPixels
.
y
-
8
,
16
,
16
,
0
);
...
...
@@ -367,8 +368,8 @@ THREE.LensFlarePlugin = function ( renderer, flares ) {
// copy result to occlusionMap
renderer
.
state
.
activeTexture
(
gl
.
TEXTURE0
);
renderer
.
state
.
bindTexture
(
gl
.
TEXTURE_2D
,
occlusionTexture
);
state
.
activeTexture
(
gl
.
TEXTURE0
);
state
.
bindTexture
(
gl
.
TEXTURE_2D
,
occlusionTexture
);
gl
.
copyTexImage2D
(
gl
.
TEXTURE_2D
,
0
,
gl
.
RGBA
,
screenPositionPixels
.
x
-
8
,
screenPositionPixels
.
y
-
8
,
16
,
16
,
0
);
...
...
@@ -377,8 +378,8 @@ THREE.LensFlarePlugin = function ( renderer, flares ) {
gl
.
uniform1i
(
uniforms
.
renderType
,
1
);
gl
.
disable
(
gl
.
DEPTH_TEST
);
renderer
.
state
.
activeTexture
(
gl
.
TEXTURE1
);
renderer
.
state
.
bindTexture
(
gl
.
TEXTURE_2D
,
tempTexture
);
state
.
activeTexture
(
gl
.
TEXTURE1
);
state
.
bindTexture
(
gl
.
TEXTURE_2D
,
tempTexture
);
gl
.
drawElements
(
gl
.
TRIANGLES
,
6
,
gl
.
UNSIGNED_SHORT
,
0
);
...
...
@@ -423,7 +424,7 @@ THREE.LensFlarePlugin = function ( renderer, flares ) {
gl
.
uniform1f
(
uniforms
.
opacity
,
sprite
.
opacity
);
gl
.
uniform3f
(
uniforms
.
color
,
sprite
.
color
.
r
,
sprite
.
color
.
g
,
sprite
.
color
.
b
);
renderer
.
state
.
setBlending
(
sprite
.
blending
,
sprite
.
blendEquation
,
sprite
.
blendSrc
,
sprite
.
blendDst
);
state
.
setBlending
(
sprite
.
blending
,
sprite
.
blendEquation
,
sprite
.
blendSrc
,
sprite
.
blendDst
);
renderer
.
setTexture
(
sprite
.
texture
,
1
);
gl
.
drawElements
(
gl
.
TRIANGLES
,
6
,
gl
.
UNSIGNED_SHORT
,
0
);
...
...
src/renderers/webgl/plugins/SpritePlugin.js
浏览文件 @
141ac28d
...
...
@@ -6,6 +6,7 @@
THREE
.
SpritePlugin
=
function
(
renderer
,
sprites
)
{
var
gl
=
renderer
.
context
;
var
state
=
renderer
.
state
;
var
vertexBuffer
,
elementBuffer
;
var
program
,
attributes
,
uniforms
;
...
...
@@ -98,10 +99,10 @@ THREE.SpritePlugin = function ( renderer, sprites ) {
gl
.
useProgram
(
program
);
renderer
.
state
.
initAttributes
();
renderer
.
state
.
enableAttribute
(
attributes
.
position
);
renderer
.
state
.
enableAttribute
(
attributes
.
uv
);
renderer
.
state
.
disableUnusedAttributes
();
state
.
initAttributes
();
state
.
enableAttribute
(
attributes
.
position
);
state
.
enableAttribute
(
attributes
.
uv
);
state
.
disableUnusedAttributes
();
gl
.
disable
(
gl
.
CULL_FACE
);
gl
.
enable
(
gl
.
BLEND
);
...
...
@@ -114,7 +115,7 @@ THREE.SpritePlugin = function ( renderer, sprites ) {
gl
.
uniformMatrix4fv
(
uniforms
.
projectionMatrix
,
false
,
camera
.
projectionMatrix
.
elements
);
renderer
.
state
.
activeTexture
(
gl
.
TEXTURE0
);
state
.
activeTexture
(
gl
.
TEXTURE0
);
gl
.
uniform1i
(
uniforms
.
map
,
0
);
var
oldFogType
=
0
;
...
...
@@ -216,9 +217,9 @@ THREE.SpritePlugin = function ( renderer, sprites ) {
gl
.
uniform1f
(
uniforms
.
rotation
,
material
.
rotation
);
gl
.
uniform2fv
(
uniforms
.
scale
,
scale
);
renderer
.
state
.
setBlending
(
material
.
blending
,
material
.
blendEquation
,
material
.
blendSrc
,
material
.
blendDst
);
renderer
.
state
.
setDepthTest
(
material
.
depthTest
);
renderer
.
state
.
setDepthWrite
(
material
.
depthWrite
);
state
.
setBlending
(
material
.
blending
,
material
.
blendEquation
,
material
.
blendSrc
,
material
.
blendDst
);
state
.
setDepthTest
(
material
.
depthTest
);
state
.
setDepthWrite
(
material
.
depthWrite
);
if
(
material
.
map
&&
material
.
map
.
image
&&
material
.
map
.
image
.
width
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录