Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
289185ad
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,发现更多精彩内容 >>
提交
289185ad
编写于
5月 23, 2019
作者:
M
Mugen87
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
JSM: Added module and TS file for BokehPass.
上级
c2096aa9
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
175 addition
and
6 deletion
+175
-6
docs/manual/en/introduction/Import-via-modules.html
docs/manual/en/introduction/Import-via-modules.html
+1
-0
examples/js/postprocessing/BokehPass.js
examples/js/postprocessing/BokehPass.js
+4
-6
examples/jsm/postprocessing/BokehPass.d.ts
examples/jsm/postprocessing/BokehPass.d.ts
+32
-0
examples/jsm/postprocessing/BokehPass.js
examples/jsm/postprocessing/BokehPass.js
+137
-0
utils/modularize.js
utils/modularize.js
+1
-0
未找到文件。
docs/manual/en/introduction/Import-via-modules.html
浏览文件 @
289185ad
...
...
@@ -160,6 +160,7 @@
<ul>
<li>
AfterimagePass
</li>
<li>
BloomPass
</li>
<li>
BokehPass
</li>
<li>
ClearPass
</li>
<li>
CubeTexturePass
</li>
<li>
DotScreenPass
</li>
...
...
examples/js/postprocessing/BokehPass.js
浏览文件 @
289185ad
...
...
@@ -2,7 +2,6 @@
* Depth-of-field post-process with bokeh shader
*/
THREE
.
BokehPass
=
function
(
scene
,
camera
,
params
)
{
THREE
.
Pass
.
call
(
this
);
...
...
@@ -69,7 +68,6 @@ THREE.BokehPass = function ( scene, camera, params ) {
this
.
fsQuad
=
new
THREE
.
Pass
.
FullScreenQuad
(
this
.
materialBokeh
);
this
.
oldClearColor
=
new
THREE
.
Color
();
this
.
oldClearAlpha
=
1
;
};
...
...
@@ -77,14 +75,14 @@ THREE.BokehPass.prototype = Object.assign( Object.create( THREE.Pass.prototype )
constructor
:
THREE
.
BokehPass
,
render
:
function
(
renderer
,
writeBuffer
,
readBuffer
,
deltaTime
,
maskActive
)
{
render
:
function
(
renderer
,
writeBuffer
,
readBuffer
/*, deltaTime, maskActive*/
)
{
// Render depth into texture
this
.
scene
.
overrideMaterial
=
this
.
materialDepth
;
this
.
oldClearColor
.
copy
(
renderer
.
getClearColor
()
);
this
.
oldClearAlpha
=
renderer
.
getClearAlpha
();
var
oldClearAlpha
=
renderer
.
getClearAlpha
();
var
oldAutoClear
=
renderer
.
autoClear
;
renderer
.
autoClear
=
false
;
...
...
@@ -115,8 +113,8 @@ THREE.BokehPass.prototype = Object.assign( Object.create( THREE.Pass.prototype )
this
.
scene
.
overrideMaterial
=
null
;
renderer
.
setClearColor
(
this
.
oldClearColor
);
renderer
.
setClearAlpha
(
this
.
oldClearAlpha
);
renderer
.
autoClear
=
this
.
oldAutoClear
;
renderer
.
setClearAlpha
(
oldClearAlpha
);
renderer
.
autoClear
=
oldAutoClear
;
}
...
...
examples/jsm/postprocessing/BokehPass.d.ts
0 → 100644
浏览文件 @
289185ad
import
{
Scene
,
Camera
,
ShaderMaterial
,
WebGLRenderTarget
,
MeshDepthMaterial
,
Color
}
from
'
../../../src/Three
'
;
import
{
Pass
}
from
'
./Pass
'
;
export
interface
BokehPassParamters
{
focus
?:
number
;
aspect
?:
number
;
aperture
?:
number
;
maxblur
?:
number
;
width
?:
number
;
height
?:
number
;
}
export
class
BokehPass
extends
Pass
{
constructor
(
scene
:
Scene
,
camera
:
Camera
,
params
:
BokehPassParamters
);
scene
:
Scene
;
camera
:
Camera
;
renderTargetColor
:
WebGLRenderTarget
;
renderTargetDepth
:
WebGLRenderTarget
;
materialDepth
:
MeshDepthMaterial
;
materialBokeh
:
ShaderMaterial
;
uniforms
:
object
;
fsQuad
:
object
;
oldClearColor
:
Color
;
}
examples/jsm/postprocessing/BokehPass.js
0 → 100644
浏览文件 @
289185ad
/**
* Depth-of-field post-process with bokeh shader
*/
import
{
Color
,
LinearFilter
,
MeshDepthMaterial
,
NoBlending
,
RGBADepthPacking
,
RGBFormat
,
ShaderMaterial
,
UniformsUtils
,
WebGLRenderTarget
}
from
"
../../../build/three.module.js
"
;
import
{
Pass
}
from
"
../postprocessing/Pass.js
"
;
import
{
BokehShader
}
from
"
../shaders/BokehShader.js
"
;
var
BokehPass
=
function
(
scene
,
camera
,
params
)
{
Pass
.
call
(
this
);
this
.
scene
=
scene
;
this
.
camera
=
camera
;
var
focus
=
(
params
.
focus
!==
undefined
)
?
params
.
focus
:
1.0
;
var
aspect
=
(
params
.
aspect
!==
undefined
)
?
params
.
aspect
:
camera
.
aspect
;
var
aperture
=
(
params
.
aperture
!==
undefined
)
?
params
.
aperture
:
0.025
;
var
maxblur
=
(
params
.
maxblur
!==
undefined
)
?
params
.
maxblur
:
1.0
;
// render targets
var
width
=
params
.
width
||
window
.
innerWidth
||
1
;
var
height
=
params
.
height
||
window
.
innerHeight
||
1
;
this
.
renderTargetColor
=
new
WebGLRenderTarget
(
width
,
height
,
{
minFilter
:
LinearFilter
,
magFilter
:
LinearFilter
,
format
:
RGBFormat
}
);
this
.
renderTargetColor
.
texture
.
name
=
"
BokehPass.color
"
;
this
.
renderTargetDepth
=
this
.
renderTargetColor
.
clone
();
this
.
renderTargetDepth
.
texture
.
name
=
"
BokehPass.depth
"
;
// depth material
this
.
materialDepth
=
new
MeshDepthMaterial
();
this
.
materialDepth
.
depthPacking
=
RGBADepthPacking
;
this
.
materialDepth
.
blending
=
NoBlending
;
// bokeh material
if
(
BokehShader
===
undefined
)
{
console
.
error
(
"
BokehPass relies on BokehShader
"
);
}
var
bokehShader
=
BokehShader
;
var
bokehUniforms
=
UniformsUtils
.
clone
(
bokehShader
.
uniforms
);
bokehUniforms
[
"
tDepth
"
].
value
=
this
.
renderTargetDepth
.
texture
;
bokehUniforms
[
"
focus
"
].
value
=
focus
;
bokehUniforms
[
"
aspect
"
].
value
=
aspect
;
bokehUniforms
[
"
aperture
"
].
value
=
aperture
;
bokehUniforms
[
"
maxblur
"
].
value
=
maxblur
;
bokehUniforms
[
"
nearClip
"
].
value
=
camera
.
near
;
bokehUniforms
[
"
farClip
"
].
value
=
camera
.
far
;
this
.
materialBokeh
=
new
ShaderMaterial
(
{
defines
:
Object
.
assign
(
{},
bokehShader
.
defines
),
uniforms
:
bokehUniforms
,
vertexShader
:
bokehShader
.
vertexShader
,
fragmentShader
:
bokehShader
.
fragmentShader
}
);
this
.
uniforms
=
bokehUniforms
;
this
.
needsSwap
=
false
;
this
.
fsQuad
=
new
Pass
.
FullScreenQuad
(
this
.
materialBokeh
);
this
.
oldClearColor
=
new
Color
();
};
BokehPass
.
prototype
=
Object
.
assign
(
Object
.
create
(
Pass
.
prototype
),
{
constructor
:
BokehPass
,
render
:
function
(
renderer
,
writeBuffer
,
readBuffer
/*, deltaTime, maskActive*/
)
{
// Render depth into texture
this
.
scene
.
overrideMaterial
=
this
.
materialDepth
;
this
.
oldClearColor
.
copy
(
renderer
.
getClearColor
()
);
var
oldClearAlpha
=
renderer
.
getClearAlpha
();
var
oldAutoClear
=
renderer
.
autoClear
;
renderer
.
autoClear
=
false
;
renderer
.
setClearColor
(
0xffffff
);
renderer
.
setClearAlpha
(
1.0
);
renderer
.
setRenderTarget
(
this
.
renderTargetDepth
);
renderer
.
clear
();
renderer
.
render
(
this
.
scene
,
this
.
camera
);
// Render bokeh composite
this
.
uniforms
[
"
tColor
"
].
value
=
readBuffer
.
texture
;
this
.
uniforms
[
"
nearClip
"
].
value
=
this
.
camera
.
near
;
this
.
uniforms
[
"
farClip
"
].
value
=
this
.
camera
.
far
;
if
(
this
.
renderToScreen
)
{
renderer
.
setRenderTarget
(
null
);
this
.
fsQuad
.
render
(
renderer
);
}
else
{
renderer
.
setRenderTarget
(
writeBuffer
);
renderer
.
clear
();
this
.
fsQuad
.
render
(
renderer
);
}
this
.
scene
.
overrideMaterial
=
null
;
renderer
.
setClearColor
(
this
.
oldClearColor
);
renderer
.
setClearAlpha
(
oldClearAlpha
);
renderer
.
autoClear
=
oldAutoClear
;
}
}
);
export
{
BokehPass
};
utils/modularize.js
浏览文件 @
289185ad
...
...
@@ -69,6 +69,7 @@ var files = [
{
path
:
'
postprocessing/AfterimagePass.js
'
,
dependencies
:
[
{
name
:
'
Pass
'
,
path
:
'
postprocessing/Pass.js
'
},
{
name
:
'
AfterimageShader
'
,
path
:
'
shaders/AfterimageShader.js
'
}
],
ignoreList
:
[]
},
{
path
:
'
postprocessing/BloomPass.js
'
,
dependencies
:
[
{
name
:
'
Pass
'
,
path
:
'
postprocessing/Pass.js
'
},
{
name
:
'
CopyShader
'
,
path
:
'
shaders/CopyShader.js
'
},
{
name
:
'
ConvolutionShader
'
,
path
:
'
shaders/ConvolutionShader.js
'
}
],
ignoreList
:
[]
},
{
path
:
'
postprocessing/BokehPass.js
'
,
dependencies
:
[
{
name
:
'
Pass
'
,
path
:
'
postprocessing/Pass.js
'
},
{
name
:
'
BokehShader
'
,
path
:
'
shaders/BokehShader.js
'
}
],
ignoreList
:
[]
},
{
path
:
'
postprocessing/ClearPass.js
'
,
dependencies
:
[
{
name
:
'
Pass
'
,
path
:
'
postprocessing/Pass.js
'
}
],
ignoreList
:
[]
},
{
path
:
'
postprocessing/CubeTexturePass.js
'
,
dependencies
:
[
{
name
:
'
Pass
'
,
path
:
'
postprocessing/Pass.js
'
}
],
ignoreList
:
[]
},
{
path
:
'
postprocessing/DotScreenPass.js
'
,
dependencies
:
[
{
name
:
'
Pass
'
,
path
:
'
postprocessing/Pass.js
'
},
{
name
:
'
DotScreenShader
'
,
path
:
'
shaders/DotScreenShader.js
'
}
],
ignoreList
:
[]
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录