Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
1dfbba57
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,发现更多精彩内容 >>
提交
1dfbba57
编写于
5月 08, 2019
作者:
M
Mugen87
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
EffectComposer: Introduce .setPixelRatio() and harmonize resizing.
上级
0cc10e97
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
57 addition
and
55 deletion
+57
-55
examples/js/postprocessing/EffectComposer.js
examples/js/postprocessing/EffectComposer.js
+34
-7
examples/misc_controls_fly.html
examples/misc_controls_fly.html
+2
-3
examples/webgl_materials_video.html
examples/webgl_materials_video.html
+1
-1
examples/webgl_points_dynamic.html
examples/webgl_points_dynamic.html
+6
-7
examples/webgl_postprocessing_backgrounds.html
examples/webgl_postprocessing_backgrounds.html
+1
-5
examples/webgl_postprocessing_smaa.html
examples/webgl_postprocessing_smaa.html
+1
-5
examples/webgl_postprocessing_sobel.html
examples/webgl_postprocessing_sobel.html
+4
-4
examples/webgl_postprocessing_ssaa.html
examples/webgl_postprocessing_ssaa.html
+1
-5
examples/webgl_postprocessing_ssaa_unbiased.html
examples/webgl_postprocessing_ssaa_unbiased.html
+2
-5
examples/webgl_postprocessing_taa.html
examples/webgl_postprocessing_taa.html
+1
-5
examples/webgl_postprocessing_unreal_bloom.html
examples/webgl_postprocessing_unreal_bloom.html
+0
-1
examples/webgl_postprocessing_unreal_bloom_selective.html
examples/webgl_postprocessing_unreal_bloom_selective.html
+2
-4
examples/webgl_shader_lava.html
examples/webgl_shader_lava.html
+2
-3
未找到文件。
examples/js/postprocessing/EffectComposer.js
浏览文件 @
1dfbba57
...
...
@@ -15,10 +15,20 @@ THREE.EffectComposer = function ( renderer, renderTarget ) {
stencilBuffer
:
false
};
var
size
=
renderer
.
getDrawingBufferSize
(
new
THREE
.
Vector2
()
);
renderTarget
=
new
THREE
.
WebGLRenderTarget
(
size
.
width
,
size
.
height
,
parameters
);
var
size
=
renderer
.
getSize
(
new
THREE
.
Vector2
()
);
this
.
_pixelRatio
=
renderer
.
getPixelRatio
();
this
.
_width
=
size
.
width
;
this
.
_height
=
size
.
height
;
renderTarget
=
new
THREE
.
WebGLRenderTarget
(
this
.
_width
*
this
.
_pixelRatio
,
this
.
_height
*
this
.
_pixelRatio
,
parameters
);
renderTarget
.
texture
.
name
=
'
EffectComposer.rt1
'
;
}
else
{
this
.
_pixelRatio
=
1
;
this
.
_width
=
renderTarget
.
width
;
this
.
_height
=
renderTarget
.
height
;
}
this
.
renderTarget1
=
renderTarget
;
...
...
@@ -162,10 +172,13 @@ Object.assign( THREE.EffectComposer.prototype, {
if
(
renderTarget
===
undefined
)
{
var
size
=
this
.
renderer
.
getDrawingBufferSize
(
new
THREE
.
Vector2
()
);
var
size
=
this
.
renderer
.
getSize
(
new
THREE
.
Vector2
()
);
this
.
_pixelRatio
=
this
.
renderer
.
getPixelRatio
();
this
.
_width
=
size
.
width
;
this
.
_height
=
size
.
height
;
renderTarget
=
this
.
renderTarget1
.
clone
();
renderTarget
.
setSize
(
size
.
width
,
size
.
height
);
renderTarget
.
setSize
(
this
.
_width
*
this
.
_pixelRatio
,
this
.
_height
*
this
.
_pixelRatio
);
}
...
...
@@ -181,15 +194,29 @@ Object.assign( THREE.EffectComposer.prototype, {
setSize
:
function
(
width
,
height
)
{
this
.
renderTarget1
.
setSize
(
width
,
height
);
this
.
renderTarget2
.
setSize
(
width
,
height
);
this
.
_width
=
width
;
this
.
_height
=
height
;
var
effectiveWidth
=
this
.
_width
*
this
.
_pixelRatio
;
var
effectiveHeight
=
this
.
_height
*
this
.
_pixelRatio
;
this
.
renderTarget1
.
setSize
(
effectiveWidth
,
effectiveHeight
);
this
.
renderTarget2
.
setSize
(
effectiveWidth
,
effectiveHeight
);
for
(
var
i
=
0
;
i
<
this
.
passes
.
length
;
i
++
)
{
this
.
passes
[
i
].
setSize
(
width
,
h
eight
);
this
.
passes
[
i
].
setSize
(
effectiveWidth
,
effectiveH
eight
);
}
},
setPixelRatio
:
function
(
pixelRatio
)
{
this
.
_pixelRatio
=
pixelRatio
;
this
.
setSize
(
this
.
_width
,
this
.
_height
);
}
}
);
...
...
examples/misc_controls_fly.html
浏览文件 @
1dfbba57
...
...
@@ -252,12 +252,11 @@
SCREEN_HEIGHT
=
window
.
innerHeight
;
SCREEN_WIDTH
=
window
.
innerWidth
;
renderer
.
setSize
(
SCREEN_WIDTH
,
SCREEN_HEIGHT
);
camera
.
aspect
=
SCREEN_WIDTH
/
SCREEN_HEIGHT
;
camera
.
updateProjectionMatrix
();
composer
.
reset
();
renderer
.
setSize
(
SCREEN_WIDTH
,
SCREEN_HEIGHT
);
composer
.
setSize
(
SCREEN_WIDTH
,
SCREEN_HEIGHT
);
}
...
...
examples/webgl_materials_video.html
浏览文件 @
1dfbba57
...
...
@@ -244,7 +244,7 @@
camera
.
updateProjectionMatrix
();
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
composer
.
reset
(
);
composer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
}
...
...
examples/webgl_points_dynamic.html
浏览文件 @
1dfbba57
...
...
@@ -135,8 +135,8 @@
effectFocus
=
new
THREE
.
ShaderPass
(
THREE
.
FocusShader
);
effectFocus
.
uniforms
[
"
screenWidth
"
].
value
=
window
.
innerWidth
;
effectFocus
.
uniforms
[
"
screenHeight
"
].
value
=
window
.
innerHeight
;
effectFocus
.
uniforms
[
"
screenWidth
"
].
value
=
window
.
innerWidth
*
window
.
devicePixelRatio
;
effectFocus
.
uniforms
[
"
screenHeight
"
].
value
=
window
.
innerHeight
*
window
.
devicePixelRatio
;
composer
=
new
THREE
.
EffectComposer
(
renderer
);
...
...
@@ -156,17 +156,16 @@
function
onWindowResize
()
{
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
updateProjectionMatrix
();
camera
.
lookAt
(
scene
.
position
);
composer
.
reset
();
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
composer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
effectFocus
.
uniforms
[
"
screenWidth
"
].
value
=
window
.
innerWidth
;
effectFocus
.
uniforms
[
"
screenHeight
"
].
value
=
window
.
innerHeight
;
effectFocus
.
uniforms
[
"
screenWidth
"
].
value
=
window
.
innerWidth
*
window
.
devicePixelRatio
;
effectFocus
.
uniforms
[
"
screenHeight
"
].
value
=
window
.
innerHeight
*
window
.
devicePixelRatio
;
}
...
...
examples/webgl_postprocessing_backgrounds.html
浏览文件 @
1dfbba57
...
...
@@ -239,11 +239,7 @@
cameraO.updateProjectionMatrix();*/
renderer
.
setSize
(
width
,
height
);
var
pixelRatio
=
renderer
.
getPixelRatio
();
var
newWidth
=
Math
.
floor
(
width
*
pixelRatio
)
||
1
;
var
newHeight
=
Math
.
floor
(
height
*
pixelRatio
)
||
1
;
composer
.
setSize
(
newWidth
,
newHeight
);
composer
.
setSize
(
width
,
height
);
}
...
...
examples/webgl_postprocessing_smaa.html
浏览文件 @
1dfbba57
...
...
@@ -92,11 +92,7 @@
camera
.
updateProjectionMatrix
();
renderer
.
setSize
(
width
,
height
);
var
pixelRatio
=
renderer
.
getPixelRatio
();
var
newWidth
=
Math
.
floor
(
width
*
pixelRatio
)
||
1
;
var
newHeight
=
Math
.
floor
(
height
*
pixelRatio
)
||
1
;
composer
.
setSize
(
newWidth
,
newHeight
);
composer
.
setSize
(
width
,
height
);
}
...
...
examples/webgl_postprocessing_sobel.html
浏览文件 @
1dfbba57
...
...
@@ -118,8 +118,8 @@
// Sobel operator
effectSobel
=
new
THREE
.
ShaderPass
(
THREE
.
SobelOperatorShader
);
effectSobel
.
uniforms
[
"
resolution
"
].
value
.
x
=
window
.
innerWidth
;
effectSobel
.
uniforms
[
"
resolution
"
].
value
.
y
=
window
.
innerHeight
;
effectSobel
.
uniforms
[
'
resolution
'
].
value
.
x
=
window
.
innerWidth
*
window
.
devicePixelRatio
;
effectSobel
.
uniforms
[
'
resolution
'
].
value
.
y
=
window
.
innerHeight
*
window
.
devicePixelRatio
;
composer
.
addPass
(
effectSobel
);
var
controls
=
new
THREE
.
OrbitControls
(
camera
,
renderer
.
domElement
);
...
...
@@ -145,8 +145,8 @@
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
composer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
effectSobel
.
uniforms
[
"
resolution
"
].
value
.
x
=
window
.
innerWidth
;
effectSobel
.
uniforms
[
"
resolution
"
].
value
.
y
=
window
.
innerHeight
;
effectSobel
.
uniforms
[
'
resolution
'
].
value
.
x
=
window
.
innerWidth
*
window
.
devicePixelRatio
;
effectSobel
.
uniforms
[
'
resolution
'
].
value
.
y
=
window
.
innerHeight
*
window
.
devicePixelRatio
;
}
...
...
examples/webgl_postprocessing_ssaa.html
浏览文件 @
1dfbba57
...
...
@@ -143,11 +143,7 @@
camera
.
updateProjectionMatrix
();
renderer
.
setSize
(
width
,
height
);
var
pixelRatio
=
renderer
.
getPixelRatio
();
var
newWidth
=
Math
.
floor
(
width
*
pixelRatio
)
||
1
;
var
newHeight
=
Math
.
floor
(
height
*
pixelRatio
)
||
1
;
composer
.
setSize
(
newWidth
,
newHeight
);
composer
.
setSize
(
width
,
height
);
}
...
...
examples/webgl_postprocessing_ssaa_unbiased.html
浏览文件 @
1dfbba57
...
...
@@ -177,6 +177,7 @@
// postprocessing
composer
=
new
THREE
.
EffectComposer
(
renderer
);
composer
.
setPixelRatio
(
1
);
// ensure pixel ratio is always 1 for performance reasons
ssaaRenderPassP
=
new
THREE
.
SSAARenderPass
(
scene
,
cameraP
);
composer
.
addPass
(
ssaaRenderPassP
);
ssaaRenderPassO
=
new
THREE
.
SSAARenderPass
(
scene
,
cameraO
);
...
...
@@ -204,11 +205,7 @@
cameraO
.
updateProjectionMatrix
();
renderer
.
setSize
(
width
,
height
);
var
pixelRatio
=
renderer
.
getPixelRatio
();
var
newWidth
=
Math
.
floor
(
width
*
pixelRatio
)
||
1
;
var
newHeight
=
Math
.
floor
(
height
*
pixelRatio
)
||
1
;
composer
.
setSize
(
newWidth
,
newHeight
);
composer
.
setSize
(
width
,
height
);
}
...
...
examples/webgl_postprocessing_taa.html
浏览文件 @
1dfbba57
...
...
@@ -172,11 +172,7 @@
camera
.
updateProjectionMatrix
();
renderer
.
setSize
(
width
,
height
);
var
pixelRatio
=
renderer
.
getPixelRatio
();
var
newWidth
=
Math
.
floor
(
width
*
pixelRatio
)
||
1
;
var
newHeight
=
Math
.
floor
(
height
*
pixelRatio
)
||
1
;
composer
.
setSize
(
newWidth
,
newHeight
);
composer
.
setSize
(
width
,
height
);
}
...
...
examples/webgl_postprocessing_unreal_bloom.html
浏览文件 @
1dfbba57
...
...
@@ -109,7 +109,6 @@
bloomPass
.
radius
=
params
.
bloomRadius
;
composer
=
new
THREE
.
EffectComposer
(
renderer
);
composer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
composer
.
addPass
(
renderScene
);
composer
.
addPass
(
bloomPass
);
...
...
examples/webgl_postprocessing_unreal_bloom_selective.html
浏览文件 @
1dfbba57
...
...
@@ -140,7 +140,6 @@
var
bloomComposer
=
new
THREE
.
EffectComposer
(
renderer
);
bloomComposer
.
renderToScreen
=
false
;
bloomComposer
.
setSize
(
window
.
innerWidth
*
window
.
devicePixelRatio
,
window
.
innerHeight
*
window
.
devicePixelRatio
);
bloomComposer
.
addPass
(
renderScene
);
bloomComposer
.
addPass
(
bloomPass
);
...
...
@@ -158,7 +157,6 @@
finalPass
.
needsSwap
=
true
;
var
finalComposer
=
new
THREE
.
EffectComposer
(
renderer
);
finalComposer
.
setSize
(
window
.
innerWidth
*
window
.
devicePixelRatio
,
window
.
innerHeight
*
window
.
devicePixelRatio
);
finalComposer
.
addPass
(
renderScene
);
finalComposer
.
addPass
(
finalPass
);
...
...
@@ -251,8 +249,8 @@
renderer
.
setSize
(
width
,
height
);
bloomComposer
.
setSize
(
width
*
window
.
devicePixelRatio
,
height
*
window
.
devicePixelRatio
);
finalComposer
.
setSize
(
width
*
window
.
devicePixelRatio
,
height
*
window
.
devicePixelRatio
);
bloomComposer
.
setSize
(
width
,
height
);
finalComposer
.
setSize
(
width
,
height
);
render
();
...
...
examples/webgl_shader_lava.html
浏览文件 @
1dfbba57
...
...
@@ -199,12 +199,11 @@
function
onWindowResize
()
{
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
updateProjectionMatrix
();
composer
.
reset
();
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
composer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录