Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
779655b4
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,发现更多精彩内容 >>
提交
779655b4
编写于
7月 01, 2016
作者:
S
ShynRou
提交者:
Mr.doob
7月 01, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reverted animation-io see #9192 (#9263)
上级
10e71fe6
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
90 addition
and
57 deletion
+90
-57
src/animation/AnimationClip.js
src/animation/AnimationClip.js
+1
-1
utils/exporters/blender/addons/io_three/exporter/api/animation.py
...porters/blender/addons/io_three/exporter/api/animation.py
+89
-56
未找到文件。
src/animation/AnimationClip.js
浏览文件 @
779655b4
...
...
@@ -326,7 +326,7 @@ Object.assign( THREE.AnimationClip, {
}
else
{
// ...assume skeletal animation
var
boneName
=
'
.bones[
'
+
bones
[
h
ierarchyTracks
[
h
].
parent
].
name
+
'
]
'
;
var
boneName
=
'
.bones[
'
+
bones
[
h
].
name
+
'
]
'
;
addNonemptyTrack
(
THREE
.
VectorKeyframeTrack
,
boneName
+
'
.position
'
,
...
...
utils/exporters/blender/addons/io_three/exporter/api/animation.py
浏览文件 @
779655b4
...
...
@@ -200,63 +200,78 @@ def _parse_pose_action(action, armature, options):
start_frame
=
action
.
frame_range
[
0
]
frame_length
=
end_frame
-
start_frame
frame_step
=
options
.
get
(
constants
.
FRAME_STEP
,
1
)
used_frames
=
int
(
frame_length
/
frame_step
)
+
1
frame_index_as_time
=
options
[
constants
.
FRAME_INDEX_AS_TIME
]
keys
=
[]
bone_index
=
0
;
channels_location
=
[]
channels_rotation
=
[]
channels_scale
=
[]
for
pose_bone
in
armature
.
pose
.
bones
:
logger
.
info
(
"Processing channels for %s"
,
pose_bone
.
bone
.
name
)
keys
.
append
([])
channels_location
.
append
(
_find_channels
(
action
,
pose_bone
.
bone
,
'location'
))
channels_rotation
.
append
(
_find_channels
(
action
,
pose_bone
.
bone
,
'rotation_quaternion'
))
channels_rotation
.
append
(
_find_channels
(
action
,
pose_bone
.
bone
,
'rotation_euler'
))
channels_scale
.
append
(
_find_channels
(
action
,
pose_bone
.
bone
,
'scale'
))
frame_step
=
options
[
constants
.
FRAME_STEP
]
frame_index_as_time
=
options
[
constants
.
FRAME_INDEX_AS_TIME
]
for
frame_index
in
range
(
0
,
used_frames
):
if
frame_index
==
used_frames
-
1
:
frame
=
end_frame
else
:
frame
=
start_frame
+
frame_index
*
frame_step
channels_location
=
_find_channels
(
action
,
pose_bone
.
bone
,
'location'
)
channels_rotation_q
=
_find_channels
(
action
,
pose_bone
.
bone
,
'rotation_quaternion'
)
channels_rotation
=
(
_find_channels
(
action
,
pose_bone
.
bone
,
'rotation_euler'
))
channels_scale
=
_find_channels
(
action
,
pose_bone
.
bone
,
'scale'
)
logger
.
info
(
"Processing frame %d"
,
frame
)
time
=
frame
-
start_frame
if
frame_index_as_time
is
False
:
time
=
time
/
fps
keyframes_times_location
=
[]
keyframes_times_rotation
=
[]
keyframes_times_scale
=
[]
keyframes_times
=
[]
context
.
scene
.
frame_set
(
frame
)
def
add_keyframes_times
(
target
,
channels
):
for
channel
in
channels
:
for
keyframe
in
channel
.
keyframe_points
:
time
=
int
(
keyframe
.
co
[
0
])
if
not
time
in
target
:
target
.
append
(
time
)
return
target
bone_index
=
0
add_keyframes_times
(
keyframes_times_location
,
channels_location
)
add_keyframes_times
(
keyframes_times_rotation
,
channels_rotation_q
)
add_keyframes_times
(
keyframes_times_rotation
,
channels_rotation
)
add_keyframes_times
(
keyframes_times_scale
,
channels_scale
)
def
has_keyframe_at
(
channels
,
frame
):
"""
def
merge_times
(
target
,
source
):
for
time
in
source
:
if
not
time
in
target
:
target
.
append
(
time
)
return
target
:param channels:
:param frame:
merge_times
(
keyframes_times
,
keyframes_times_location
)
merge_times
(
keyframes_times
,
keyframes_times_rotation
)
merge_times
(
keyframes_times
,
keyframes_times_scale
)
"""
def
find_keyframe_at
(
channel
,
frame
):
"""
keyframes_times
.
sort
()
:param channel:
:param frame:
for
keyframe_time
in
keyframes_times
:
"""
for
keyframe
in
channel
.
keyframe_points
:
if
keyframe
.
co
[
0
]
==
frame
:
return
keyframe
return
None
context
.
scene
.
frame_set
(
keyframe_time
)
for
channel
in
channels
:
if
not
find_keyframe_at
(
channel
,
frame
)
is
None
:
return
True
return
False
time
=
keyframe_time
-
start_frame
if
frame_index_as_time
is
False
:
time
=
time
/
fps
for
pose_bone
in
armature
.
pose
.
bones
:
logger
.
info
(
"Processing bone %s"
,
pose_bone
.
bone
.
name
)
if
pose_bone
.
parent
is
None
:
...
...
@@ -269,36 +284,48 @@ def _parse_pose_action(action, armature, options):
pos
,
rot
,
scl
=
bone_matrix
.
decompose
()
rot
=
_normalize_quaternion
(
rot
)
pchange
=
True
or
has_keyframe_at
(
channels_location
[
bone_index
],
frame
)
rchange
=
True
or
has_keyframe_at
(
channels_rotation
[
bone_index
],
frame
)
schange
=
True
or
has_keyframe_at
(
channels_scale
[
bone_index
],
frame
)
pos
=
(
pos
.
x
,
pos
.
z
,
-
pos
.
y
)
rot
=
(
rot
.
x
,
rot
.
z
,
-
rot
.
y
,
rot
.
w
)
scl
=
(
scl
.
x
,
scl
.
z
,
-
scl
.
y
)
scl
=
(
scl
.
x
,
scl
.
z
,
scl
.
y
)
keyframe
=
{
constants
.
TIME
:
time
}
if
keyframe_time
in
keyframes_times_location
:
if
frame
==
start_frame
or
frame
==
end_frame
:
keyframe
.
update
({
constants
.
POS
:
pos
,
constants
.
ROT
:
rot
,
constants
.
SCL
:
scl
})
elif
any
([
pchange
,
rchange
,
schange
]):
if
pchange
is
True
:
keyframe
[
constants
.
POS
]
=
pos
if
keyframe_time
in
keyframes_times_rotation
:
if
rchange
is
True
:
keyframe
[
constants
.
ROT
]
=
rot
if
keyframe_time
in
keyframes_times_scal
e
:
if
schange
is
Tru
e
:
keyframe
[
constants
.
SCL
]
=
scl
if
len
(
keyframe
.
keys
())
>
0
:
if
len
(
keyframe
.
keys
())
>
1
:
logger
.
info
(
"Recording keyframe data for %s %s"
,
pose_bone
.
bone
.
name
,
str
(
keyframe
))
keys
[
bone_index
].
append
(
keyframe
)
else
:
logger
.
info
(
"No anim data to record for %s"
,
pose_bone
.
bone
.
name
)
bone_index
+=
1
hierarchy
=
[]
bone_index
=
0
for
pose_bone
in
armature
.
pose
.
bones
:
if
len
(
keys
[
bone_index
])
>
0
:
hierarchy
.
append
({
constants
.
PARENT
:
bone_index
,
constants
.
KEYS
:
keys
[
bone_index
],
constants
.
PARENT
:
bone_index
-
1
,
constants
.
KEYS
:
keys
[
bone_index
]
})
bone_index
+=
1
...
...
@@ -328,10 +355,16 @@ def _find_channels(action, bone, channel_type):
"""
result
=
[]
if
len
(
action
.
groups
)
>
0
:
for
group
in
action
.
groups
:
if
len
(
action
.
groups
):
group_index
=
-
1
for
index
,
group
in
enumerate
(
action
.
groups
):
if
group
.
name
==
bone
.
name
:
for
channel
in
group
.
channels
:
group_index
=
index
# @TODO: break?
if
group_index
>
-
1
:
for
channel
in
action
.
groups
[
group_index
].
channels
:
if
channel_type
in
channel
.
data_path
:
result
.
append
(
channel
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录