Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
dd542a41
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,发现更多精彩内容 >>
未验证
提交
dd542a41
编写于
4月 12, 2018
作者:
M
Mr.doob
提交者:
GitHub
4月 12, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13815 from WestLangley/dev-pmrem_dispose
PMREM and EquiangularToCubeGenerator: added dispose() methods
上级
9be38906
9b91fe07
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
99 addition
and
39 deletion
+99
-39
examples/js/loaders/EquiangularToCubeGenerator.js
examples/js/loaders/EquiangularToCubeGenerator.js
+40
-31
examples/js/pmrem/PMREMCubeUVPacker.js
examples/js/pmrem/PMREMCubeUVPacker.js
+15
-2
examples/js/pmrem/PMREMGenerator.js
examples/js/pmrem/PMREMGenerator.js
+18
-1
examples/webgl_materials_envmaps_exr.html
examples/webgl_materials_envmaps_exr.html
+13
-3
examples/webgl_materials_envmaps_hdr.html
examples/webgl_materials_envmaps_hdr.html
+13
-2
未找到文件。
examples/js/loaders/EquiangularToCubeGenerator.js
浏览文件 @
dd542a41
...
...
@@ -2,18 +2,18 @@
* @author Richard M. / https://github.com/richardmonette
*/
THREE
.
EquiangularToCubeGenerator
=
function
(
sourceTexture
,
resolution
)
{
THREE
.
EquiangularToCubeGenerator
=
function
(
sourceTexture
,
resolution
)
{
this
.
sourceTexture
=
sourceTexture
;
this
.
resolution
=
resolution
;
this
.
views
=
[
{
t
:
[
1.0
,
0.0
,
0.0
],
u
:
[
0.0
,
-
1.0
,
0.0
]
},
{
t
:
[
-
1.0
,
0.0
,
0.0
],
u
:
[
0.0
,
-
1.0
,
0.0
]
},
{
t
:
[
0.0
,
1.0
,
0.0
],
u
:
[
0.0
,
0.0
,
1.0
]
},
{
t
:
[
0.0
,
-
1.0
,
0.0
],
u
:
[
0.0
,
0.0
,
-
1.0
]
},
{
t
:
[
0.0
,
0.0
,
1.0
],
u
:
[
0.0
,
-
1.0
,
0.0
]
},
{
t
:
[
0.0
,
0.0
,
-
1.0
],
u
:
[
0.0
,
-
1.0
,
0.0
]
},
{
t
:
[
1
,
0
,
0
],
u
:
[
0
,
-
1
,
0
]
},
{
t
:
[
-
1
,
0
,
0
],
u
:
[
0
,
-
1
,
0
]
},
{
t
:
[
0
,
1
,
0
],
u
:
[
0
,
0
,
1
]
},
{
t
:
[
0
,
-
1
,
0
],
u
:
[
0
,
0
,
-
1
]
},
{
t
:
[
0
,
0
,
1
],
u
:
[
0
,
-
1
,
0
]
},
{
t
:
[
0
,
0
,
-
1
],
u
:
[
0
,
-
1
,
0
]
},
];
this
.
camera
=
new
THREE
.
PerspectiveCamera
(
90
,
1
,
0.1
,
10
);
...
...
@@ -22,49 +22,47 @@ THREE.EquiangularToCubeGenerator = function( sourceTexture, resolution ) {
this
.
scene
=
new
THREE
.
Scene
();
this
.
scene
.
add
(
this
.
boxMesh
);
};
var
params
=
{
format
:
THREE
.
RGBAFormat
,
magFilter
:
this
.
sourceTexture
.
magFilter
,
minFilter
:
this
.
sourceTexture
.
minFilter
,
type
:
this
.
sourceTexture
.
type
,
generateMipmaps
:
this
.
sourceTexture
.
generateMipmaps
,
anisotropy
:
this
.
sourceTexture
.
anisotropy
,
encoding
:
this
.
sourceTexture
.
encoding
};
THREE
.
EquiangularToCubeGenerator
.
prototype
=
{
this
.
renderTarget
=
new
THREE
.
WebGLRenderTargetCube
(
this
.
resolution
,
this
.
resolution
,
params
);
constructor
:
THREE
.
EquiangularToCubeGenerator
,
};
generate
:
function
(
renderer
)
{
THREE
.
EquiangularToCubeGenerator
.
prototype
=
{
var
params
=
{
format
:
THREE
.
RGBAFormat
,
magFilter
:
this
.
sourceTexture
.
magFilter
,
minFilter
:
this
.
sourceTexture
.
minFilter
,
type
:
this
.
sourceTexture
.
type
,
generateMipmaps
:
this
.
sourceTexture
.
generateMipmaps
,
anisotropy
:
this
.
sourceTexture
.
anisotropy
,
encoding
:
this
.
sourceTexture
.
encoding
};
constructor
:
THREE
.
EquiangularToCubeGenerator
,
var
renderTarget
=
new
THREE
.
WebGLRenderTargetCube
(
this
.
resolution
,
this
.
resolution
,
params
);
update
:
function
(
renderer
)
{
for
(
var
i
=
0
;
i
<
6
;
i
++
)
{
for
(
var
i
=
0
;
i
<
6
;
i
++
)
{
renderTarget
.
activeCubeFace
=
i
;
this
.
renderTarget
.
activeCubeFace
=
i
;
var
v
=
this
.
views
[
i
];
var
v
=
this
.
views
[
i
];
this
.
camera
.
position
.
set
(
0
,
0
,
0
);
this
.
camera
.
up
.
set
(
v
.
u
[
0
],
v
.
u
[
1
],
v
.
u
[
2
]
);
this
.
camera
.
lookAt
(
v
.
t
[
0
],
v
.
t
[
1
],
v
.
t
[
2
]
);
this
.
camera
.
updateProjectionMatrix
();
renderer
.
render
(
this
.
scene
,
this
.
camera
,
renderTarget
,
true
);
renderer
.
render
(
this
.
scene
,
this
.
camera
,
this
.
renderTarget
,
true
);
}
return
renderTarget
.
texture
;
return
this
.
renderTarget
.
texture
;
},
getShader
:
function
()
{
getShader
:
function
()
{
return
new
THREE
.
ShaderMaterial
(
{
var
shaderMaterial
=
new
THREE
.
ShaderMaterial
(
{
uniforms
:
{
"
equirectangularMap
"
:
{
value
:
this
.
sourceTexture
},
...
...
@@ -107,7 +105,18 @@ THREE.EquiangularToCubeGenerator.prototype = {
}
);
shaderMaterial
.
type
=
'
EquiangularToCubeGenerator
'
;
return
shaderMaterial
;
},
dispose
:
function
()
{
this
.
boxMesh
.
geometry
.
dispose
();
this
.
boxMesh
.
material
.
dispose
();
this
.
renderTarget
.
dispose
();
}
};
examples/js/pmrem/PMREMCubeUVPacker.js
浏览文件 @
dd542a41
...
...
@@ -13,10 +13,9 @@
* The arrangement of the faces is fixed, as assuming this arrangement, the sampling function has been written.
*/
THREE
.
PMREMCubeUVPacker
=
function
(
cubeTextureLods
,
numLods
)
{
THREE
.
PMREMCubeUVPacker
=
function
(
cubeTextureLods
)
{
this
.
cubeLods
=
cubeTextureLods
;
this
.
numLods
=
numLods
;
var
size
=
cubeTextureLods
[
0
].
width
*
4
;
var
sourceTexture
=
cubeTextureLods
[
0
].
texture
;
...
...
@@ -189,8 +188,22 @@ THREE.PMREMCubeUVPacker.prototype = {
}
);
shaderMaterial
.
type
=
'
PMREMCubeUVPacker
'
;
return
shaderMaterial
;
},
dispose
:
function
()
{
for
(
var
i
=
0
,
l
=
this
.
objects
.
length
;
i
<
l
;
i
++
)
{
this
.
objects
[
i
].
material
.
dispose
();
}
this
.
objects
[
0
].
geometry
.
dispose
();
}
};
examples/js/pmrem/PMREMGenerator.js
浏览文件 @
dd542a41
...
...
@@ -138,7 +138,7 @@ THREE.PMREMGenerator.prototype = {
getShader
:
function
()
{
return
new
THREE
.
ShaderMaterial
(
{
var
shaderMaterial
=
new
THREE
.
ShaderMaterial
(
{
defines
:
{
"
SAMPLES_PER_LEVEL
"
:
20
,
...
...
@@ -269,6 +269,23 @@ THREE.PMREMGenerator.prototype = {
}
);
shaderMaterial
.
type
=
'
PMREMGenerator
'
;
return
shaderMaterial
;
},
dispose
:
function
()
{
for
(
var
i
=
0
,
l
=
this
.
cubeLods
.
length
;
i
<
l
;
i
++
)
{
this
.
cubeLods
[
i
].
dispose
();
}
this
.
planeMesh
.
geometry
.
dispose
();
this
.
planeMesh
.
material
.
dispose
();
}
};
examples/webgl_materials_envmaps_exr.html
浏览文件 @
dd542a41
...
...
@@ -67,7 +67,7 @@
document
.
body
.
appendChild
(
container
);
camera
=
new
THREE
.
PerspectiveCamera
(
40
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
1000
);
camera
.
position
.
set
(
0
.0
,
0
,
120
);
camera
.
position
.
set
(
0
,
0
,
120
);
scene
=
new
THREE
.
Scene
();
scene
.
background
=
new
THREE
.
Color
(
0x000000
);
...
...
@@ -107,7 +107,7 @@
texture
.
encoding
=
THREE
.
LinearEncoding
;
var
cubemapGenerator
=
new
THREE
.
EquiangularToCubeGenerator
(
texture
,
512
);
var
cubeMapTexture
=
cubemapGenerator
.
gener
ate
(
renderer
);
var
cubeMapTexture
=
cubemapGenerator
.
upd
ate
(
renderer
);
var
pmremGenerator
=
new
THREE
.
PMREMGenerator
(
cubeMapTexture
);
pmremGenerator
.
update
(
renderer
);
...
...
@@ -117,6 +117,11 @@
exrCubeRenderTarget
=
pmremCubeUVPacker
.
CubeUVRenderTarget
;
texture
.
dispose
();
cubemapGenerator
.
dispose
();
pmremGenerator
.
dispose
();
pmremCubeUVPacker
.
dispose
();
}
);
new
THREE
.
TextureLoader
().
load
(
'
textures/equiangular.png
'
,
function
(
texture
)
{
...
...
@@ -124,7 +129,7 @@
texture
.
encoding
=
THREE
.
sRGBEncoding
;
var
cubemapGenerator
=
new
THREE
.
EquiangularToCubeGenerator
(
texture
,
512
);
var
cubeMapTexture
=
cubemapGenerator
.
gener
ate
(
renderer
);
var
cubeMapTexture
=
cubemapGenerator
.
upd
ate
(
renderer
);
var
pmremGenerator
=
new
THREE
.
PMREMGenerator
(
cubeMapTexture
);
pmremGenerator
.
update
(
renderer
);
...
...
@@ -134,6 +139,11 @@
pngCubeRenderTarget
=
pmremCubeUVPacker
.
CubeUVRenderTarget
;
texture
.
dispose
();
cubemapGenerator
.
dispose
();
pmremGenerator
.
dispose
();
pmremCubeUVPacker
.
dispose
();
}
);
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
...
...
examples/webgl_materials_envmaps_hdr.html
浏览文件 @
dd542a41
...
...
@@ -68,7 +68,7 @@
document
.
body
.
appendChild
(
container
);
camera
=
new
THREE
.
PerspectiveCamera
(
40
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
1000
);
camera
.
position
.
set
(
0
.0
,
0
,
120
);
camera
.
position
.
set
(
0
,
0
,
120
);
scene
=
new
THREE
.
Scene
();
scene
.
background
=
new
THREE
.
Color
(
0x000000
);
...
...
@@ -77,7 +77,6 @@
renderer
.
toneMapping
=
THREE
.
LinearToneMapping
;
standardMaterial
=
new
THREE
.
MeshStandardMaterial
(
{
map
:
null
,
color
:
0xffffff
,
metalness
:
params
.
metalness
,
roughness
:
params
.
roughness
...
...
@@ -119,6 +118,10 @@
hdrCubeRenderTarget
=
pmremCubeUVPacker
.
CubeUVRenderTarget
;
hdrCubeMap
.
dispose
();
pmremGenerator
.
dispose
();
pmremCubeUVPacker
.
dispose
();
}
);
var
ldrUrls
=
genCubeUrls
(
'
./textures/cube/pisa/
'
,
'
.png
'
);
...
...
@@ -134,6 +137,10 @@
ldrCubeRenderTarget
=
pmremCubeUVPacker
.
CubeUVRenderTarget
;
ldrCubeMap
.
dispose
();
pmremGenerator
.
dispose
();
pmremCubeUVPacker
.
dispose
();
}
);
...
...
@@ -150,6 +157,10 @@
rgbmCubeRenderTarget
=
pmremCubeUVPacker
.
CubeUVRenderTarget
;
rgbmCubeMap
.
dispose
();
pmremGenerator
.
dispose
();
pmremCubeUVPacker
.
dispose
();
}
);
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录