Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
c8cb6315
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,发现更多精彩内容 >>
提交
c8cb6315
编写于
3月 31, 2018
作者:
M
Mugen87
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Examples: Clean up
上级
46cf3f98
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
41 addition
and
43 deletion
+41
-43
examples/webgl_camera_cinematic.html
examples/webgl_camera_cinematic.html
+41
-43
未找到文件。
examples/webgl_camera_cinematic.html
浏览文件 @
c8cb6315
...
...
@@ -11,14 +11,23 @@
margin
:
0px
;
overflow
:
hidden
;
}
#info
{
position
:
absolute
;
top
:
10px
;
width
:
100%
;
text-align
:
center
;
}
</style>
</head>
<body>
<div
id=
"info"
>
<a
href=
"https://threejs.org"
target=
"_blank"
rel=
"noopener"
>
three.js
</a>
webgl - interactive cubes
</div>
<script
src=
"../build/three.js"
></script>
<script
src=
"js/shaders/BokehShader2.js"
></script>
<script
src=
"js/cameras/CinematicCamera.js"
></script>
<script
src=
"js/libs/stats.min.js"
></script>
...
...
@@ -26,32 +35,19 @@
<script>
var
container
,
stats
;
var
camera
,
scene
,
raycaster
,
renderer
;
var
camera
,
scene
,
raycaster
,
renderer
,
stats
;
var
mouse
=
new
THREE
.
Vector2
(),
INTERSECTED
;
var
radius
=
100
,
theta
=
0
;
init
();
animate
();
function
init
()
{
container
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
container
);
var
info
=
document
.
createElement
(
'
div
'
);
info
.
style
.
position
=
'
absolute
'
;
info
.
style
.
top
=
'
10px
'
;
info
.
style
.
width
=
'
100%
'
;
info
.
style
.
textAlign
=
'
center
'
;
info
.
innerHTML
=
'
<a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> webgl - interactive cubes
'
;
container
.
appendChild
(
info
);
camera
=
new
THREE
.
CinematicCamera
(
60
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
1000
);
camera
.
setLens
(
5
);
camera
.
position
.
set
(
2
,
1
,
500
);
camera
.
setLens
(
5
);
camera
.
position
.
set
(
2
,
1
,
500
);
scene
=
new
THREE
.
Scene
();
scene
.
background
=
new
THREE
.
Color
(
0xf0f0f0
);
...
...
@@ -62,8 +58,7 @@
light
.
position
.
set
(
1
,
1
,
1
).
normalize
();
scene
.
add
(
light
);
var
geometry
=
new
THREE
.
BoxGeometry
(
20
,
20
,
20
);
var
geometry
=
new
THREE
.
BoxBufferGeometry
(
20
,
20
,
20
);
for
(
var
i
=
0
;
i
<
1500
;
i
++
)
{
...
...
@@ -82,15 +77,13 @@
renderer
=
new
THREE
.
WebGLRenderer
(
{
antialias
:
true
}
);
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
container
.
appendChild
(
renderer
.
domElement
);
document
.
body
.
appendChild
(
renderer
.
domElement
);
stats
=
new
Stats
();
container
.
appendChild
(
stats
.
dom
);
document
.
body
.
appendChild
(
stats
.
dom
);
document
.
addEventListener
(
'
mousemove
'
,
onDocumentMouseMove
,
false
);
window
.
addEventListener
(
'
resize
'
,
onWindowResize
,
false
);
var
effectController
=
{
...
...
@@ -123,23 +116,31 @@
var
matChanger
=
function
(
)
{
for
(
var
e
in
effectController
)
{
if
(
e
in
camera
.
postprocessing
.
bokeh_uniforms
)
camera
.
postprocessing
.
bokeh_uniforms
[
e
].
value
=
effectController
[
e
];
for
(
var
e
in
effectController
)
{
if
(
e
in
camera
.
postprocessing
.
bokeh_uniforms
)
{
camera
.
postprocessing
.
bokeh_uniforms
[
e
].
value
=
effectController
[
e
];
}
}
camera
.
postprocessing
.
bokeh_uniforms
[
'
znear
'
].
value
=
camera
.
near
;
camera
.
postprocessing
.
bokeh_uniforms
[
'
zfar
'
].
value
=
camera
.
far
;
camera
.
setLens
(
effectController
.
focalLength
,
camera
.
frameHeight
,
effectController
.
fstop
,
camera
.
coc
);
effectController
[
'
focalDepth
'
]
=
camera
.
postprocessing
.
bokeh_uniforms
[
"
focalDepth
"
].
value
;
camera
.
setLens
(
effectController
.
focalLength
,
camera
.
frameHeight
,
effectController
.
fstop
,
camera
.
coc
);
effectController
[
'
focalDepth
'
]
=
camera
.
postprocessing
.
bokeh_uniforms
[
'
focalDepth
'
].
value
;
};
//
var
gui
=
new
dat
.
GUI
();
gui
.
add
(
effectController
,
"
focalLength
"
,
1
,
135
,
0.01
).
onChange
(
matChanger
);
gui
.
add
(
effectController
,
"
fstop
"
,
1.8
,
22
,
0.01
).
onChange
(
matChanger
);
gui
.
add
(
effectController
,
"
focalDepth
"
,
0.1
,
100
,
0.001
).
onChange
(
matChanger
);
gui
.
add
(
effectController
,
"
showFocus
"
,
true
).
onChange
(
matChanger
);
gui
.
add
(
effectController
,
'
focalLength
'
,
1
,
135
,
0.01
).
onChange
(
matChanger
);
gui
.
add
(
effectController
,
'
fstop
'
,
1.8
,
22
,
0.01
).
onChange
(
matChanger
);
gui
.
add
(
effectController
,
'
focalDepth
'
,
0.1
,
100
,
0.001
).
onChange
(
matChanger
);
gui
.
add
(
effectController
,
'
showFocus
'
,
true
).
onChange
(
matChanger
);
matChanger
();
...
...
@@ -147,8 +148,7 @@
}
function
onWindowResize
()
{
function
onWindowResize
()
{
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
updateProjectionMatrix
();
...
...
@@ -166,7 +166,6 @@
}
function
animate
()
{
requestAnimationFrame
(
animate
,
renderer
.
domElement
);
...
...
@@ -197,9 +196,8 @@
if
(
intersects
.
length
>
0
)
{
var
targetDistance
=
intersects
[
0
].
distance
;
//Using Cinematic camera focusAt method
camera
.
focusAt
(
targetDistance
);
camera
.
focusAt
(
targetDistance
);
// using Cinematic camera focusAt method
if
(
INTERSECTED
!=
intersects
[
0
].
object
)
{
...
...
@@ -218,13 +216,13 @@
}
//
if
(
camera
.
postprocessing
.
enabled
){
//rendering Cinematic Camera effects
camera
.
renderCinematic
(
scene
,
renderer
);
}
if
(
camera
.
postprocessing
.
enabled
)
{
else
{
camera
.
renderCinematic
(
scene
,
renderer
);
}
else
{
scene
.
overrideMaterial
=
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录