Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
174dc10a
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,发现更多精彩内容 >>
未验证
提交
174dc10a
编写于
2月 05, 2018
作者:
M
Mr.doob
提交者:
GitHub
2月 05, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13110 from Mugen87/dev7
WebGLRenderer: Enable nested render calls
上级
1735ff99
cf15406a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
153 addition
and
29 deletion
+153
-29
examples/js/objects/LensFlare.js
examples/js/objects/LensFlare.js
+0
-3
examples/js/objects/Reflector.js
examples/js/objects/Reflector.js
+0
-1
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+35
-23
src/renderers/webgl/WebGLLights.js
src/renderers/webgl/WebGLLights.js
+2
-2
src/renderers/webgl/WebGLProperties.js
src/renderers/webgl/WebGLProperties.js
+10
-0
src/renderers/webgl/WebGLRenderStates.js
src/renderers/webgl/WebGLRenderStates.js
+106
-0
未找到文件。
examples/js/objects/LensFlare.js
浏览文件 @
174dc10a
...
...
@@ -8,9 +8,6 @@ THREE.LensFlare = function () {
THREE
.
Mesh
.
call
(
this
);
this
.
type
=
'
LensFlare
'
;
this
.
renderOrder
=
Infinity
;
// see #12883
this
.
material
.
transparent
=
true
;
this
.
frustumCulled
=
false
;
//
...
...
examples/js/objects/Reflector.js
浏览文件 @
174dc10a
...
...
@@ -7,7 +7,6 @@ THREE.Reflector = function ( geometry, options ) {
THREE
.
Mesh
.
call
(
this
,
geometry
);
this
.
type
=
'
Reflector
'
;
this
.
renderOrder
=
Infinity
;
// see #12883
var
scope
=
this
;
...
...
src/renderers/WebGLRenderer.js
浏览文件 @
174dc10a
...
...
@@ -15,7 +15,6 @@ import { WebGLMorphtargets } from './webgl/WebGLMorphtargets.js';
import
{
WebGLIndexedBufferRenderer
}
from
'
./webgl/WebGLIndexedBufferRenderer.js
'
;
import
{
WebGLBufferRenderer
}
from
'
./webgl/WebGLBufferRenderer.js
'
;
import
{
WebGLGeometries
}
from
'
./webgl/WebGLGeometries.js
'
;
import
{
WebGLLights
}
from
'
./webgl/WebGLLights.js
'
;
import
{
WebGLObjects
}
from
'
./webgl/WebGLObjects.js
'
;
import
{
WebGLPrograms
}
from
'
./webgl/WebGLPrograms.js
'
;
import
{
WebGLTextures
}
from
'
./webgl/WebGLTextures.js
'
;
...
...
@@ -29,6 +28,7 @@ import { WebGLClipping } from './webgl/WebGLClipping.js';
import
{
Frustum
}
from
'
../math/Frustum.js
'
;
import
{
Vector4
}
from
'
../math/Vector4.js
'
;
import
{
WebGLUtils
}
from
'
./webgl/WebGLUtils.js
'
;
import
{
WebGLRenderStates
}
from
'
./webgl/WebGLRenderStates.js
'
;
/**
* @author supereggbert / http://www.paulbrunt.co.uk/
...
...
@@ -55,12 +55,8 @@ function WebGLRenderer( parameters ) {
_preserveDrawingBuffer
=
parameters
.
preserveDrawingBuffer
!==
undefined
?
parameters
.
preserveDrawingBuffer
:
false
,
_powerPreference
=
parameters
.
powerPreference
!==
undefined
?
parameters
.
powerPreference
:
'
default
'
;
var
lightsArray
=
[];
var
shadowsArray
=
[];
var
currentRenderList
=
null
;
var
spritesArray
=
[];
var
currentRenderState
=
null
;
// public properties
...
...
@@ -254,8 +250,8 @@ function WebGLRenderer( parameters ) {
}
var
extensions
,
capabilities
,
state
;
var
properties
,
textures
,
attributes
,
geometries
,
objects
,
lights
;
var
programCache
,
renderLists
;
var
properties
,
textures
,
attributes
,
geometries
,
objects
;
var
programCache
,
renderLists
,
renderStates
;
var
background
,
morphtargets
,
bufferRenderer
,
indexedBufferRenderer
;
var
spriteRenderer
;
...
...
@@ -289,8 +285,8 @@ function WebGLRenderer( parameters ) {
objects
=
new
WebGLObjects
(
geometries
,
_infoRender
);
morphtargets
=
new
WebGLMorphtargets
(
_gl
);
programCache
=
new
WebGLPrograms
(
_this
,
extensions
,
capabilities
);
lights
=
new
WebGLLights
();
renderLists
=
new
WebGLRenderLists
();
renderStates
=
new
WebGLRenderStates
();
background
=
new
WebGLBackground
(
_this
,
state
,
geometries
,
_premultipliedAlpha
);
...
...
@@ -525,6 +521,7 @@ function WebGLRenderer( parameters ) {
_canvas
.
removeEventListener
(
'
webglcontextrestored
'
,
onContextRestore
,
false
);
renderLists
.
dispose
();
renderStates
.
dispose
();
properties
.
dispose
();
objects
.
dispose
();
...
...
@@ -996,18 +993,17 @@ function WebGLRenderer( parameters ) {
this
.
compile
=
function
(
scene
,
camera
)
{
lightsArray
.
length
=
0
;
shadowsArray
.
length
=
0
;
currentRenderState
.
init
();
scene
.
traverse
(
function
(
object
)
{
if
(
object
.
isLight
)
{
lightsArray
.
push
(
object
);
currentRenderState
.
pushLight
(
object
);
if
(
object
.
castShadow
)
{
shadowsArray
.
push
(
object
);
currentRenderState
.
pushShadow
(
object
);
}
...
...
@@ -1015,7 +1011,7 @@ function WebGLRenderer( parameters ) {
}
);
lights
.
setup
(
lightsArray
,
shadowsArray
,
camera
);
currentRenderState
.
setupLights
(
camera
);
scene
.
traverse
(
function
(
object
)
{
...
...
@@ -1128,16 +1124,16 @@ function WebGLRenderer( parameters ) {
}
//
currentRenderState
=
renderStates
.
get
(
scene
,
camera
);
currentRenderState
.
init
();
scene
.
onBeforeRender
(
_this
,
scene
,
camera
,
renderTarget
);
_projScreenMatrix
.
multiplyMatrices
(
camera
.
projectionMatrix
,
camera
.
matrixWorldInverse
);
_frustum
.
setFromMatrix
(
_projScreenMatrix
);
lightsArray
.
length
=
0
;
shadowsArray
.
length
=
0
;
spritesArray
.
length
=
0
;
_localClippingEnabled
=
this
.
localClippingEnabled
;
_clippingEnabled
=
_clipping
.
init
(
this
.
clippingPlanes
,
_localClippingEnabled
,
camera
);
...
...
@@ -1156,9 +1152,11 @@ function WebGLRenderer( parameters ) {
if
(
_clippingEnabled
)
_clipping
.
beginShadows
();
var
shadowsArray
=
currentRenderState
.
state
.
shadowsArray
;
shadowMap
.
render
(
shadowsArray
,
scene
,
camera
);
lights
.
setup
(
lightsArray
,
shadowsArray
,
camera
);
currentRenderState
.
setupLights
(
camera
);
if
(
_clippingEnabled
)
_clipping
.
endShadows
();
...
...
@@ -1204,6 +1202,8 @@ function WebGLRenderer( parameters ) {
// custom renderers
var
spritesArray
=
currentRenderState
.
state
.
spritesArray
;
spriteRenderer
.
render
(
spritesArray
,
scene
,
camera
);
// Generate mipmap if we're using any kind of mipmap filtering
...
...
@@ -1233,6 +1233,7 @@ function WebGLRenderer( parameters ) {
// _gl.finish();
currentRenderList
=
null
;
currentRenderState
=
null
;
};
...
...
@@ -1301,11 +1302,11 @@ function WebGLRenderer( parameters ) {
if
(
object
.
isLight
)
{
lightsArray
.
push
(
object
);
currentRenderState
.
pushLight
(
object
);
if
(
object
.
castShadow
)
{
shadowsArray
.
push
(
object
);
currentRenderState
.
pushShadow
(
object
);
}
...
...
@@ -1313,7 +1314,7 @@ function WebGLRenderer( parameters ) {
if
(
!
object
.
frustumCulled
||
_frustum
.
intersectsSprite
(
object
)
)
{
spritesArray
.
push
(
object
);
currentRenderState
.
pushSprite
(
object
);
}
...
...
@@ -1440,6 +1441,7 @@ function WebGLRenderer( parameters ) {
function
renderObject
(
object
,
scene
,
camera
,
geometry
,
material
,
group
)
{
object
.
onBeforeRender
(
_this
,
scene
,
camera
,
geometry
,
material
,
group
);
currentRenderState
=
renderStates
.
get
(
scene
,
_currentArrayCamera
||
camera
);
object
.
modelViewMatrix
.
multiplyMatrices
(
camera
.
matrixWorldInverse
,
object
.
matrixWorld
);
object
.
normalMatrix
.
getNormalMatrix
(
object
.
modelViewMatrix
);
...
...
@@ -1463,6 +1465,7 @@ function WebGLRenderer( parameters ) {
}
object
.
onAfterRender
(
_this
,
scene
,
camera
,
geometry
,
material
,
group
);
currentRenderState
=
renderStates
.
get
(
scene
,
_currentArrayCamera
||
camera
);
}
...
...
@@ -1470,6 +1473,9 @@ function WebGLRenderer( parameters ) {
var
materialProperties
=
properties
.
get
(
material
);
var
lights
=
currentRenderState
.
state
.
lights
;
var
shadowsArray
=
currentRenderState
.
state
.
shadowsArray
;
var
parameters
=
programCache
.
getParameters
(
material
,
lights
.
state
,
shadowsArray
,
fog
,
_clipping
.
numPlanes
,
_clipping
.
numIntersection
,
object
);
...
...
@@ -1488,6 +1494,11 @@ function WebGLRenderer( parameters ) {
// changed glsl or parameters
releaseMaterialProgramReference
(
material
);
}
else
if
(
materialProperties
.
lightsHash
!==
lights
.
state
.
hash
)
{
properties
.
update
(
material
,
'
lightsHash
'
,
lights
.
state
.
hash
);
programChange
=
false
;
}
else
if
(
parameters
.
shaderID
!==
undefined
)
{
// same glsl and uniform list
...
...
@@ -1619,6 +1630,7 @@ function WebGLRenderer( parameters ) {
_usedTextureUnits
=
0
;
var
materialProperties
=
properties
.
get
(
material
);
var
lights
=
currentRenderState
.
state
.
lights
;
if
(
_clippingEnabled
)
{
...
...
src/renderers/webgl/WebGLLights.js
浏览文件 @
174dc10a
...
...
@@ -100,7 +100,7 @@ function UniformsCache() {
}
function
WebGLLights
()
{
function
WebGLLights
(
stateId
)
{
var
cache
=
new
UniformsCache
();
...
...
@@ -313,7 +313,7 @@ function WebGLLights() {
state
.
hemi
.
length
=
hemiLength
;
// TODO (sam-g-steel) why aren't we using join
state
.
hash
=
directionalLength
+
'
,
'
+
pointLength
+
'
,
'
+
spotLength
+
'
,
'
+
rectAreaLength
+
'
,
'
+
hemiLength
+
'
,
'
+
shadows
.
length
;
state
.
hash
=
directionalLength
+
'
,
'
+
pointLength
+
'
,
'
+
spotLength
+
'
,
'
+
rectAreaLength
+
'
,
'
+
hemiLength
+
'
,
'
+
shadows
.
length
+
'
,
'
+
stateId
;
}
...
...
src/renderers/webgl/WebGLProperties.js
浏览文件 @
174dc10a
...
...
@@ -28,6 +28,15 @@ function WebGLProperties() {
}
function
update
(
object
,
key
,
value
)
{
var
uuid
=
object
.
uuid
;
var
map
=
properties
[
uuid
];
map
[
key
]
=
value
;
}
function
dispose
()
{
properties
=
{};
...
...
@@ -37,6 +46,7 @@ function WebGLProperties() {
return
{
get
:
get
,
remove
:
remove
,
update
:
update
,
dispose
:
dispose
};
...
...
src/renderers/webgl/WebGLRenderStates.js
0 → 100644
浏览文件 @
174dc10a
/**
* @author Mugen87 / https://github.com/Mugen87
*/
import
{
WebGLLights
}
from
'
./WebGLLights.js
'
;
var
count
=
0
;
function
WebGLRenderState
()
{
var
id
=
count
++
;
var
lights
=
new
WebGLLights
(
id
);
var
lightsArray
=
[];
var
shadowsArray
=
[];
var
spritesArray
=
[];
function
init
()
{
lightsArray
.
length
=
0
;
shadowsArray
.
length
=
0
;
spritesArray
.
length
=
0
;
}
function
pushLight
(
light
)
{
lightsArray
.
push
(
light
);
}
function
pushShadow
(
shadowLight
)
{
shadowsArray
.
push
(
shadowLight
);
}
function
pushSprite
(
shadowLight
)
{
spritesArray
.
push
(
shadowLight
);
}
function
setupLights
(
camera
)
{
lights
.
setup
(
lightsArray
,
shadowsArray
,
camera
);
}
var
state
=
{
lightsArray
:
lightsArray
,
shadowsArray
:
shadowsArray
,
spritesArray
:
spritesArray
,
lights
:
lights
};
return
{
init
:
init
,
state
:
state
,
setupLights
:
setupLights
,
pushLight
:
pushLight
,
pushShadow
:
pushShadow
,
pushSprite
:
pushSprite
};
}
function
WebGLRenderStates
()
{
var
renderStates
=
{};
function
get
(
scene
,
camera
)
{
var
hash
=
scene
.
id
+
'
,
'
+
camera
.
id
;
var
renderState
=
renderStates
[
hash
];
if
(
renderState
===
undefined
)
{
renderState
=
new
WebGLRenderState
();
renderStates
[
hash
]
=
renderState
;
}
return
renderState
;
}
function
dispose
()
{
renderStates
=
{};
}
return
{
get
:
get
,
dispose
:
dispose
};
}
export
{
WebGLRenderStates
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录