Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
a881ec50
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,发现更多精彩内容 >>
提交
a881ec50
编写于
10月 14, 2014
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WebGLRenderer: Refactored extensions code.
Also trying to only call gl.getExtension() when needed.
上级
3eb04f4d
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
134 addition
and
100 deletion
+134
-100
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+66
-100
src/renderers/webgl/WebGLExtensions.js
src/renderers/webgl/WebGLExtensions.js
+67
-0
utils/build/includes/common.json
utils/build/includes/common.json
+1
-0
未找到文件。
src/renderers/WebGLRenderer.js
浏览文件 @
a881ec50
...
...
@@ -184,16 +184,6 @@ THREE.WebGLRenderer = function ( parameters ) {
var
_gl
;
var
_glExtensionTextureFloat
;
var
_glExtensionTextureFloatLinear
;
var
_glExtensionStandardDerivatives
;
var
_glExtensionTextureFilterAnisotropic
;
var
_glExtensionCompressedTextureS3TC
;
var
_glExtensionCompressedTexturePVRTC
;
var
_glExtensionElementIndexUint
;
var
_glExtensionFragDepth
;
var
_glExtensionBlendMinMax
;
try
{
var
attributes
=
{
...
...
@@ -219,63 +209,6 @@ THREE.WebGLRenderer = function ( parameters ) {
}
_glExtensionTextureFloat
=
_gl
.
getExtension
(
'
OES_texture_float
'
);
_glExtensionTextureFloatLinear
=
_gl
.
getExtension
(
'
OES_texture_float_linear
'
);
if
(
_glExtensionTextureFloat
===
null
)
{
console
.
log
(
'
THREE.WebGLRenderer: Float textures not supported.
'
);
}
_glExtensionStandardDerivatives
=
_gl
.
getExtension
(
'
OES_standard_derivatives
'
);
if
(
_glExtensionStandardDerivatives
===
null
)
{
console
.
log
(
'
THREE.WebGLRenderer: Standard derivatives not supported.
'
);
}
_glExtensionTextureFilterAnisotropic
=
_gl
.
getExtension
(
'
EXT_texture_filter_anisotropic
'
)
||
_gl
.
getExtension
(
'
MOZ_EXT_texture_filter_anisotropic
'
)
||
_gl
.
getExtension
(
'
WEBKIT_EXT_texture_filter_anisotropic
'
);
if
(
_glExtensionTextureFilterAnisotropic
===
null
)
{
console
.
log
(
'
THREE.WebGLRenderer: Anisotropic texture filtering not supported.
'
);
}
_glExtensionCompressedTextureS3TC
=
_gl
.
getExtension
(
'
WEBGL_compressed_texture_s3tc
'
)
||
_gl
.
getExtension
(
'
MOZ_WEBGL_compressed_texture_s3tc
'
)
||
_gl
.
getExtension
(
'
WEBKIT_WEBGL_compressed_texture_s3tc
'
);
if
(
_glExtensionCompressedTextureS3TC
===
null
)
{
console
.
log
(
'
THREE.WebGLRenderer: S3TC compressed textures not supported.
'
);
}
_glExtensionCompressedTexturePVRTC
=
_gl
.
getExtension
(
'
WEBGL_compressed_texture_pvrtc
'
)
||
_gl
.
getExtension
(
'
WEBKIT_WEBGL_compressed_texture_pvrtc
'
);
if
(
_glExtensionCompressedTexturePVRTC
===
null
)
{
console
.
log
(
'
THREE.WebGLRenderer: PVRTC compressed textures not supported.
'
);
}
_glExtensionElementIndexUint
=
_gl
.
getExtension
(
'
OES_element_index_uint
'
);
if
(
_glExtensionElementIndexUint
===
null
)
{
console
.
log
(
'
THREE.WebGLRenderer: elementindex as unsigned integer not supported.
'
);
}
_glExtensionBlendMinMax
=
_gl
.
getExtension
(
'
EXT_blend_minmax
'
);
if
(
_glExtensionBlendMinMax
===
null
)
{
console
.
log
(
'
THREE.WebGLRenderer: min max blend equations not supported.
'
);
}
if
(
_gl
.
getShaderPrecisionFormat
===
undefined
)
{
_gl
.
getShaderPrecisionFormat
=
function
()
{
...
...
@@ -289,9 +222,11 @@ THREE.WebGLRenderer = function ( parameters ) {
}
}
var
extensions
=
new
THREE
.
WebGLExtensions
(
_gl
);
if
(
_logarithmicDepthBuffer
)
{
_glExtensionFragDepth
=
_gl
.
getExtension
(
'
EXT_frag_depth
'
);
extensions
.
get
(
'
EXT_frag_depth
'
);
}
...
...
@@ -331,20 +266,23 @@ THREE.WebGLRenderer = function ( parameters ) {
var
_maxTextureSize
=
_gl
.
getParameter
(
_gl
.
MAX_TEXTURE_SIZE
);
var
_maxCubemapSize
=
_gl
.
getParameter
(
_gl
.
MAX_CUBE_MAP_TEXTURE_SIZE
);
var
_maxAnisotropy
=
_glExtensionTextureFilterAnisotropic
?
_gl
.
getParameter
(
_glExtensionTextureFilterAnisotropic
.
MAX_TEXTURE_MAX_ANISOTROPY_EXT
)
:
0
;
var
_supportsVertexTextures
=
(
_maxVertexTextures
>
0
);
var
_supportsBoneTextures
=
_supportsVertexTextures
&&
_glExtensionTextureFloat
;
var
_supportsVertexTextures
=
_maxVertexTextures
>
0
;
var
_supportsBoneTextures
=
_supportsVertexTextures
&&
extensions
.
get
(
'
OES_texture_float
'
);
// COMPRESSED_TEXTURE_FORMATS return IntArray
// but we need Array.indexOf to test formats availabilities
var
_compressedTextureFormats
=
[];
if
(
_glExtensionCompressedTexturePVRTC
||
_glExtensionCompressedTextureS3TC
)
{
if
(
extensions
.
get
(
'
WEBGL_compressed_texture_pvrtc
'
)
||
extensions
.
get
(
'
WEBGL_compressed_texture_s3tc
'
)
)
{
var
compressedfmts
=
_gl
.
getParameter
(
_gl
.
COMPRESSED_TEXTURE_FORMATS
);
for
(
var
i
=
0
;
i
<
compressedfmts
.
length
;
i
++
){
_compressedTextureFormats
.
push
(
compressedfmts
[
i
]
);
for
(
var
i
=
0
;
i
<
compressedfmts
.
length
;
i
++
){
_compressedTextureFormats
.
push
(
compressedfmts
[
i
]
);
}
}
...
...
@@ -402,39 +340,55 @@ THREE.WebGLRenderer = function ( parameters ) {
this
.
supportsFloatTextures
=
function
()
{
return
_glExtensionTextureFloat
;
return
extensions
.
get
(
'
OES_texture_float
'
)
;
};
this
.
supportsStandardDerivatives
=
function
()
{
return
_glExtensionStandardDerivatives
;
return
extensions
.
get
(
'
OES_standard_derivatives
'
)
;
};
this
.
supportsCompressedTextureS3TC
=
function
()
{
return
_glExtensionCompressedTextureS3TC
;
return
extensions
.
get
(
'
WEBGL_compressed_texture_s3tc
'
)
;
};
this
.
supportsCompressedTexturePVRTC
=
function
()
{
return
_glExtensionCompressedTexturePVRTC
;
return
extensions
.
get
(
'
WEBGL_compressed_texture_pvrtc
'
)
;
};
this
.
supportsBlendMinMax
=
function
()
{
return
_glExtensionBlendMinMax
;
return
extensions
.
get
(
'
EXT_blend_minmax
'
)
;
};
this
.
getMaxAnisotropy
=
function
()
{
this
.
getMaxAnisotropy
=
(
function
()
{
return
_maxAnisotropy
;
var
value
;
};
return
function
()
{
if
(
value
!==
undefined
)
{
return
value
;
}
var
extension
=
extensions
.
get
(
'
EXT_texture_filter_anisotropic
'
);
value
=
extension
!==
null
?
_gl
.
getParameter
(
extension
.
MAX_TEXTURE_MAX_ANISOTROPY_EXT
)
:
0
;
return
value
;
}
}
)();
this
.
getPrecision
=
function
()
{
...
...
@@ -1099,7 +1053,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
var
UintArray
=
_glExtensionElementIndexUint
!==
null
&&
ntris
>
21845
?
Uint32Array
:
Uint16Array
;
// 65535 / 3
var
UintArray
=
extensions
.
get
(
'
OES_element_index_uint
'
)
!==
null
&&
ntris
>
21845
?
Uint32Array
:
Uint16Array
;
// 65535 / 3
geometryGroup
.
__typeArray
=
UintArray
;
geometryGroup
.
__faceArray
=
new
UintArray
(
ntris
*
3
);
...
...
@@ -3943,7 +3897,7 @@ THREE.WebGLRenderer = function ( parameters ) {
delete
_webglObjects
[
object
.
id
];
geometryGroups
[
geometry
.
id
]
=
makeGroups
(
geometry
,
material
instanceof
THREE
.
MeshFaceMaterial
,
_glExtensionElementIndexUint
?
4294967296
:
65535
);
geometryGroups
[
geometry
.
id
]
=
makeGroups
(
geometry
,
material
instanceof
THREE
.
MeshFaceMaterial
,
extensions
.
get
(
'
OES_element_index_uint
'
)
?
4294967296
:
65535
);
geometry
.
groupsNeedUpdate
=
false
;
...
...
@@ -5784,6 +5738,8 @@ THREE.WebGLRenderer = function ( parameters ) {
function
setTextureParameters
(
textureType
,
texture
,
isImagePowerOfTwo
)
{
var
extension
;
if
(
isImagePowerOfTwo
)
{
_gl
.
texParameteri
(
textureType
,
_gl
.
TEXTURE_WRAP_S
,
paramThreeToGL
(
texture
.
wrapS
)
);
...
...
@@ -5802,11 +5758,13 @@ THREE.WebGLRenderer = function ( parameters ) {
}
if
(
_glExtensionTextureFilterAnisotropic
&&
texture
.
type
!==
THREE
.
FloatType
)
{
extension
=
extensions
.
get
(
'
EXT_texture_filter_anisotropic
'
);
if
(
extension
&&
texture
.
type
!==
THREE
.
FloatType
)
{
if
(
texture
.
anisotropy
>
1
||
texture
.
__oldAnisotropy
)
{
_gl
.
texParameterf
(
textureType
,
_glExtensionTextureFilterAnisotropic
.
TEXTURE_MAX_ANISOTROPY_EXT
,
Math
.
min
(
texture
.
anisotropy
,
_maxAnisotropy
)
);
_gl
.
texParameterf
(
textureType
,
extension
.
TEXTURE_MAX_ANISOTROPY_EXT
,
Math
.
min
(
texture
.
anisotropy
,
_this
.
getMaxAnisotropy
()
)
);
texture
.
__oldAnisotropy
=
texture
.
anisotropy
;
}
...
...
@@ -6313,6 +6271,8 @@ THREE.WebGLRenderer = function ( parameters ) {
function
paramThreeToGL
(
p
)
{
var
extension
;
if
(
p
===
THREE
.
RepeatWrapping
)
return
_gl
.
REPEAT
;
if
(
p
===
THREE
.
ClampToEdgeWrapping
)
return
_gl
.
CLAMP_TO_EDGE
;
if
(
p
===
THREE
.
MirroredRepeatWrapping
)
return
_gl
.
MIRRORED_REPEAT
;
...
...
@@ -6360,28 +6320,34 @@ THREE.WebGLRenderer = function ( parameters ) {
if
(
p
===
THREE
.
OneMinusDstColorFactor
)
return
_gl
.
ONE_MINUS_DST_COLOR
;
if
(
p
===
THREE
.
SrcAlphaSaturateFactor
)
return
_gl
.
SRC_ALPHA_SATURATE
;
if
(
_glExtensionCompressedTextureS3TC
!==
null
)
{
extension
=
extensions
.
get
(
'
WEBGL_compressed_texture_s3tc
'
);
if
(
p
===
THREE
.
RGB_S3TC_DXT1_Format
)
return
_glExtensionCompressedTextureS3TC
.
COMPRESSED_RGB_S3TC_DXT1_EXT
;
if
(
p
===
THREE
.
RGBA_S3TC_DXT1_Format
)
return
_glExtensionCompressedTextureS3TC
.
COMPRESSED_RGBA_S3TC_DXT1_EXT
;
if
(
p
===
THREE
.
RGBA_S3TC_DXT3_Format
)
return
_glExtensionCompressedTextureS3TC
.
COMPRESSED_RGBA_S3TC_DXT3_EXT
;
if
(
p
===
THREE
.
RGBA_S3TC_DXT5_Format
)
return
_glExtensionCompressedTextureS3TC
.
COMPRESSED_RGBA_S3TC_DXT5_EXT
;
if
(
extension
!==
null
)
{
if
(
p
===
THREE
.
RGB_S3TC_DXT1_Format
)
return
extension
.
COMPRESSED_RGB_S3TC_DXT1_EXT
;
if
(
p
===
THREE
.
RGBA_S3TC_DXT1_Format
)
return
extension
.
COMPRESSED_RGBA_S3TC_DXT1_EXT
;
if
(
p
===
THREE
.
RGBA_S3TC_DXT3_Format
)
return
extension
.
COMPRESSED_RGBA_S3TC_DXT3_EXT
;
if
(
p
===
THREE
.
RGBA_S3TC_DXT5_Format
)
return
extension
.
COMPRESSED_RGBA_S3TC_DXT5_EXT
;
}
if
(
_glExtensionCompressedTexturePVRTC
!==
null
)
{
extension
=
extensions
.
get
(
'
WEBGL_compressed_texture_pvrtc
'
);
if
(
extension
!==
null
)
{
if
(
p
===
THREE
.
RGB_PVRTC_4BPPV1_Format
)
return
_glExtensionCompressedTexturePVRTC
.
COMPRESSED_RGB_PVRTC_4BPPV1_IMG
;
if
(
p
===
THREE
.
RGB_PVRTC_2BPPV1_Format
)
return
_glExtensionCompressedTexturePVRTC
.
COMPRESSED_RGB_PVRTC_2BPPV1_IMG
;
if
(
p
===
THREE
.
RGBA_PVRTC_4BPPV1_Format
)
return
_glExtensionCompressedTexturePVRTC
.
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
;
if
(
p
===
THREE
.
RGBA_PVRTC_2BPPV1_Format
)
return
_glExtensionCompressedTexturePVRTC
.
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
;
if
(
p
===
THREE
.
RGB_PVRTC_4BPPV1_Format
)
return
extension
.
COMPRESSED_RGB_PVRTC_4BPPV1_IMG
;
if
(
p
===
THREE
.
RGB_PVRTC_2BPPV1_Format
)
return
extension
.
COMPRESSED_RGB_PVRTC_2BPPV1_IMG
;
if
(
p
===
THREE
.
RGBA_PVRTC_4BPPV1_Format
)
return
extension
.
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
;
if
(
p
===
THREE
.
RGBA_PVRTC_2BPPV1_Format
)
return
extension
.
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
;
}
if
(
_glExtensionBlendMinMax
!==
undefined
)
{
extension
=
extensions
.
get
(
'
EXT_blend_minmax
'
);
if
(
extension
!==
null
)
{
if
(
p
===
THREE
.
MinEquation
)
return
_glExtensionBlendMinMax
.
MIN_EXT
;
if
(
p
===
THREE
.
MaxEquation
)
return
_glExtensionBlendMinMax
.
MAX_EXT
;
if
(
p
===
THREE
.
MinEquation
)
return
extension
.
MIN_EXT
;
if
(
p
===
THREE
.
MaxEquation
)
return
extension
.
MAX_EXT
;
}
...
...
src/renderers/webgl/WebGLExtensions.js
0 → 100644
浏览文件 @
a881ec50
THREE
.
WebGLExtensions
=
function
(
gl
)
{
var
extensions
=
{};
this
.
get
=
function
(
name
)
{
if
(
extensions
[
name
]
!==
undefined
)
{
return
extensions
[
name
];
}
var
extension
;
switch
(
name
)
{
case
'
OES_texture_float
'
:
extension
=
gl
.
getExtension
(
'
OES_texture_float
'
);
break
;
case
'
OES_texture_float_linear
'
:
extension
=
gl
.
getExtension
(
'
OES_texture_float_linear
'
);
break
;
case
'
OES_standard_derivatives
'
:
extension
=
gl
.
getExtension
(
'
OES_standard_derivatives
'
);
break
;
case
'
EXT_texture_filter_anisotropic
'
:
extension
=
gl
.
getExtension
(
'
EXT_texture_filter_anisotropic
'
)
||
gl
.
getExtension
(
'
MOZ_EXT_texture_filter_anisotropic
'
)
||
gl
.
getExtension
(
'
WEBKIT_EXT_texture_filter_anisotropic
'
);
break
;
case
'
WEBGL_compressed_texture_s3tc
'
:
extension
=
gl
.
getExtension
(
'
WEBGL_compressed_texture_s3tc
'
)
||
gl
.
getExtension
(
'
MOZ_WEBGL_compressed_texture_s3tc
'
)
||
gl
.
getExtension
(
'
WEBKIT_WEBGL_compressed_texture_s3tc
'
);
break
;
case
'
WEBGL_compressed_texture_pvrtc
'
:
extension
=
gl
.
getExtension
(
'
WEBGL_compressed_texture_pvrtc
'
)
||
gl
.
getExtension
(
'
WEBKIT_WEBGL_compressed_texture_pvrtc
'
);
break
;
case
'
OES_element_index_uint
'
:
extension
=
gl
.
getExtension
(
'
OES_element_index_uint
'
);
break
;
case
'
EXT_blend_minmax
'
:
extension
=
gl
.
getExtension
(
'
EXT_blend_minmax
'
);
break
;
case
'
EXT_frag_depth
'
:
extension
=
gl
.
getExtension
(
'
EXT_frag_depth
'
);
break
;
}
if
(
extension
===
null
)
{
console
.
log
(
'
THREE.WebGLRenderer:
'
+
name
+
'
extension not supported.
'
);
}
extensions
[
name
]
=
extension
;
return
extension
;
};
};
utils/build/includes/common.json
浏览文件 @
a881ec50
...
...
@@ -140,6 +140,7 @@
"src/renderers/WebGLRenderer.js"
,
"src/renderers/WebGLRenderTarget.js"
,
"src/renderers/WebGLRenderTargetCube.js"
,
"src/renderers/webgl/WebGLExtensions.js"
,
"src/renderers/webgl/WebGLProgram.js"
,
"src/renderers/webgl/WebGLShader.js"
]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录