Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
d8bc641b
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(gitcode.net)2024年7月9日维护升级公告
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d8bc641b
编写于
10月 27, 2018
作者:
L
Lewy Blue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added buffergeometry morph example
上级
c0dbf052
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
187 addition
and
0 deletion
+187
-0
examples/files.js
examples/files.js
+1
-0
examples/webgl_buffergeometry_morphtargets.html
examples/webgl_buffergeometry_morphtargets.html
+186
-0
未找到文件。
examples/files.js
浏览文件 @
d8bc641b
...
...
@@ -289,6 +289,7 @@ var files = {
"
webgl_buffergeometry_instancing_lambert
"
,
"
webgl_buffergeometry_lines
"
,
"
webgl_buffergeometry_lines_indexed
"
,
"
webgl_buffergeometry_morphtargets
"
,
"
webgl_buffergeometry_points
"
,
"
webgl_buffergeometry_points_interleaved
"
,
"
webgl_buffergeometry_rawshader
"
,
...
...
examples/webgl_buffergeometry_morphtargets.html
0 → 100644
浏览文件 @
d8bc641b
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<title>
three.js webgl - buffergeometry - morph targets
</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
{
margin
:
0px
;
overflow
:
hidden
;
text-align
:
center
;
}
#info
{
color
:
#fff
;
position
:
absolute
;
top
:
10px
;
width
:
100%
;
}
</style>
</head>
<body>
<div
id=
"container"
></div>
<div
id=
"info"
>
<a
href=
"http://threejs.org"
target=
"_blank"
rel=
"noopener"
>
three.js
</a>
- buffergeometry - morph targets
</div>
<script
src=
"../build/three.js"
></script>
<script
src=
"js/controls/OrbitControls.js"
></script>
<script
src=
"js/WebGL.js"
></script>
<script
src=
"js/libs/dat.gui.min.js"
></script>
<script>
var
container
,
camera
,
scene
,
renderer
,
mesh
;
function
init
()
{
if
(
WEBGL
.
isWebGLAvailable
()
===
false
)
{
document
.
body
.
appendChild
(
WEBGL
.
getWebGLErrorMessage
()
);
return
false
;
}
container
=
document
.
getElementById
(
'
container
'
);
camera
=
new
THREE
.
PerspectiveCamera
(
45
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
20
);
camera
.
position
.
z
=
10
;
var
controls
=
new
THREE
.
OrbitControls
(
camera
,
container
);
scene
=
new
THREE
.
Scene
();
scene
.
background
=
new
THREE
.
Color
(
0x8FBCD4
);
var
pointLight
=
new
THREE
.
PointLight
(
0xffffff
,
1
);
camera
.
add
(
pointLight
);
scene
.
add
(
camera
);
var
geometry
=
createGeometry
();
var
material
=
new
THREE
.
MeshPhongMaterial
(
{
flatShading
:
true
,
color
:
0xff0000
,
morphTargets
:
true
}
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
scene
.
add
(
mesh
);
initGUI
();
renderer
=
new
THREE
.
WebGLRenderer
(
{
antialias
:
true
}
);
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
renderer
.
setAnimationLoop
(
function
()
{
renderer
.
render
(
scene
,
camera
);
}
);
container
.
appendChild
(
renderer
.
domElement
);
window
.
addEventListener
(
'
resize
'
,
onWindowResize
,
false
);
}
function
createGeometry
()
{
var
geometry
=
new
THREE
.
BufferGeometry
();
// 2 x 2 cube centered at (0, 0, 0) defined by 8 corner vertices
var
positions
=
[
-
1
,
-
1
,
1
,
// front bottom left
1
,
-
1
,
1
,
// front bottom right
-
1
,
1
,
1
,
// front top left
1
,
1
,
1
,
// front top right
-
1
,
-
1
,
-
1
,
// back bottom left
1
,
-
1
,
-
1
,
// back bottom right
-
1
,
1
,
-
1
,
// back top left
1
,
1
,
-
1
,
// back top right
];
geometry
.
addAttribute
(
'
position
'
,
new
THREE
.
Float32BufferAttribute
(
positions
,
3
)
);
// each face consists of two triangles
var
indices
=
[
2
,
0
,
1
,
1
,
3
,
2
,
// front
4
,
6
,
5
,
6
,
7
,
5
,
// back
2
,
3
,
6
,
3
,
7
,
6
,
// top
0
,
4
,
5
,
5
,
1
,
0
,
// bottom
0
,
6
,
4
,
6
,
0
,
2
,
// left
1
,
5
,
3
,
3
,
5
,
7
// right
];
geometry
.
setIndex
(
indices
);
// create an empty array to hold targets for the attribute we want to morph
// morphing positions and normals is supported
geometry
.
morphAttributes
.
position
=
[];
// squash
var
morphTargetPositions0
=
[
-
1.25
,
-
1
,
1.25
,
1.25
,
-
1
,
1.25
,
-
1.25
,
0.5
,
1.25
,
1.25
,
0.5
,
1.25
,
-
1.25
,
-
1
,
-
1.25
,
1.25
,
-
1
,
-
1.25
,
-
1.25
,
0.5
,
-
1.25
,
1.25
,
0.5
,
-
1.25
,
];
geometry
.
morphAttributes
.
position
[
0
]
=
new
THREE
.
Float32BufferAttribute
(
morphTargetPositions0
,
3
);
// lean
var
morphTargetPositions1
=
[
-
1
,
-
1
,
1
,
1
,
-
1
,
1
,
-
1.5
,
1
,
1
,
0.5
,
1
,
1
,
-
1
,
-
1
,
-
1
,
1
,
-
1
,
-
1
,
-
1.5
,
1
,
-
1
,
0.5
,
1
,
-
1
,
];
geometry
.
morphAttributes
.
position
[
1
]
=
new
THREE
.
Float32BufferAttribute
(
morphTargetPositions1
,
3
);
return
geometry
;
}
function
initGUI
()
{
// Set up dat.GUI to control targets
var
params
=
{
squash
:
0
,
lean
:
0
,
};
var
gui
=
new
dat
.
GUI
();
var
folder
=
gui
.
addFolder
(
'
Morph Targets
'
);
folder
.
add
(
params
,
'
squash
'
,
0
,
1
).
step
(
0.01
).
onChange
(
function
(
value
)
{
mesh
.
morphTargetInfluences
[
0
]
=
value
;
}
);
folder
.
add
(
params
,
'
lean
'
,
0
,
1
).
step
(
0.01
).
onChange
(
function
(
value
)
{
mesh
.
morphTargetInfluences
[
1
]
=
value
;
}
);
folder
.
open
();
}
function
onWindowResize
()
{
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
updateProjectionMatrix
();
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
}
init
();
</script>
</body>
</html>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录