Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
ae4bf3bc
T
three.js
项目概览
车家大少爷
/
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,发现更多精彩内容 >>
提交
ae4bf3bc
编写于
5月 02, 2018
作者:
D
Daosheng Mu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adding the gui for controlling the parameters of thickness.
上级
8037cbca
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
48 addition
and
9 deletion
+48
-9
examples/webgl_materials_translucency.html
examples/webgl_materials_translucency.html
+48
-9
未找到文件。
examples/webgl_materials_translucency.html
浏览文件 @
ae4bf3bc
...
...
@@ -35,6 +35,7 @@
<script
src=
"js/Detector.js"
></script>
<script
src=
"js/libs/stats.min.js"
></script>
<script
src=
"js/libs/dat.gui.min.js"
></script>
<script
src=
"js/loaders/FBXLoader.js"
></script>
<script
src=
"js/ShaderTranslucent.js"
></script>
...
...
@@ -71,15 +72,15 @@
pointLight1
.
add
(
new
THREE
.
PointLight
(
0x888888
,
7.0
,
300
)
);
scene
.
add
(
pointLight1
);
pointLight1
.
position
.
x
=
0
;
pointLight1
.
position
.
y
=
0
;
pointLight1
.
position
.
y
=
-
5
0
;
pointLight1
.
position
.
z
=
350
;
var
pointLight2
=
new
THREE
.
Mesh
(
new
THREE
.
SphereBufferGeometry
(
4
,
8
,
8
),
new
THREE
.
MeshBasicMaterial
(
{
color
:
0x888800
}
)
);
pointLight2
.
add
(
new
THREE
.
PointLight
(
0x888800
,
1.0
,
500
)
);
scene
.
add
(
pointLight2
);
pointLight2
.
position
.
x
=
15
0
;
pointLight2
.
position
.
y
=
-
10
0
;
pointLight2
.
position
.
z
=
-
2
5
0
;
pointLight2
.
position
.
x
=
-
10
0
;
pointLight2
.
position
.
y
=
2
0
;
pointLight2
.
position
.
z
=
-
2
6
0
;
renderer
=
new
THREE
.
WebGLRenderer
(
{
antialias
:
true
}
);
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
...
...
@@ -106,7 +107,7 @@
var
loader
=
new
THREE
.
TextureLoader
();
var
imgTexture
=
loader
.
load
(
'
models/fbx/white.jpg
'
);
var
thicknessTexture
=
loader
.
load
(
'
models/fbx/bunny_thickness.
pn
g
'
);
var
thicknessTexture
=
loader
.
load
(
'
models/fbx/bunny_thickness.
jp
g
'
);
imgTexture
.
wrapS
=
imgTexture
.
wrapT
=
THREE
.
RepeatWrapping
;
var
shader
=
new
THREE
.
TranslucentShader
();
...
...
@@ -118,12 +119,12 @@
uniforms
[
'
shininess
'
].
value
=
500
;
uniforms
[
'
thicknessMap
'
].
value
=
thicknessTexture
;
uniforms
[
'
thicknessColor
'
].
value
=
new
THREE
.
Vector3
(
0.5
,
0.3
,
0.
3
);
uniforms
[
'
thicknessColor
'
].
value
=
new
THREE
.
Vector3
(
0.5
,
0.3
,
0.
0
);
uniforms
[
'
thicknessDistortion
'
].
value
=
0.1
;
uniforms
[
'
thicknessAmbient
'
].
value
=
0.
1
;
uniforms
[
'
thicknessAmbient
'
].
value
=
0.
4
;
uniforms
[
'
thicknessAttenuation
'
].
value
=
0.8
;
uniforms
[
'
thicknessPower
'
].
value
=
2
;
uniforms
[
'
thicknessScale
'
].
value
=
1
0
.0
;
uniforms
[
'
thicknessPower
'
].
value
=
2
.0
;
uniforms
[
'
thicknessScale
'
].
value
=
1
6
.0
;
var
material
=
new
THREE
.
ShaderMaterial
(
{
uniforms
:
uniforms
,
...
...
@@ -146,6 +147,44 @@
}
);
initGUI
(
uniforms
);
}
function
initGUI
(
uniforms
)
{
var
gui
=
new
dat
.
GUI
();
var
ThicknessControls
=
function
()
{
this
.
distoration
=
uniforms
[
'
thicknessDistortion
'
].
value
;
this
.
ambient
=
uniforms
[
'
thicknessAmbient
'
].
value
;
this
.
attenuation
=
uniforms
[
'
thicknessAttenuation
'
].
value
;
this
.
power
=
uniforms
[
'
thicknessPower
'
].
value
;
this
.
scale
=
uniforms
[
'
thicknessScale
'
].
value
;
};
var
thicknessControls
=
new
ThicknessControls
();
var
thicknessFolder
=
gui
.
addFolder
(
'
Thickness Control
'
);
thicknessFolder
.
add
(
thicknessControls
,
'
distoration
'
).
min
(
0.01
).
max
(
1
).
step
(
0.01
).
onChange
(
function
()
{
uniforms
[
'
thicknessDistortion
'
].
value
=
thicknessControls
.
distoration
;
});
thicknessFolder
.
add
(
thicknessControls
,
'
ambient
'
).
min
(
0.01
).
max
(
5.0
).
step
(
0.05
).
onChange
(
function
()
{
uniforms
[
'
thicknessAmbient
'
].
value
=
thicknessControls
.
ambient
;
});
thicknessFolder
.
add
(
thicknessControls
,
'
attenuation
'
).
min
(
0.01
).
max
(
5.0
).
step
(
0.05
).
onChange
(
function
()
{
uniforms
[
'
thicknessAttenuation
'
].
value
=
thicknessControls
.
attenuation
;
});
thicknessFolder
.
add
(
thicknessControls
,
'
power
'
).
min
(
0.01
).
max
(
16.0
).
step
(
0.1
).
onChange
(
function
()
{
uniforms
[
'
thicknessPower
'
].
value
=
thicknessControls
.
power
;
});
thicknessFolder
.
add
(
thicknessControls
,
'
scale
'
).
min
(
0.01
).
max
(
50.0
).
step
(
0.1
).
onChange
(
function
()
{
uniforms
[
'
thicknessScale
'
].
value
=
thicknessControls
.
scale
;
});
thicknessFolder
.
open
();
}
function
onWindowResize
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录