Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
d97f3681
T
three.js
项目概览
车家大少爷
/
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,发现更多精彩内容 >>
未验证
提交
d97f3681
编写于
2月 24, 2018
作者:
M
Mr.doob
提交者:
GitHub
2月 24, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13404 from Mugen87/dev3
WebGLRenderer: Introduce WebGLInfo
上级
69ebfb9a
da0e026b
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
113 addition
and
80 deletion
+113
-80
docs/api/renderers/WebGLRenderer.html
docs/api/renderers/WebGLRenderer.html
+1
-1
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+11
-45
src/renderers/webgl/WebGLBufferRenderer.js
src/renderers/webgl/WebGLBufferRenderer.js
+3
-11
src/renderers/webgl/WebGLGeometries.js
src/renderers/webgl/WebGLGeometries.js
+3
-3
src/renderers/webgl/WebGLIndexedBufferRenderer.js
src/renderers/webgl/WebGLIndexedBufferRenderer.js
+3
-11
src/renderers/webgl/WebGLInfo.js
src/renderers/webgl/WebGLInfo.js
+83
-0
src/renderers/webgl/WebGLObjects.js
src/renderers/webgl/WebGLObjects.js
+2
-2
src/renderers/webgl/WebGLTextures.js
src/renderers/webgl/WebGLTextures.js
+7
-7
未找到文件。
docs/api/renderers/WebGLRenderer.html
浏览文件 @
d97f3681
...
...
@@ -180,9 +180,9 @@
<li>
render:
<ul>
<li>
calls
</li>
<li>
vertices
</li>
<li>
faces
</li>
<li>
points
</li>
<li>
segments
</li>
</ul>
</li>
<li>
programs
...
...
src/renderers/WebGLRenderer.js
浏览文件 @
d97f3681
...
...
@@ -29,6 +29,7 @@ import { Frustum } from '../math/Frustum.js';
import
{
Vector4
}
from
'
../math/Vector4.js
'
;
import
{
WebGLUtils
}
from
'
./webgl/WebGLUtils.js
'
;
import
{
WebGLRenderStates
}
from
'
./webgl/WebGLRenderStates.js
'
;
import
{
WebGLInfo
}
from
'
./webgl/WebGLInfo.js
'
;
/**
* @author supereggbert / http://www.paulbrunt.co.uk/
...
...
@@ -149,44 +150,7 @@ function WebGLRenderer( parameters ) {
_projScreenMatrix
=
new
Matrix4
(),
_vector3
=
new
Vector3
(),
// info
_infoMemory
=
{
geometries
:
0
,
textures
:
0
},
_infoRender
=
{
frame
:
0
,
calls
:
0
,
vertices
:
0
,
faces
:
0
,
points
:
0
};
this
.
info
=
{
render
:
_infoRender
,
memory
:
_infoMemory
,
programs
:
null
,
autoReset
:
true
,
reset
:
resetInfo
};
function
resetInfo
()
{
_infoRender
.
frame
++
;
_infoRender
.
calls
=
0
;
_infoRender
.
vertices
=
0
;
_infoRender
.
faces
=
0
;
_infoRender
.
points
=
0
;
}
_vector3
=
new
Vector3
();
function
getTargetPixelRatio
()
{
...
...
@@ -249,7 +213,7 @@ function WebGLRenderer( parameters ) {
}
var
extensions
,
capabilities
,
state
;
var
extensions
,
capabilities
,
state
,
info
;
var
properties
,
textures
,
attributes
,
geometries
,
objects
;
var
programCache
,
renderLists
,
renderStates
;
...
...
@@ -278,11 +242,12 @@ function WebGLRenderer( parameters ) {
state
.
scissor
(
_currentScissor
.
copy
(
_scissor
).
multiplyScalar
(
_pixelRatio
)
);
state
.
viewport
(
_currentViewport
.
copy
(
_viewport
).
multiplyScalar
(
_pixelRatio
)
);
info
=
new
WebGLInfo
(
_gl
);
properties
=
new
WebGLProperties
();
textures
=
new
WebGLTextures
(
_gl
,
extensions
,
state
,
properties
,
capabilities
,
utils
,
_infoMemory
,
_infoRender
);
textures
=
new
WebGLTextures
(
_gl
,
extensions
,
state
,
properties
,
capabilities
,
utils
,
info
);
attributes
=
new
WebGLAttributes
(
_gl
);
geometries
=
new
WebGLGeometries
(
_gl
,
attributes
,
_infoMemory
);
objects
=
new
WebGLObjects
(
geometries
,
_infoRender
);
geometries
=
new
WebGLGeometries
(
_gl
,
attributes
,
info
);
objects
=
new
WebGLObjects
(
geometries
,
info
);
morphtargets
=
new
WebGLMorphtargets
(
_gl
);
programCache
=
new
WebGLPrograms
(
_this
,
extensions
,
capabilities
);
renderLists
=
new
WebGLRenderLists
();
...
...
@@ -290,12 +255,12 @@ function WebGLRenderer( parameters ) {
background
=
new
WebGLBackground
(
_this
,
state
,
geometries
,
_premultipliedAlpha
);
bufferRenderer
=
new
WebGLBufferRenderer
(
_gl
,
extensions
,
_infoRender
);
indexedBufferRenderer
=
new
WebGLIndexedBufferRenderer
(
_gl
,
extensions
,
_infoRender
);
bufferRenderer
=
new
WebGLBufferRenderer
(
_gl
,
extensions
,
info
);
indexedBufferRenderer
=
new
WebGLIndexedBufferRenderer
(
_gl
,
extensions
,
info
);
spriteRenderer
=
new
WebGLSpriteRenderer
(
_this
,
_gl
,
state
,
textures
,
capabilities
);
_this
.
info
.
programs
=
programCache
.
programs
;
info
.
programs
=
programCache
.
programs
;
_this
.
context
=
_gl
;
_this
.
capabilities
=
capabilities
;
...
...
@@ -303,6 +268,7 @@ function WebGLRenderer( parameters ) {
_this
.
properties
=
properties
;
_this
.
renderLists
=
renderLists
;
_this
.
state
=
state
;
_this
.
info
=
info
;
}
...
...
src/renderers/webgl/WebGLBufferRenderer.js
浏览文件 @
d97f3681
...
...
@@ -2,7 +2,7 @@
* @author mrdoob / http://mrdoob.com/
*/
function
WebGLBufferRenderer
(
gl
,
extensions
,
info
Render
)
{
function
WebGLBufferRenderer
(
gl
,
extensions
,
info
)
{
var
mode
;
...
...
@@ -16,11 +16,7 @@ function WebGLBufferRenderer( gl, extensions, infoRender ) {
gl
.
drawArrays
(
mode
,
start
,
count
);
infoRender
.
calls
++
;
infoRender
.
vertices
+=
count
;
if
(
mode
===
gl
.
TRIANGLES
)
infoRender
.
faces
+=
count
/
3
;
else
if
(
mode
===
gl
.
POINTS
)
infoRender
.
points
+=
count
;
info
.
update
(
count
,
mode
);
}
...
...
@@ -49,11 +45,7 @@ function WebGLBufferRenderer( gl, extensions, infoRender ) {
}
infoRender
.
calls
++
;
infoRender
.
vertices
+=
count
*
geometry
.
maxInstancedCount
;
if
(
mode
===
gl
.
TRIANGLES
)
infoRender
.
faces
+=
geometry
.
maxInstancedCount
*
count
/
3
;
else
if
(
mode
===
gl
.
POINTS
)
infoRender
.
points
+=
geometry
.
maxInstancedCount
*
count
;
info
.
update
(
count
,
mode
,
geometry
.
maxInstancedCount
);
}
...
...
src/renderers/webgl/WebGLGeometries.js
浏览文件 @
d97f3681
...
...
@@ -6,7 +6,7 @@ import { Uint16BufferAttribute, Uint32BufferAttribute } from '../../core/BufferA
import
{
BufferGeometry
}
from
'
../../core/BufferGeometry.js
'
;
import
{
arrayMax
}
from
'
../../utils.js
'
;
function
WebGLGeometries
(
gl
,
attributes
,
info
Memory
)
{
function
WebGLGeometries
(
gl
,
attributes
,
info
)
{
var
geometries
=
{};
var
wireframeAttributes
=
{};
...
...
@@ -54,7 +54,7 @@ function WebGLGeometries( gl, attributes, infoMemory ) {
//
info
M
emory
.
geometries
--
;
info
.
m
emory
.
geometries
--
;
}
...
...
@@ -84,7 +84,7 @@ function WebGLGeometries( gl, attributes, infoMemory ) {
geometries
[
geometry
.
id
]
=
buffergeometry
;
info
M
emory
.
geometries
++
;
info
.
m
emory
.
geometries
++
;
return
buffergeometry
;
...
...
src/renderers/webgl/WebGLIndexedBufferRenderer.js
浏览文件 @
d97f3681
...
...
@@ -2,7 +2,7 @@
* @author mrdoob / http://mrdoob.com/
*/
function
WebGLIndexedBufferRenderer
(
gl
,
extensions
,
info
Render
)
{
function
WebGLIndexedBufferRenderer
(
gl
,
extensions
,
info
)
{
var
mode
;
...
...
@@ -25,11 +25,7 @@ function WebGLIndexedBufferRenderer( gl, extensions, infoRender ) {
gl
.
drawElements
(
mode
,
count
,
type
,
start
*
bytesPerElement
);
infoRender
.
calls
++
;
infoRender
.
vertices
+=
count
;
if
(
mode
===
gl
.
TRIANGLES
)
infoRender
.
faces
+=
count
/
3
;
else
if
(
mode
===
gl
.
POINTS
)
infoRender
.
points
+=
count
;
info
.
update
(
count
,
mode
);
}
...
...
@@ -46,11 +42,7 @@ function WebGLIndexedBufferRenderer( gl, extensions, infoRender ) {
extension
.
drawElementsInstancedANGLE
(
mode
,
count
,
type
,
start
*
bytesPerElement
,
geometry
.
maxInstancedCount
);
infoRender
.
calls
++
;
infoRender
.
vertices
+=
count
*
geometry
.
maxInstancedCount
;
if
(
mode
===
gl
.
TRIANGLES
)
infoRender
.
faces
+=
geometry
.
maxInstancedCount
*
count
/
3
;
else
if
(
mode
===
gl
.
POINTS
)
infoRender
.
points
+=
geometry
.
maxInstancedCount
*
count
;
info
.
update
(
count
,
mode
,
geometry
.
maxInstancedCount
);
}
...
...
src/renderers/webgl/WebGLInfo.js
0 → 100644
浏览文件 @
d97f3681
/**
* @author Mugen87 / https://github.com/Mugen87
*/
function
WebGLInfo
(
gl
)
{
var
memory
=
{
geometries
:
0
,
textures
:
0
};
var
render
=
{
frame
:
0
,
calls
:
0
,
faces
:
0
,
points
:
0
,
segments
:
0
};
function
update
(
count
,
mode
,
instanceCount
)
{
instanceCount
=
instanceCount
||
1
;
render
.
calls
++
;
switch
(
mode
)
{
case
gl
.
TRIANGLES
:
render
.
faces
+=
instanceCount
*
(
count
/
3
);
break
;
case
gl
.
TRIANGLE_STRIP
:
case
gl
.
TRIANGLE_FAN
:
render
.
faces
+=
instanceCount
*
(
count
-
2
);
break
;
case
gl
.
LINES
:
render
.
segments
+=
instanceCount
*
(
count
/
2
);
break
;
case
gl
.
LINE_STRIP
:
render
.
segments
+=
instanceCount
*
(
count
-
1
);
break
;
case
gl
.
LINE_LOOP
:
render
.
segments
+=
instanceCount
*
count
;
break
;
case
gl
.
POINTS
:
render
.
points
+=
instanceCount
*
count
;
break
;
default
:
console
.
error
(
'
THREE.WebGLInfo: Unknown draw mode:
'
,
mode
);
break
;
}
}
function
reset
()
{
render
.
frame
++
;
render
.
calls
=
0
;
render
.
faces
=
0
;
render
.
points
=
0
;
render
.
segments
=
0
;
}
return
{
memory
:
memory
,
render
:
render
,
programs
:
null
,
autoReset
:
true
,
reset
:
reset
,
update
:
update
};
}
export
{
WebGLInfo
};
src/renderers/webgl/WebGLObjects.js
浏览文件 @
d97f3681
...
...
@@ -2,13 +2,13 @@
* @author mrdoob / http://mrdoob.com/
*/
function
WebGLObjects
(
geometries
,
info
Render
)
{
function
WebGLObjects
(
geometries
,
info
)
{
var
updateList
=
{};
function
update
(
object
)
{
var
frame
=
info
R
ender
.
frame
;
var
frame
=
info
.
r
ender
.
frame
;
var
geometry
=
object
.
geometry
;
var
buffergeometry
=
geometries
.
get
(
object
,
geometry
);
...
...
src/renderers/webgl/WebGLTextures.js
浏览文件 @
d97f3681
...
...
@@ -5,7 +5,7 @@
import
{
LinearFilter
,
NearestFilter
,
RGBFormat
,
RGBAFormat
,
DepthFormat
,
DepthStencilFormat
,
UnsignedShortType
,
UnsignedIntType
,
UnsignedInt248Type
,
FloatType
,
HalfFloatType
,
ClampToEdgeWrapping
,
NearestMipMapLinearFilter
,
NearestMipMapNearestFilter
}
from
'
../../constants.js
'
;
import
{
_Math
}
from
'
../../math/Math.js
'
;
function
WebGLTextures
(
_gl
,
extensions
,
state
,
properties
,
capabilities
,
utils
,
info
Memory
,
infoRender
)
{
function
WebGLTextures
(
_gl
,
extensions
,
state
,
properties
,
capabilities
,
utils
,
info
)
{
var
_isWebGL2
=
(
typeof
WebGL2RenderingContext
!==
'
undefined
'
&&
_gl
instanceof
WebGL2RenderingContext
);
var
_videoTextures
=
{};
...
...
@@ -111,7 +111,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
}
info
M
emory
.
textures
--
;
info
.
m
emory
.
textures
--
;
}
...
...
@@ -123,7 +123,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
deallocateRenderTarget
(
renderTarget
);
info
M
emory
.
textures
--
;
info
.
m
emory
.
textures
--
;
}
...
...
@@ -244,7 +244,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
textureProperties
.
__image__webglTextureCube
=
_gl
.
createTexture
();
info
M
emory
.
textures
++
;
info
.
m
emory
.
textures
++
;
}
...
...
@@ -415,7 +415,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
textureProperties
.
__webglTexture
=
_gl
.
createTexture
();
info
M
emory
.
textures
++
;
info
.
m
emory
.
textures
++
;
}
...
...
@@ -718,7 +718,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
textureProperties
.
__webglTexture
=
_gl
.
createTexture
();
info
M
emory
.
textures
++
;
info
.
m
emory
.
textures
++
;
var
isCube
=
(
renderTarget
.
isWebGLRenderTargetCube
===
true
);
var
isTargetPowerOfTwo
=
isPowerOfTwo
(
renderTarget
);
...
...
@@ -799,7 +799,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
function
updateVideoTexture
(
texture
)
{
var
id
=
texture
.
id
;
var
frame
=
info
R
ender
.
frame
;
var
frame
=
info
.
r
ender
.
frame
;
// Check the last frame we updated the VideoTexture
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录