Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
cbb87c80
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,发现更多精彩内容 >>
提交
cbb87c80
编写于
2月 20, 2019
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Editor: Refactored animation support.
上级
8e4a57b0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
61 addition
and
60 deletion
+61
-60
editor/js/Editor.js
editor/js/Editor.js
+5
-0
editor/js/Loader.js
editor/js/Loader.js
+5
-1
editor/js/Sidebar.Animation.js
editor/js/Sidebar.Animation.js
+28
-59
editor/js/Viewport.js
editor/js/Viewport.js
+23
-0
未找到文件。
editor/js/Editor.js
浏览文件 @
cbb87c80
...
...
@@ -92,7 +92,9 @@ var Editor = function () {
this
.
materials
=
{};
this
.
textures
=
{};
this
.
scripts
=
{};
this
.
animations
=
{};
this
.
animationMixer
=
new
THREE
.
AnimationMixer
(
this
.
scene
);
this
.
selected
=
null
;
this
.
helpers
=
{};
...
...
@@ -466,6 +468,9 @@ Editor.prototype = {
this
.
materials
=
{};
this
.
textures
=
{};
this
.
scripts
=
{};
this
.
animations
=
{};
this
.
animationMixer
.
stopAllAction
();
this
.
deselect
();
...
...
editor/js/Loader.js
浏览文件 @
cbb87c80
...
...
@@ -217,6 +217,7 @@ var Loader = function ( editor ) {
var
scene
=
result
.
scene
;
scene
.
name
=
filename
;
editor
.
addAnimation
(
scene
,
result
.
animations
);
editor
.
execute
(
new
AddObjectCommand
(
scene
)
);
...
...
@@ -249,6 +250,7 @@ var Loader = function ( editor ) {
var
scene
=
result
.
scene
;
scene
.
name
=
filename
;
editor
.
addAnimation
(
scene
,
result
.
animations
);
editor
.
execute
(
new
AddObjectCommand
(
scene
)
);
...
...
@@ -347,8 +349,8 @@ var Loader = function ( editor ) {
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
mesh
.
mixer
=
new
THREE
.
AnimationMixer
(
mesh
);
mesh
.
name
=
filename
;
editor
.
addAnimation
(
mesh
,
geometry
.
animations
);
editor
.
addAnimation
(
mesh
,
geometry
.
animations
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
},
false
);
...
...
@@ -684,6 +686,7 @@ var Loader = function ( editor ) {
loader
.
parse
(
file
.
asArrayBuffer
(),
''
,
function
(
result
)
{
var
scene
=
result
.
scene
;
editor
.
addAnimation
(
scene
,
result
.
animations
);
editor
.
execute
(
new
AddObjectCommand
(
scene
)
);
...
...
@@ -697,6 +700,7 @@ var Loader = function ( editor ) {
loader
.
parse
(
file
.
asText
(),
''
,
function
(
result
)
{
var
scene
=
result
.
scene
;
editor
.
addAnimation
(
scene
,
result
.
animations
);
editor
.
execute
(
new
AddObjectCommand
(
scene
)
);
...
...
editor/js/Sidebar.Animation.js
浏览文件 @
cbb87c80
...
...
@@ -5,34 +5,32 @@
Sidebar
.
Animation
=
function
(
editor
)
{
var
signals
=
editor
.
signals
;
var
mixer
=
editor
.
animationMixer
;
var
renderer
=
null
;
signals
.
rendererChanged
.
add
(
function
(
newRenderer
)
{
renderer
=
newRenderer
;
}
);
var
actions
=
{};
signals
.
objectSelected
.
add
(
function
(
object
)
{
var
uuid
=
object
!==
null
?
object
.
uuid
:
''
;
var
animations
=
editor
.
animations
[
uuid
];
var
animations
=
editor
.
animations
[
object
!==
null
?
object
.
uuid
:
''
]
;
if
(
animations
!==
undefined
)
{
container
.
setDisplay
(
''
);
mixer
=
new
THREE
.
AnimationMixer
(
object
);
var
options
=
{};
var
firstAnimation
;
for
(
var
animation
of
animations
)
{
options
[
animation
.
name
]
=
animation
.
name
;
if
(
firstAnimation
===
undefined
)
firstAnimation
=
animation
.
name
;
var
action
=
mixer
.
clipAction
(
animation
);
actions
[
animation
.
name
]
=
action
;
actions
[
animation
.
name
]
=
mixer
.
clipAction
(
animation
,
object
);
options
[
animation
.
name
]
=
animation
.
name
;
}
animationsSelect
.
setOptions
(
options
);
animationsSelect
.
setValue
(
firstAnimation
);
}
else
{
...
...
@@ -42,73 +40,44 @@ Sidebar.Animation = function ( editor ) {
}
);
var
mixer
,
currentAnimation
,
actions
=
{};
var
clock
=
new
THREE
.
Clock
();
function
updateAnimation
()
{
if
(
mixer
!==
undefined
&&
renderer
!==
null
)
{
signals
.
objectRemoved
.
add
(
function
(
object
)
{
var
dt
=
clock
.
getDelta
();
mixer
.
update
(
dt
*
speed
.
getValue
()
);
if
(
currentAnimation
!==
undefined
&&
currentAnimation
.
isRunning
()
)
{
var
animations
=
editor
.
animations
[
object
!==
null
?
object
.
uuid
:
''
];
requestAnimationFrame
(
updateAnimation
);
renderer
.
render
(
editor
.
scene
,
editor
.
camera
);
}
else
{
if
(
animations
!==
undefined
)
{
currentAnimation
=
undefined
;
}
mixer
.
uncacheRoot
(
object
);
}
}
function
playAnimation
()
{
currentAnimation
=
actions
[
animationsSelect
.
getValue
()
];
if
(
currentAnimation
!==
undefined
)
{
}
);
stopAnimations
();
currentAnimation
.
play
();
updateAnimation
();
function
playAction
()
{
}
actions
[
animationsSelect
.
getValue
()
].
play
();
}
function
stopAnimations
()
{
if
(
mixer
!==
undefined
)
{
function
stopAction
()
{
mixer
.
stopAllAction
();
}
actions
[
animationsSelect
.
getValue
()
].
stop
();
}
var
container
=
new
UI
.
Panel
();
container
.
setDisplay
(
'
none
'
);
container
.
add
(
new
UI
.
Text
(
'
Animation
'
).
setTextTransform
(
'
uppercase
'
)
);
container
.
add
(
new
UI
.
Text
(
'
Animations
'
).
setTextTransform
(
'
uppercase
'
)
);
container
.
add
(
new
UI
.
Break
()
);
container
.
add
(
new
UI
.
Break
()
);
var
div
=
new
UI
.
Div
()
.
setMarginLeft
(
'
90px
'
)
;
var
div
=
new
UI
.
Div
();
container
.
add
(
div
);
div
.
add
(
new
UI
.
Button
(
"
Play
"
).
setFontSize
(
'
12px
'
).
onClick
(
playAnimation
).
setMarginRight
(
'
10px
'
)
);
div
.
add
(
new
UI
.
Button
(
"
Stop
"
).
setFontSize
(
'
12px
'
).
onClick
(
stopAnimations
),
new
UI
.
Break
()
);
var
animationsSelect
=
new
UI
.
Select
().
setFontSize
(
'
12px
'
).
setMarginTop
(
'
10px
'
).
setMarginBottom
(
'
10px
'
);
div
.
add
(
animationsSelect
,
new
UI
.
Break
()
);
var
row
=
new
UI
.
Row
();
div
.
add
(
row
);
var
speed
=
new
UI
.
Number
(
1
).
setRange
(
0.25
,
2
).
setStep
(
0.5
).
setMarginLeft
(
'
10px
'
);
row
.
add
(
new
UI
.
Text
(
"
Speed
"
),
speed
);
var
animationsSelect
=
new
UI
.
Select
().
setFontSize
(
'
12px
'
);
div
.
add
(
animationsSelect
);
div
.
add
(
new
UI
.
Button
(
'
Play
'
).
setMarginLeft
(
'
4px
'
).
onClick
(
playAction
)
);
div
.
add
(
new
UI
.
Button
(
'
Stop
'
).
setMarginLeft
(
'
4px
'
).
onClick
(
stopAction
)
);
return
container
;
...
...
editor/js/Viewport.js
浏览文件 @
cbb87c80
...
...
@@ -519,6 +519,29 @@ var Viewport = function ( editor ) {
}
);
// animations
var
prevTime
=
performance
.
now
();
function
animate
(
time
)
{
requestAnimationFrame
(
animate
);
var
mixer
=
editor
.
animationMixer
;
if
(
mixer
.
stats
.
actions
.
inUse
>
0
)
{
editor
.
animationMixer
.
update
(
(
time
-
prevTime
)
/
1000
);
render
();
}
prevTime
=
time
;
}
requestAnimationFrame
(
animate
);
//
function
render
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录