Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
c9bdd41b
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,体验更适合开发者的 AI 搜索 >>
提交
c9bdd41b
编写于
8月 19, 2019
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WebGLTextures: Refactored setTextureCube()
上级
92ed6776
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
66 addition
and
60 deletion
+66
-60
src/renderers/webgl/WebGLTextures.js
src/renderers/webgl/WebGLTextures.js
+66
-60
未找到文件。
src/renderers/webgl/WebGLTextures.js
浏览文件 @
c9bdd41b
...
...
@@ -357,104 +357,110 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
function
setTextureCube
(
texture
,
slot
)
{
if
(
texture
.
image
.
length
!==
6
)
return
;
var
textureProperties
=
properties
.
get
(
texture
);
if
(
texture
.
image
.
length
===
6
)
{
if
(
texture
.
version
>
0
&&
textureProperties
.
__version
!==
texture
.
version
)
{
i
f
(
texture
.
version
>
0
&&
textureProperties
.
__version
!==
texture
.
version
)
{
i
nitTexture
(
textureProperties
,
texture
);
initTexture
(
textureProperties
,
texture
);
state
.
activeTexture
(
_gl
.
TEXTURE0
+
slot
);
state
.
bindTexture
(
_gl
.
TEXTURE_CUBE_MAP
,
textureProperties
.
__webglTexture
);
state
.
activeTexture
(
_gl
.
TEXTURE0
+
slot
);
state
.
bindTexture
(
_gl
.
TEXTURE_CUBE_MAP
,
textureProperties
.
__webglTexture
);
_gl
.
pixelStorei
(
_gl
.
UNPACK_FLIP_Y_WEBGL
,
texture
.
flipY
);
_gl
.
pixelStorei
(
_gl
.
UNPACK_FLIP_Y_WEBGL
,
texture
.
flipY
);
var
isCompressed
=
(
texture
&&
texture
.
isCompressedTexture
);
var
isDataTexture
=
(
texture
.
image
[
0
]
&&
texture
.
image
[
0
].
isDataTexture
);
var
isCompressed
=
(
texture
&&
texture
.
isCompressedTexture
);
var
isDataTexture
=
(
texture
.
image
[
0
]
&&
texture
.
image
[
0
].
isDataTexture
);
var
cubeImage
=
[];
var
cubeImage
=
[];
for
(
var
i
=
0
;
i
<
6
;
i
++
)
{
for
(
var
i
=
0
;
i
<
6
;
i
++
)
{
if
(
!
isCompressed
&&
!
isDataTexture
)
{
if
(
!
isCompressed
&&
!
isDataTexture
)
{
cubeImage
[
i
]
=
resizeImage
(
texture
.
image
[
i
],
false
,
true
,
capabilities
.
maxCubemapSize
);
cubeImage
[
i
]
=
resizeImage
(
texture
.
image
[
i
],
false
,
true
,
capabilities
.
maxCubemapSize
);
}
else
{
}
else
{
cubeImage
[
i
]
=
isDataTexture
?
texture
.
image
[
i
].
image
:
texture
.
image
[
i
];
cubeImage
[
i
]
=
isDataTexture
?
texture
.
image
[
i
].
image
:
texture
.
image
[
i
];
}
}
}
}
var
image
=
cubeImage
[
0
],
supportsMips
=
isPowerOfTwo
(
image
)
||
capabilities
.
isWebGL2
,
glFormat
=
utils
.
convert
(
texture
.
format
),
glType
=
utils
.
convert
(
texture
.
type
),
glInternalFormat
=
getInternalFormat
(
glFormat
,
glType
);
var
image
=
cubeImage
[
0
],
supportsMips
=
isPowerOfTwo
(
image
)
||
capabilities
.
isWebGL2
,
glFormat
=
utils
.
convert
(
texture
.
format
),
glType
=
utils
.
convert
(
texture
.
type
),
glInternalFormat
=
getInternalFormat
(
glFormat
,
glType
);
setTextureParameters
(
_gl
.
TEXTURE_CUBE_MAP
,
texture
,
supportsMips
);
setTextureParameters
(
_gl
.
TEXTURE_CUBE_MAP
,
texture
,
supportsMips
)
;
var
mipmaps
;
var
mipmaps
=
texture
.
mipmaps
;
if
(
isCompressed
)
{
for
(
var
i
=
0
;
i
<
6
;
i
++
)
{
if
(
!
isCompressed
)
{
mipmaps
=
cubeImage
[
i
].
mipmaps
;
for
(
var
j
=
0
;
j
<
mipmaps
.
length
;
j
++
)
{
if
(
isDataTexture
)
{
var
mipmap
=
mipmaps
[
j
];
state
.
texImage2D
(
_gl
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
i
,
0
,
glInternalFormat
,
cubeImage
[
i
].
width
,
cubeImage
[
i
].
height
,
0
,
glFormat
,
glType
,
cubeImage
[
i
].
data
);
if
(
texture
.
format
!==
RGBAFormat
&&
texture
.
format
!==
RGBFormat
)
{
for
(
var
j
=
0
;
j
<
mipmaps
.
length
;
++
j
)
{
if
(
state
.
getCompressedTextureFormats
().
indexOf
(
glFormat
)
>
-
1
)
{
var
mipmap
=
mipmaps
[
j
];
var
mipmapImage
=
mipmap
.
image
[
i
].
image
;
state
.
compressedTexImage2D
(
_gl
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
i
,
j
,
glInternalFormat
,
mipmap
.
width
,
mipmap
.
height
,
0
,
mipmap
.
data
);
state
.
texImage2D
(
_gl
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
i
,
j
+
1
,
glInternalFormat
,
mipmapImage
.
width
,
mipmapImage
.
height
,
0
,
glFormat
,
glType
,
mipmapImage
.
data
);
}
else
{
console
.
warn
(
'
THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()
'
);
}
}
else
{
state
.
texImage2D
(
_gl
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
i
,
0
,
glInternalFormat
,
glFormat
,
glType
,
cubeImage
[
i
]
);
state
.
texImage2D
(
_gl
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
i
,
j
,
glInternalFormat
,
mipmap
.
width
,
mipmap
.
height
,
0
,
glFormat
,
glType
,
mipmap
.
data
);
for
(
var
j
=
0
;
j
<
mipmaps
.
length
;
++
j
)
{
}
var
mipmap
=
mipmaps
[
j
];
}
state
.
texImage2D
(
_gl
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
i
,
j
+
1
,
glInternalFormat
,
glFormat
,
glType
,
mipmap
.
image
[
i
]
);
}
}
textureProperties
.
__maxMipLevel
=
mipmaps
.
length
-
1
;
}
}
else
{
}
else
{
mipmaps
=
texture
.
mipmaps
;
mipmaps
=
cubeImage
[
i
].
mipmaps
;
for
(
var
i
=
0
;
i
<
6
;
i
++
)
{
for
(
var
j
=
0
,
jl
=
mipmaps
.
length
;
j
<
jl
;
j
++
)
{
if
(
isDataTexture
)
{
var
mipmap
=
mipmaps
[
j
]
;
state
.
texImage2D
(
_gl
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
i
,
0
,
glInternalFormat
,
cubeImage
[
i
].
width
,
cubeImage
[
i
].
height
,
0
,
glFormat
,
glType
,
cubeImage
[
i
].
data
)
;
if
(
texture
.
format
!==
RGBAFormat
&&
texture
.
format
!==
RGBFormat
)
{
for
(
var
j
=
0
;
j
<
mipmaps
.
length
;
j
++
)
{
if
(
state
.
getCompressedTextureFormats
().
indexOf
(
glFormat
)
>
-
1
)
{
var
mipmap
=
mipmaps
[
j
];
var
mipmapImage
=
mipmap
.
image
[
i
].
image
;
state
.
compressedTexImage2D
(
_gl
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
i
,
j
,
glInternalFormat
,
mipmap
.
width
,
mipmap
.
height
,
0
,
mipmap
.
data
);
state
.
texImage2D
(
_gl
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
i
,
j
+
1
,
glInternalFormat
,
mipmapImage
.
width
,
mipmapImage
.
height
,
0
,
glFormat
,
glType
,
mipmapImage
.
data
);
}
else
{
}
console
.
warn
(
'
THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()
'
);
}
else
{
}
state
.
texImage2D
(
_gl
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
i
,
0
,
glInternalFormat
,
glFormat
,
glType
,
cubeImage
[
i
]
);
}
else
{
for
(
var
j
=
0
;
j
<
mipmaps
.
length
;
j
++
)
{
state
.
texImage2D
(
_gl
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
i
,
j
,
glInternalFormat
,
mipmap
.
width
,
mipmap
.
height
,
0
,
glFormat
,
glType
,
mipmap
.
data
)
;
var
mipmap
=
mipmaps
[
j
]
;
}
state
.
texImage2D
(
_gl
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
i
,
j
+
1
,
glInternalFormat
,
glFormat
,
glType
,
mipmap
.
image
[
i
]
);
}
...
...
@@ -462,25 +468,25 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
}
textureProperties
.
__maxMipLevel
=
isCompressed
?
mipmaps
.
length
-
1
:
mipmaps
.
length
;
textureProperties
.
__maxMipLevel
=
mipmaps
.
length
;
if
(
textureNeedsGenerateMipmaps
(
texture
,
supportsMips
)
)
{
}
// We assume images for cube map have the same size.
generateMipmap
(
_gl
.
TEXTURE_CUBE_MAP
,
texture
,
image
.
width
,
image
.
height
);
if
(
textureNeedsGenerateMipmaps
(
texture
,
supportsMips
)
)
{
}
// We assume images for cube map have the same size.
generateMipmap
(
_gl
.
TEXTURE_CUBE_MAP
,
texture
,
image
.
width
,
image
.
height
);
textureProperties
.
__version
=
texture
.
version
;
}
if
(
texture
.
onUpdate
)
texture
.
onUpdate
(
texture
)
;
textureProperties
.
__version
=
texture
.
version
;
}
else
{
if
(
texture
.
onUpdate
)
texture
.
onUpdate
(
texture
);
state
.
activeTexture
(
_gl
.
TEXTURE0
+
slot
);
state
.
bindTexture
(
_gl
.
TEXTURE_CUBE_MAP
,
textureProperties
.
__webglTexture
);
}
else
{
}
state
.
activeTexture
(
_gl
.
TEXTURE0
+
slot
);
state
.
bindTexture
(
_gl
.
TEXTURE_CUBE_MAP
,
textureProperties
.
__webglTexture
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录