Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
0b26080c
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,发现更多精彩内容 >>
提交
0b26080c
编写于
3月 12, 2018
作者:
D
Daosheng Mu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add webgl_materials_translucency subsurface scattering demo.
上级
7a0651d3
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
4490 addition
and
0 deletion
+4490
-0
examples/models/fbx/bunny_thickness.png
examples/models/fbx/bunny_thickness.png
+0
-0
examples/models/fbx/stanford-bunny.fbx
examples/models/fbx/stanford-bunny.fbx
+4314
-0
examples/models/fbx/white.jpg
examples/models/fbx/white.jpg
+0
-0
examples/webgl_materials_translucency.html
examples/webgl_materials_translucency.html
+176
-0
未找到文件。
examples/models/fbx/bunny_thickness.png
0 → 100644
浏览文件 @
0b26080c
8.6 MB
examples/models/fbx/stanford-bunny.fbx
0 → 100644
浏览文件 @
0b26080c
此差异已折叠。
点击以展开。
examples/models/fbx/white.jpg
0 → 100644
浏览文件 @
0b26080c
1.6 KB
examples/webgl_materials_translucency.html
0 → 100644
浏览文件 @
0b26080c
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<title>
three.js webgl - Fast subsurface scattering in Blinn-Phong shading demo
</title>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
>
<style>
body
{
color
:
#fff
;
font-family
:
Monospace
;
font-size
:
13px
;
text-align
:
center
;
background-color
:
#000
;
margin
:
0px
;
overflow
:
hidden
;
}
#info
{
position
:
absolute
;
top
:
0px
;
width
:
100%
;
padding
:
5px
;
}
</style>
</head>
<body>
<div
id=
"container"
></div>
<div
id=
"info"
><a
href=
"http://threejs.org"
target=
"_blank"
rel=
"noopener"
>
three.js
</a>
<br/>
Fast subsurface scattering in Blinn-Phong shading demo
<br/>
[Thanks for the art support from
<a
href=
"https://github.com/shaochun"
>
Shaochun Lin
</a>
]
</div>
<script
src=
"../build/three.js"
></script>
<script
src=
"js/controls/OrbitControls.js"
></script>
<script
src=
"js/Detector.js"
></script>
<script
src=
"js/libs/stats.min.js"
></script>
<script
src=
"js/loaders/FBXLoader.js"
></script>
<script
src=
"js/ShaderTranslucent.js"
></script>
<script>
if
(
!
Detector
.
webgl
)
Detector
.
addGetWebGLMessage
();
var
container
,
stats
,
font
;
var
camera
,
scene
,
renderer
,
controls
;
init
();
animate
();
function
init
()
{
container
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
container
);
font
=
font
;
camera
=
new
THREE
.
PerspectiveCamera
(
40
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
5000
);
camera
.
position
.
set
(
0.0
,
300
,
400
*
4
);
scene
=
new
THREE
.
Scene
();
// Lights
scene
.
add
(
new
THREE
.
AmbientLight
(
0x888888
)
);
var
directionalLight
=
new
THREE
.
DirectionalLight
(
0xffffff
,
0.03
);
directionalLight
.
position
.
set
(
0.0
,
0.5
,
0.5
).
normalize
();
scene
.
add
(
directionalLight
);
var
pointLight1
=
new
THREE
.
Mesh
(
new
THREE
.
SphereBufferGeometry
(
4
,
8
,
8
),
new
THREE
.
MeshBasicMaterial
(
{
color
:
0x888888
}
)
);
pointLight1
.
add
(
new
THREE
.
PointLight
(
0x888888
,
7.0
,
300
)
);
scene
.
add
(
pointLight1
);
pointLight1
.
position
.
x
=
0
;
pointLight1
.
position
.
y
=
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
=
150
;
pointLight2
.
position
.
y
=
-
100
;
pointLight2
.
position
.
z
=
-
250
;
renderer
=
new
THREE
.
WebGLRenderer
(
{
antialias
:
true
}
);
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
container
.
appendChild
(
renderer
.
domElement
);
renderer
.
gammaInput
=
true
;
renderer
.
gammaOutput
=
true
;
//
stats
=
new
Stats
();
container
.
appendChild
(
stats
.
dom
);
controls
=
new
THREE
.
OrbitControls
(
camera
);
window
.
addEventListener
(
'
resize
'
,
onWindowResize
,
false
);
initMaterial
();
}
function
initMaterial
()
{
var
shader
=
new
THREE
.
TranslucentShader
();
var
uniforms
=
THREE
.
UniformsUtils
.
clone
(
shader
.
uniforms
);
// Materials
var
loader
=
new
THREE
.
TextureLoader
();
var
imgTexture
=
loader
.
load
(
"
models/fbx/white.jpg
"
);
var
thicknessTexture
=
loader
.
load
(
"
models/fbx/bunny_thickness.png
"
);
imgTexture
.
wrapS
=
imgTexture
.
wrapT
=
THREE
.
RepeatWrapping
;
uniforms
[
"
map
"
].
value
=
imgTexture
;
uniforms
[
"
diffuse
"
].
value
=
new
THREE
.
Vector3
(
1.0
,
0.2
,
0.2
);
uniforms
[
"
shininess
"
].
value
=
500
;
uniforms
[
"
thicknessMap
"
].
value
=
thicknessTexture
;
uniforms
[
"
thicknessColor
"
].
value
=
new
THREE
.
Vector3
(
0.5
,
0.3
,
0.3
);
uniforms
[
"
thicknessDistortion
"
].
value
=
0.1
;
uniforms
[
"
thicknessAmbient
"
].
value
=
0.1
;
uniforms
[
"
thicknessAttenuation
"
].
value
=
0.8
;
uniforms
[
"
thicknessPower
"
].
value
=
2
;
uniforms
[
"
thicknessScale
"
].
value
=
10.0
;
var
parameters
=
{
fragmentShader
:
shader
.
fragmentShader
,
vertexShader
:
shader
.
vertexShader
,
uniforms
:
uniforms
,
lights
:
true
};
var
material
=
new
THREE
.
ShaderMaterial
(
parameters
);
material
.
extensions
.
derivatives
=
true
;
// LOADER
var
loader
=
new
THREE
.
FBXLoader
();
loader
.
load
(
"
models/fbx/stanford-bunny.fbx
"
,
function
(
object
)
{
loadedModel
(
object
,
1
,
material
);
});
}
function
loadedModel
(
object
,
scale
,
material
)
{
object
.
children
[
0
].
position
.
x
=
0
;
object
.
children
[
0
].
position
.
y
=
0
;
object
.
children
[
0
].
position
.
z
=
10
;
object
.
children
[
0
].
scale
.
set
(
scale
,
scale
,
scale
);
object
.
children
[
0
].
material
=
material
;
scene
.
add
(
object
);
}
function
onWindowResize
()
{
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
updateProjectionMatrix
();
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
}
//
function
animate
()
{
requestAnimationFrame
(
animate
);
render
();
stats
.
update
();
}
function
render
()
{
var
timer
=
Date
.
now
()
*
0.00025
;
camera
.
lookAt
(
scene
.
position
);
renderer
.
render
(
scene
,
camera
);
}
</script>
</body>
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录