Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
e69b69d6
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,发现更多精彩内容 >>
提交
e69b69d6
编写于
11月 23, 2017
作者:
L
Lewy Blue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Further refactor animation methods
上级
ce2867d5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
50 addition
and
79 deletion
+50
-79
examples/js/loaders/FBXLoader.js
examples/js/loaders/FBXLoader.js
+50
-79
未找到文件。
examples/js/loaders/FBXLoader.js
浏览文件 @
e69b69d6
...
...
@@ -2063,92 +2063,88 @@
// format and is no longer used
function
parseAnimations
(
FBXTree
,
connections
,
modelsArray
)
{
var
rawNodes
=
FBXTree
.
Objects
.
subNodes
.
AnimationCurveNode
;
var
rawCurves
=
FBXTree
.
Objects
.
subNodes
.
AnimationCurve
;
var
rawCurveNodes
=
FBXTree
.
Objects
.
subNodes
.
AnimationCurveNode
;
var
rawLayers
=
FBXTree
.
Objects
.
subNodes
.
AnimationLayer
;
var
rawStacks
=
FBXTree
.
Objects
.
subNodes
.
AnimationStack
;
// since the actual transformation data is stored in
rawCurves, if this is undefined we
// can safely assume there are no animations
if
(
rawCurves
===
undefined
)
return
undefined
;
// since the actual transformation data is stored in
FBXTree.Objects.subNodes.AnimationCurve,
//
if this is undefined we
can safely assume there are no animations
if
(
FBXTree
.
Objects
.
subNodes
.
AnimationCurve
===
undefined
)
return
undefined
;
var
animations
=
{
takes
:
{},
fps
:
getFrameRate
(
FBXTree
),
};
var
animationCurveNodes
=
[];
for
(
var
nodeID
in
rawNodes
)
{
var
curveNodesMap
=
new
Map
();
if
(
nodeID
.
match
(
/
\d
+/
)
)
{
var
animationNode
=
parseAnimationCurveNode
(
FBXTree
,
rawNodes
[
nodeID
],
connections
,
modelsArray
);
animationCurveNodes
.
push
(
animationNode
);
for
(
var
nodeID
in
rawCurveNodes
)
{
}
if
(
nodeID
.
match
(
/
\d
+/
)
)
{
}
var
animationNode
=
parseAnimationCurveNode
(
FBXTree
,
rawCurveNodes
[
nodeID
],
connections
,
modelsArray
);
var
tmpMap
=
new
Map
();
for
(
var
animationCurveNodeIndex
=
0
;
animationCurveNodeIndex
<
animationCurveNodes
.
length
;
++
animationCurveNodeIndex
)
{
if
(
animationNode
!==
null
)
{
if
(
animationCurveNodes
[
animationCurveNodeIndex
]
===
null
)
{
curveNodesMap
.
set
(
animationNode
.
id
,
animationNode
);
continue
;
}
}
tmpMap
.
set
(
animationCurveNodes
[
animationCurveNodeIndex
].
id
,
animationCurveNodes
[
animationCurveNodeIndex
]
);
}
var
animationCurves
=
[];
for
(
nodeID
in
rawCurves
)
{
if
(
nodeID
.
match
(
/
\d
+/
)
)
{
var
animationCurve
=
parseAnimationCurve
(
rawCurves
[
nodeID
]
);
animationCurves
.
push
(
animationCurve
);
var
conns
=
connections
.
get
(
animationCurve
.
id
);
var
firstParentConn
=
connections
.
get
(
animationCurve
.
id
).
parents
[
0
];
var
firstParentID
=
firstParentConn
.
ID
;
var
firstParentRelationship
=
firstParentConn
.
relationship
;
var
axis
=
''
;
if
(
conns
!==
undefined
)
{
if
(
firstParentRelationship
.
match
(
/X/
)
)
{
var
firstParentConn
=
conns
.
parents
[
0
];
var
firstParentID
=
firstParentConn
.
ID
;
var
firstParentRelationship
=
firstParentConn
.
relationship
;
var
axis
=
''
;
axis
=
'
x
'
;
if
(
firstParentRelationship
.
match
(
/X/
)
)
{
}
else
if
(
firstParentRelationship
.
match
(
/Y/
)
)
{
axis
=
'
x
'
;
axis
=
'
y
'
;
}
else
if
(
firstParentRelationship
.
match
(
/Y/
)
)
{
}
else
if
(
firstParentRelationship
.
match
(
/Z/
)
)
{
axis
=
'
y
'
;
axis
=
'
z
'
;
}
else
if
(
firstParentRelationship
.
match
(
/Z/
)
)
{
}
else
{
axis
=
'
z
'
;
continue
;
}
else
{
}
continue
;
}
tmpMap
.
get
(
firstParentID
).
curves
[
axis
]
=
animationCurve
;
curveNodesMap
.
get
(
firstParentID
).
curves
[
axis
]
=
animationCurve
;
}
}
}
var
emptyCurve
=
{
version
:
null
,
times
:
[
0.0
],
values
:
[
0.0
]
};
// loop over rotation values, convert to radians and add any pre rotation
tmp
Map
.
forEach
(
function
(
curveNode
)
{
curveNodes
Map
.
forEach
(
function
(
curveNode
)
{
if
(
curveNode
.
attr
===
'
R
'
)
{
...
...
@@ -2164,7 +2160,9 @@
if
(
curveNode
.
preRotations
!==
null
)
{
var
preRotations
=
new
THREE
.
Euler
().
setFromVector3
(
curveNode
.
preRotations
,
'
ZYX
'
);
var
preRotations
=
curveNode
.
preRotations
.
map
(
THREE
.
Math
.
degToRad
);
preRotations
.
push
(
'
ZYX
'
);
preRotations
=
new
THREE
.
Euler
().
fromArray
(
preRotations
);
preRotations
=
new
THREE
.
Quaternion
().
setFromEuler
(
preRotations
);
var
frameRotation
=
new
THREE
.
Euler
();
...
...
@@ -2202,9 +2200,9 @@
for
(
var
childIndex
=
0
;
childIndex
<
children
.
length
;
childIndex
++
)
{
// Skip lockInfluenceWeights
if
(
tmp
Map
.
has
(
children
[
childIndex
].
ID
)
)
{
if
(
curveNodes
Map
.
has
(
children
[
childIndex
].
ID
)
)
{
var
curveNode
=
tmp
Map
.
get
(
children
[
childIndex
].
ID
);
var
curveNode
=
curveNodes
Map
.
get
(
children
[
childIndex
].
ID
);
var
boneID
=
curveNode
.
containerBoneID
;
if
(
layer
[
boneID
]
===
undefined
)
{
...
...
@@ -2262,10 +2260,12 @@
if
(
timestamps
.
max
>
timestamps
.
min
)
{
animations
.
takes
[
nodeID
]
=
{
name
:
rawStacks
[
nodeID
].
attrName
,
layers
:
layers
,
length
:
timestamps
.
max
-
timestamps
.
min
,
frames
:
(
timestamps
.
max
-
timestamps
.
min
)
*
animations
.
fps
};
}
...
...
@@ -2276,6 +2276,7 @@
}
// parse a node in FBXTree.Objects.subNodes.AnimationCurveNode
function
parseAnimationCurveNode
(
FBXTree
,
animationCurveNode
,
connections
,
modelsArray
)
{
var
rawModels
=
FBXTree
.
Objects
.
subNodes
.
Model
;
...
...
@@ -2284,48 +2285,17 @@
id
:
animationCurveNode
.
id
,
attr
:
animationCurveNode
.
attrName
,
internalID
:
animationCurveNode
.
id
,
attrX
:
false
,
attrY
:
false
,
attrZ
:
false
,
containerBoneID
:
-
1
,
containerID
:
-
1
,
curves
:
{
x
:
null
,
y
:
null
,
z
:
null
},
preRotations
:
null
preRotations
:
null
,
};
if
(
returnObject
.
attr
.
match
(
/S|R|T/
)
)
{
for
(
var
attributeKey
in
animationCurveNode
.
properties
)
{
if
(
attributeKey
.
match
(
/X/
)
)
{
returnObject
.
attrX
=
true
;
}
if
(
attributeKey
.
match
(
/Y/
)
)
{
returnObject
.
attrY
=
true
;
}
if
(
attributeKey
.
match
(
/Z/
)
)
{
returnObject
.
attrZ
=
true
;
}
}
}
else
{
return
null
;
}
if
(
returnObject
.
attr
.
match
(
/S|R|T/
)
===
null
)
return
null
;
var
conns
=
connections
.
get
(
returnObject
.
id
);
var
containerIndices
=
conns
.
parents
;
...
...
@@ -2337,15 +2307,18 @@
return
bone
.
FBX_ID
===
containerIndices
[
containerIndicesIndex
].
ID
;
}
);
if
(
boneID
>
-
1
)
{
returnObject
.
containerBoneID
=
boneID
;
returnObject
.
containerID
=
containerIndices
[
containerIndicesIndex
].
ID
;
var
model
=
rawModels
[
returnObject
.
containerID
.
toString
()
];
var
model
=
rawModels
[
containerIndices
[
containerIndicesIndex
].
ID
.
toString
()
];
// if the animated model is pre rotated, we'll have to apply the prerotations to every
// animation value as well
if
(
'
PreRotation
'
in
model
.
properties
)
{
returnObject
.
preRotations
=
new
THREE
.
Vector3
().
fromArray
(
model
.
properties
.
PreRotation
.
value
).
multiplyScalar
(
Math
.
PI
/
180
)
;
returnObject
.
preRotations
=
model
.
properties
.
PreRotation
.
value
;
}
break
;
...
...
@@ -2358,17 +2331,15 @@
}
// parse single node in FBXTree.Objects.subNodes.AnimationCurve
function
parseAnimationCurve
(
animationCurve
)
{
return
{
version
:
null
,
id
:
animationCurve
.
id
,
internalID
:
animationCurve
.
id
,
times
:
animationCurve
.
subNodes
.
KeyTime
.
properties
.
a
.
map
(
convertFBXTimeToSeconds
),
values
:
animationCurve
.
subNodes
.
KeyValueFloat
.
properties
.
a
,
attrFlag
:
animationCurve
.
subNodes
.
KeyAttrFlags
.
properties
.
a
,
attrData
:
animationCurve
.
subNodes
.
KeyAttrDataFloat
.
properties
.
a
,
};
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录