Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
9f4fb2be
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,发现更多精彩内容 >>
提交
9f4fb2be
编写于
9月 30, 2019
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WebGLTextures: Cache isWebGL2, maxTexture, maxCubemapSize, maxTextureSize and maxSamples.
上级
9d70acde
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
17 deletion
+23
-17
src/renderers/webgl/WebGLTextures.js
src/renderers/webgl/WebGLTextures.js
+23
-17
未找到文件。
src/renderers/webgl/WebGLTextures.js
浏览文件 @
9f4fb2be
...
...
@@ -7,6 +7,12 @@ import { _Math } from '../../math/Math.js';
function
WebGLTextures
(
_gl
,
extensions
,
state
,
properties
,
capabilities
,
utils
,
info
)
{
var
isWebGL2
=
capabilities
.
isWebGL2
;
var
maxTextures
=
capabilities
.
maxTextures
;
var
maxCubemapSize
=
capabilities
.
maxCubemapSize
;
var
maxTextureSize
=
capabilities
.
maxTextureSize
;
var
maxSamples
=
capabilities
.
maxSamples
;
var
_videoTextures
=
new
WeakMap
();
var
_canvas
;
...
...
@@ -95,7 +101,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
function
textureNeedsPowerOfTwo
(
texture
)
{
if
(
capabilities
.
isWebGL2
)
return
false
;
if
(
isWebGL2
)
return
false
;
return
(
texture
.
wrapS
!==
ClampToEdgeWrapping
||
texture
.
wrapT
!==
ClampToEdgeWrapping
)
||
(
texture
.
minFilter
!==
NearestFilter
&&
texture
.
minFilter
!==
LinearFilter
);
...
...
@@ -122,7 +128,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
function
getInternalFormat
(
glFormat
,
glType
)
{
if
(
!
capabilities
.
isWebGL2
)
return
glFormat
;
if
(
isWebGL2
===
false
)
return
glFormat
;
var
internalFormat
=
glFormat
;
...
...
@@ -294,9 +300,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
var
textureUnit
=
textureUnits
;
if
(
textureUnit
>=
capabilities
.
maxTextures
)
{
if
(
textureUnit
>=
maxTextures
)
{
console
.
warn
(
'
THREE.WebGLTextures: Trying to use
'
+
textureUnit
+
'
texture units while this GPU supports only
'
+
capabilities
.
maxTextures
);
console
.
warn
(
'
THREE.WebGLTextures: Trying to use
'
+
textureUnit
+
'
texture units while this GPU supports only
'
+
maxTextures
);
}
...
...
@@ -396,7 +402,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
if
(
!
isCompressed
&&
!
isDataTexture
)
{
cubeImage
[
i
]
=
resizeImage
(
texture
.
image
[
i
],
false
,
true
,
capabilities
.
maxCubemapSize
);
cubeImage
[
i
]
=
resizeImage
(
texture
.
image
[
i
],
false
,
true
,
maxCubemapSize
);
}
else
{
...
...
@@ -407,7 +413,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
}
var
image
=
cubeImage
[
0
],
supportsMips
=
isPowerOfTwo
(
image
)
||
capabilities
.
isWebGL2
,
supportsMips
=
isPowerOfTwo
(
image
)
||
isWebGL2
,
glFormat
=
utils
.
convert
(
texture
.
format
),
glType
=
utils
.
convert
(
texture
.
type
),
glInternalFormat
=
getInternalFormat
(
glFormat
,
glType
);
...
...
@@ -567,7 +573,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
if
(
extension
)
{
if
(
texture
.
type
===
FloatType
&&
extensions
.
get
(
'
OES_texture_float_linear
'
)
===
null
)
return
;
if
(
texture
.
type
===
HalfFloatType
&&
(
capabilities
.
isWebGL2
||
extensions
.
get
(
'
OES_texture_half_float_linear
'
)
)
===
null
)
return
;
if
(
texture
.
type
===
HalfFloatType
&&
(
isWebGL2
||
extensions
.
get
(
'
OES_texture_half_float_linear
'
)
)
===
null
)
return
;
if
(
texture
.
anisotropy
>
1
||
properties
.
get
(
texture
).
__currentAnisotropy
)
{
...
...
@@ -613,9 +619,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
_gl
.
pixelStorei
(
_gl
.
UNPACK_ALIGNMENT
,
texture
.
unpackAlignment
);
var
needsPowerOfTwo
=
textureNeedsPowerOfTwo
(
texture
)
&&
isPowerOfTwo
(
texture
.
image
)
===
false
;
var
image
=
resizeImage
(
texture
.
image
,
needsPowerOfTwo
,
false
,
capabilities
.
maxTextureSize
);
var
image
=
resizeImage
(
texture
.
image
,
needsPowerOfTwo
,
false
,
maxTextureSize
);
var
supportsMips
=
isPowerOfTwo
(
image
)
||
capabilities
.
isWebGL2
,
var
supportsMips
=
isPowerOfTwo
(
image
)
||
isWebGL2
,
glFormat
=
utils
.
convert
(
texture
.
format
),
glType
=
utils
.
convert
(
texture
.
type
),
glInternalFormat
=
getInternalFormat
(
glFormat
,
glType
);
...
...
@@ -632,10 +638,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
if
(
texture
.
type
===
FloatType
)
{
if
(
!
capabilities
.
isWebGL2
)
throw
new
Error
(
'
Float Depth Texture only supported in WebGL2.0
'
);
if
(
isWebGL2
===
false
)
throw
new
Error
(
'
Float Depth Texture only supported in WebGL2.0
'
);
glInternalFormat
=
_gl
.
DEPTH_COMPONENT32F
;
}
else
if
(
capabilities
.
isWebGL2
)
{
}
else
if
(
isWebGL2
)
{
// WebGL 2.0 requires signed internalformat for glTexImage2D
glInternalFormat
=
_gl
.
DEPTH_COMPONENT16
;
...
...
@@ -962,7 +968,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
var
isCube
=
(
renderTarget
.
isWebGLRenderTargetCube
===
true
);
var
isMultisample
=
(
renderTarget
.
isWebGLMultisampleRenderTarget
===
true
);
var
isMultiview
=
(
renderTarget
.
isWebGLMultiviewRenderTarget
===
true
);
var
supportsMips
=
isPowerOfTwo
(
renderTarget
)
||
capabilities
.
isWebGL2
;
var
supportsMips
=
isPowerOfTwo
(
renderTarget
)
||
isWebGL2
;
// Setup framebuffer
...
...
@@ -982,7 +988,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
if
(
isMultisample
)
{
if
(
capabilities
.
isWebGL2
)
{
if
(
isWebGL2
)
{
renderTargetProperties
.
__webglMultisampledFramebuffer
=
_gl
.
createFramebuffer
();
renderTargetProperties
.
__webglColorRenderbuffer
=
_gl
.
createRenderbuffer
();
...
...
@@ -1110,7 +1116,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
function
updateRenderTargetMipmap
(
renderTarget
)
{
var
texture
=
renderTarget
.
texture
;
var
supportsMips
=
isPowerOfTwo
(
renderTarget
)
||
capabilities
.
isWebGL2
;
var
supportsMips
=
isPowerOfTwo
(
renderTarget
)
||
isWebGL2
;
if
(
textureNeedsGenerateMipmaps
(
texture
,
supportsMips
)
)
{
...
...
@@ -1129,7 +1135,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
if
(
renderTarget
.
isWebGLMultisampleRenderTarget
)
{
if
(
capabilities
.
isWebGL2
)
{
if
(
isWebGL2
)
{
var
renderTargetProperties
=
properties
.
get
(
renderTarget
);
...
...
@@ -1157,8 +1163,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
function
getRenderTargetSamples
(
renderTarget
)
{
return
(
capabilities
.
isWebGL2
&&
renderTarget
.
isWebGLMultisampleRenderTarget
)
?
Math
.
min
(
capabilities
.
maxSamples
,
renderTarget
.
samples
)
:
0
;
return
(
isWebGL2
&&
renderTarget
.
isWebGLMultisampleRenderTarget
)
?
Math
.
min
(
maxSamples
,
renderTarget
.
samples
)
:
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录