Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
5219c0f1
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,发现更多精彩内容 >>
提交
5219c0f1
编写于
3月 31, 2018
作者:
T
Takahiro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Save isWebGL2 to WebGL context object
上级
b53cec23
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
19 addition
and
30 deletion
+19
-30
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+2
-0
src/renderers/webgl/WebGLBufferRenderer.js
src/renderers/webgl/WebGLBufferRenderer.js
+2
-4
src/renderers/webgl/WebGLExtensions.js
src/renderers/webgl/WebGLExtensions.js
+2
-4
src/renderers/webgl/WebGLIndexedBufferRenderer.js
src/renderers/webgl/WebGLIndexedBufferRenderer.js
+1
-3
src/renderers/webgl/WebGLProgram.js
src/renderers/webgl/WebGLProgram.js
+2
-4
src/renderers/webgl/WebGLState.js
src/renderers/webgl/WebGLState.js
+2
-4
src/renderers/webgl/WebGLTextures.js
src/renderers/webgl/WebGLTextures.js
+5
-6
src/renderers/webgl/WebGLUtils.js
src/renderers/webgl/WebGLUtils.js
+3
-5
未找到文件。
src/renderers/WebGLRenderer.js
浏览文件 @
5219c0f1
...
@@ -211,6 +211,8 @@ function WebGLRenderer( parameters ) {
...
@@ -211,6 +211,8 @@ function WebGLRenderer( parameters ) {
}
}
_gl
.
isWebGL2
=
typeof
WebGL2RenderingContext
!==
'
undefined
'
&&
_gl
instanceof
WebGL2RenderingContext
;
// Some experimental-webgl implementations do not have getShaderPrecisionFormat
// Some experimental-webgl implementations do not have getShaderPrecisionFormat
if
(
_gl
.
getShaderPrecisionFormat
===
undefined
)
{
if
(
_gl
.
getShaderPrecisionFormat
===
undefined
)
{
...
...
src/renderers/webgl/WebGLBufferRenderer.js
浏览文件 @
5219c0f1
...
@@ -4,8 +4,6 @@
...
@@ -4,8 +4,6 @@
function
WebGLBufferRenderer
(
gl
,
extensions
,
info
)
{
function
WebGLBufferRenderer
(
gl
,
extensions
,
info
)
{
var
isWebGL2
=
typeof
WebGL2RenderingContext
!==
'
undefined
'
&&
gl
instanceof
WebGL2RenderingContext
;
var
mode
;
var
mode
;
function
setMode
(
value
)
{
function
setMode
(
value
)
{
...
@@ -39,11 +37,11 @@ function WebGLBufferRenderer( gl, extensions, info ) {
...
@@ -39,11 +37,11 @@ function WebGLBufferRenderer( gl, extensions, info ) {
count
=
position
.
data
.
count
;
count
=
position
.
data
.
count
;
extension
[
isWebGL2
?
'
drawArraysInstanced
'
:
'
drawArraysInstancedANGLE
'
](
mode
,
0
,
count
,
geometry
.
maxInstancedCount
);
extension
[
gl
.
isWebGL2
?
'
drawArraysInstanced
'
:
'
drawArraysInstancedANGLE
'
](
mode
,
0
,
count
,
geometry
.
maxInstancedCount
);
}
else
{
}
else
{
extension
[
isWebGL2
?
'
drawArraysInstanced
'
:
'
drawArraysInstancedANGLE
'
](
mode
,
start
,
count
,
geometry
.
maxInstancedCount
);
extension
[
gl
.
isWebGL2
?
'
drawArraysInstanced
'
:
'
drawArraysInstancedANGLE
'
](
mode
,
start
,
count
,
geometry
.
maxInstancedCount
);
}
}
...
...
src/renderers/webgl/WebGLExtensions.js
浏览文件 @
5219c0f1
...
@@ -6,8 +6,6 @@ function WebGLExtensions( gl ) {
...
@@ -6,8 +6,6 @@ function WebGLExtensions( gl ) {
var
extensions
=
{};
var
extensions
=
{};
var
isWebGL2
=
(
typeof
WebGL2RenderingContext
!==
'
undefined
'
&&
gl
instanceof
WebGL2RenderingContext
);
return
{
return
{
get
:
function
(
name
)
{
get
:
function
(
name
)
{
...
@@ -24,7 +22,7 @@ function WebGLExtensions( gl ) {
...
@@ -24,7 +22,7 @@ function WebGLExtensions( gl ) {
case
'
WEBGL_depth_texture
'
:
case
'
WEBGL_depth_texture
'
:
if
(
isWebGL2
)
{
if
(
gl
.
isWebGL2
)
{
extension
=
gl
;
extension
=
gl
;
...
@@ -54,7 +52,7 @@ function WebGLExtensions( gl ) {
...
@@ -54,7 +52,7 @@ function WebGLExtensions( gl ) {
default
:
default
:
if
(
isWebGL2
&&
if
(
gl
.
isWebGL2
&&
[
'
ANGLE_instanced_arrays
'
,
[
'
ANGLE_instanced_arrays
'
,
'
OES_texture_float
'
,
'
OES_texture_float
'
,
'
OES_texture_half_float
'
,
'
OES_texture_half_float
'
,
...
...
src/renderers/webgl/WebGLIndexedBufferRenderer.js
浏览文件 @
5219c0f1
...
@@ -4,8 +4,6 @@
...
@@ -4,8 +4,6 @@
function
WebGLIndexedBufferRenderer
(
gl
,
extensions
,
info
)
{
function
WebGLIndexedBufferRenderer
(
gl
,
extensions
,
info
)
{
var
isWebGL2
=
typeof
WebGL2RenderingContext
!==
'
undefined
'
&&
gl
instanceof
WebGL2RenderingContext
;
var
mode
;
var
mode
;
function
setMode
(
value
)
{
function
setMode
(
value
)
{
...
@@ -42,7 +40,7 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
...
@@ -42,7 +40,7 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
}
}
extension
[
isWebGL2
?
'
drawElementsInstanced
'
:
'
drawElementsInstancedANGLE
'
](
mode
,
count
,
type
,
start
*
bytesPerElement
,
geometry
.
maxInstancedCount
);
extension
[
gl
.
isWebGL2
?
'
drawElementsInstanced
'
:
'
drawElementsInstancedANGLE
'
](
mode
,
count
,
type
,
start
*
bytesPerElement
,
geometry
.
maxInstancedCount
);
info
.
update
(
count
,
mode
,
geometry
.
maxInstancedCount
);
info
.
update
(
count
,
mode
,
geometry
.
maxInstancedCount
);
...
...
src/renderers/webgl/WebGLProgram.js
浏览文件 @
5219c0f1
...
@@ -206,8 +206,6 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters
...
@@ -206,8 +206,6 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters
var
gl
=
renderer
.
context
;
var
gl
=
renderer
.
context
;
var
isWebGL2
=
typeof
WebGL2RenderingContext
!==
'
undefined
'
&&
gl
instanceof
WebGL2RenderingContext
;
var
defines
=
material
.
defines
;
var
defines
=
material
.
defines
;
var
vertexShader
=
shader
.
vertexShader
;
var
vertexShader
=
shader
.
vertexShader
;
...
@@ -287,7 +285,7 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters
...
@@ -287,7 +285,7 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters
//
//
var
customExtensions
=
isWebGL2
?
''
:
generateExtensions
(
material
.
extensions
,
parameters
,
extensions
);
var
customExtensions
=
gl
.
isWebGL2
?
''
:
generateExtensions
(
material
.
extensions
,
parameters
,
extensions
);
var
customDefines
=
generateDefines
(
defines
);
var
customDefines
=
generateDefines
(
defines
);
...
@@ -516,7 +514,7 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters
...
@@ -516,7 +514,7 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters
vertexShader
=
unrollLoops
(
vertexShader
);
vertexShader
=
unrollLoops
(
vertexShader
);
fragmentShader
=
unrollLoops
(
fragmentShader
);
fragmentShader
=
unrollLoops
(
fragmentShader
);
if
(
isWebGL2
&&
!
material
.
isRawShaderMaterial
)
{
if
(
gl
.
isWebGL2
&&
!
material
.
isRawShaderMaterial
)
{
var
isGLSL3ShaderMaterial
=
material
.
isShaderMaterial
&&
material
.
isGLSL3
;
var
isGLSL3ShaderMaterial
=
material
.
isShaderMaterial
&&
material
.
isGLSL3
;
...
...
src/renderers/webgl/WebGLState.js
浏览文件 @
5219c0f1
...
@@ -7,8 +7,6 @@ import { Vector4 } from '../../math/Vector4.js';
...
@@ -7,8 +7,6 @@ import { Vector4 } from '../../math/Vector4.js';
function
WebGLState
(
gl
,
extensions
,
utils
)
{
function
WebGLState
(
gl
,
extensions
,
utils
)
{
var
isWebGL2
=
typeof
WebGL2RenderingContext
!==
'
undefined
'
&&
gl
instanceof
WebGL2RenderingContext
;
function
ColorBuffer
()
{
function
ColorBuffer
()
{
var
locked
=
false
;
var
locked
=
false
;
...
@@ -432,7 +430,7 @@ function WebGLState( gl, extensions, utils ) {
...
@@ -432,7 +430,7 @@ function WebGLState( gl, extensions, utils ) {
var
extension
=
extensions
.
get
(
'
ANGLE_instanced_arrays
'
);
var
extension
=
extensions
.
get
(
'
ANGLE_instanced_arrays
'
);
extension
[
isWebGL2
?
'
vertexAttribDivisor
'
:
'
vertexAttribDivisorANGLE
'
](
attribute
,
0
);
extension
[
gl
.
isWebGL2
?
'
vertexAttribDivisor
'
:
'
vertexAttribDivisorANGLE
'
](
attribute
,
0
);
attributeDivisors
[
attribute
]
=
0
;
attributeDivisors
[
attribute
]
=
0
;
}
}
...
@@ -454,7 +452,7 @@ function WebGLState( gl, extensions, utils ) {
...
@@ -454,7 +452,7 @@ function WebGLState( gl, extensions, utils ) {
var
extension
=
extensions
.
get
(
'
ANGLE_instanced_arrays
'
);
var
extension
=
extensions
.
get
(
'
ANGLE_instanced_arrays
'
);
extension
[
isWebGL2
?
'
vertexAttribDivisor
'
:
'
vertexAttribDivisorANGLE
'
](
attribute
,
meshPerAttribute
);
extension
[
gl
.
isWebGL2
?
'
vertexAttribDivisor
'
:
'
vertexAttribDivisorANGLE
'
](
attribute
,
meshPerAttribute
);
attributeDivisors
[
attribute
]
=
meshPerAttribute
;
attributeDivisors
[
attribute
]
=
meshPerAttribute
;
}
}
...
...
src/renderers/webgl/WebGLTextures.js
浏览文件 @
5219c0f1
...
@@ -7,7 +7,6 @@ import { _Math } from '../../math/Math.js';
...
@@ -7,7 +7,6 @@ import { _Math } from '../../math/Math.js';
function
WebGLTextures
(
_gl
,
extensions
,
state
,
properties
,
capabilities
,
utils
,
info
)
{
function
WebGLTextures
(
_gl
,
extensions
,
state
,
properties
,
capabilities
,
utils
,
info
)
{
var
_isWebGL2
=
(
typeof
WebGL2RenderingContext
!==
'
undefined
'
&&
_gl
instanceof
WebGL2RenderingContext
);
/* global WebGL2RenderingContext */
var
_videoTextures
=
{};
var
_videoTextures
=
{};
var
_canvas
;
var
_canvas
;
...
@@ -76,7 +75,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
...
@@ -76,7 +75,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
function
textureNeedsPowerOfTwo
(
texture
)
{
function
textureNeedsPowerOfTwo
(
texture
)
{
if
(
_isWebGL2
)
return
false
;
if
(
_
gl
.
isWebGL2
)
return
false
;
return
(
texture
.
wrapS
!==
ClampToEdgeWrapping
||
texture
.
wrapT
!==
ClampToEdgeWrapping
)
||
return
(
texture
.
wrapS
!==
ClampToEdgeWrapping
||
texture
.
wrapT
!==
ClampToEdgeWrapping
)
||
(
texture
.
minFilter
!==
NearestFilter
&&
texture
.
minFilter
!==
LinearFilter
);
(
texture
.
minFilter
!==
NearestFilter
&&
texture
.
minFilter
!==
LinearFilter
);
...
@@ -101,7 +100,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
...
@@ -101,7 +100,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
function
getInternalFormat
(
glFormat
,
glType
)
{
function
getInternalFormat
(
glFormat
,
glType
)
{
if
(
!
_isWebGL2
)
return
glFormat
;
if
(
!
_
gl
.
isWebGL2
)
return
glFormat
;
if
(
glFormat
===
_gl
.
RGB
)
{
if
(
glFormat
===
_gl
.
RGB
)
{
...
@@ -505,10 +504,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
...
@@ -505,10 +504,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
if
(
texture
.
type
===
FloatType
)
{
if
(
texture
.
type
===
FloatType
)
{
if
(
!
_isWebGL2
)
throw
new
Error
(
'
Float Depth Texture only supported in WebGL2.0
'
);
if
(
!
_
gl
.
isWebGL2
)
throw
new
Error
(
'
Float Depth Texture only supported in WebGL2.0
'
);
glInternalFormat
=
_gl
.
DEPTH_COMPONENT32F
;
glInternalFormat
=
_gl
.
DEPTH_COMPONENT32F
;
}
else
if
(
_isWebGL2
)
{
}
else
if
(
_
gl
.
isWebGL2
)
{
// WebGL 2.0 requires signed internalformat for glTexImage2D
// WebGL 2.0 requires signed internalformat for glTexImage2D
glInternalFormat
=
_gl
.
DEPTH_COMPONENT16
;
glInternalFormat
=
_gl
.
DEPTH_COMPONENT16
;
...
@@ -655,7 +654,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
...
@@ -655,7 +654,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
var
glFormat
=
utils
.
convert
(
renderTarget
.
texture
.
format
);
var
glFormat
=
utils
.
convert
(
renderTarget
.
texture
.
format
);
var
glType
=
utils
.
convert
(
renderTarget
.
texture
.
type
);
var
glType
=
utils
.
convert
(
renderTarget
.
texture
.
type
);
var
glInternalFormat
=
getInternalFormat
(
glFormat
,
glType
);
var
glInternalFormat
=
getInternalFormat
(
glFormat
,
glType
);
var
array
=
(
_isWebGL2
)
?
new
Uint8Array
(
renderTarget
.
width
*
renderTarget
.
height
*
4
)
:
null
;
var
array
=
(
_
gl
.
isWebGL2
)
?
new
Uint8Array
(
renderTarget
.
width
*
renderTarget
.
height
*
4
)
:
null
;
state
.
texImage2D
(
textureTarget
,
0
,
glInternalFormat
,
renderTarget
.
width
,
renderTarget
.
height
,
0
,
glFormat
,
glType
,
array
);
state
.
texImage2D
(
textureTarget
,
0
,
glInternalFormat
,
renderTarget
.
width
,
renderTarget
.
height
,
0
,
glFormat
,
glType
,
array
);
_gl
.
bindFramebuffer
(
_gl
.
FRAMEBUFFER
,
framebuffer
);
_gl
.
bindFramebuffer
(
_gl
.
FRAMEBUFFER
,
framebuffer
);
_gl
.
framebufferTexture2D
(
_gl
.
FRAMEBUFFER
,
attachment
,
textureTarget
,
properties
.
get
(
renderTarget
.
texture
).
__webglTexture
,
0
);
_gl
.
framebufferTexture2D
(
_gl
.
FRAMEBUFFER
,
attachment
,
textureTarget
,
properties
.
get
(
renderTarget
.
texture
).
__webglTexture
,
0
);
...
...
src/renderers/webgl/WebGLUtils.js
浏览文件 @
5219c0f1
...
@@ -6,8 +6,6 @@ import { MaxEquation, MinEquation, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, R
...
@@ -6,8 +6,6 @@ import { MaxEquation, MinEquation, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, R
function
WebGLUtils
(
gl
,
extensions
)
{
function
WebGLUtils
(
gl
,
extensions
)
{
var
isWebGL2
=
(
typeof
WebGL2RenderingContext
!==
'
undefined
'
&&
gl
instanceof
WebGL2RenderingContext
);
function
convert
(
p
)
{
function
convert
(
p
)
{
var
extension
;
var
extension
;
...
@@ -38,7 +36,7 @@ function WebGLUtils( gl, extensions ) {
...
@@ -38,7 +36,7 @@ function WebGLUtils( gl, extensions ) {
if
(
p
===
HalfFloatType
)
{
if
(
p
===
HalfFloatType
)
{
if
(
isWebGL2
)
return
gl
.
HALF_FLOAT
;
if
(
gl
.
isWebGL2
)
return
gl
.
HALF_FLOAT
;
extension
=
extensions
.
get
(
'
OES_texture_half_float
'
);
extension
=
extensions
.
get
(
'
OES_texture_half_float
'
);
...
@@ -129,7 +127,7 @@ function WebGLUtils( gl, extensions ) {
...
@@ -129,7 +127,7 @@ function WebGLUtils( gl, extensions ) {
if
(
p
===
MinEquation
||
p
===
MaxEquation
)
{
if
(
p
===
MinEquation
||
p
===
MaxEquation
)
{
if
(
isWebGL2
)
{
if
(
gl
.
isWebGL2
)
{
if
(
p
===
MinEquation
)
return
gl
.
MIN
;
if
(
p
===
MinEquation
)
return
gl
.
MIN
;
if
(
p
===
MaxEquation
)
return
gl
.
MAX
;
if
(
p
===
MaxEquation
)
return
gl
.
MAX
;
...
@@ -149,7 +147,7 @@ function WebGLUtils( gl, extensions ) {
...
@@ -149,7 +147,7 @@ function WebGLUtils( gl, extensions ) {
if
(
p
===
UnsignedInt248Type
)
{
if
(
p
===
UnsignedInt248Type
)
{
if
(
isWebGL2
)
return
gl
.
UNSIGNED_INT_24_8
;
if
(
gl
.
isWebGL2
)
return
gl
.
UNSIGNED_INT_24_8
;
extension
=
extensions
.
get
(
'
WEBGL_depth_texture
'
);
extension
=
extensions
.
get
(
'
WEBGL_depth_texture
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录