Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
167d6597
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,发现更多精彩内容 >>
提交
167d6597
编写于
6月 28, 2018
作者:
L
Lewy Blue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added support for animated morph targets
上级
28c150bb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
57 addition
and
11 deletion
+57
-11
examples/js/loaders/FBXLoader.js
examples/js/loaders/FBXLoader.js
+57
-11
未找到文件。
examples/js/loaders/FBXLoader.js
浏览文件 @
167d6597
...
...
@@ -371,7 +371,7 @@
var
texture
;
if
(
textureNode
.
FileName
.
slice
(
-
3
).
toLowerCase
()
===
'
tga
'
)
{
if
(
textureNode
.
FileName
.
slice
(
-
3
).
toLowerCase
()
===
'
tga
'
)
{
texture
=
THREE
.
Loader
.
Handlers
.
get
(
'
.tga
'
).
load
(
fileName
);
...
...
@@ -419,7 +419,7 @@
var
name
=
materialNode
.
attrName
;
var
type
=
materialNode
.
ShadingModel
;
//Case where FBX wraps shading model in property object.
//
Case where FBX wraps shading model in property object.
if
(
typeof
type
===
'
object
'
)
{
type
=
type
.
value
;
...
...
@@ -637,7 +637,6 @@
morphTarget
.
id
=
nodeID
;
if
(
relationships
.
parents
.
length
>
1
)
console
.
warn
(
'
THREE.FBXLoader: morph target attached to more than one geometry is not supported.
'
);
morphTarget
.
parentGeoID
=
relationships
.
parents
[
0
].
ID
;
morphTargets
[
nodeID
]
=
morphTarget
;
...
...
@@ -753,7 +752,7 @@
}
}
)
}
)
;
// assuming each morph target has a single animation curve for now
rawMorphTarget
.
animationCurveID
=
animConnections
.
children
[
0
].
ID
;
...
...
@@ -1675,15 +1674,51 @@
}
);
bindSkeleton
(
FBXTree
,
deformers
.
skeletons
,
geometryMap
,
modelMap
,
connections
);
addAnimations
(
FBXTree
,
connections
,
sceneGraph
);
createAmbientLight
(
FBXTree
,
sceneGraph
);
setupMorphMaterials
(
sceneGraph
);
return
sceneGraph
;
}
function
setupMorphMaterials
(
sceneGraph
)
{
sceneGraph
.
traverse
(
function
(
child
)
{
if
(
child
.
isMesh
)
{
if
(
child
.
geometry
.
morphAttributes
.
position
||
child
.
geometry
.
morphAttributes
.
normal
)
{
var
uuid
=
child
.
uuid
;
var
matUuid
=
child
.
material
.
uuid
;
// if a geometry has morph targets, it cannot share the material with other geometries
var
sharedMat
=
false
;
sceneGraph
.
traverse
(
function
(
child
)
{
if
(
child
.
isMesh
)
{
if
(
child
.
material
.
uuid
===
matUuid
&&
child
.
uuid
!==
uuid
)
sharedMat
=
true
;
}
}
);
if
(
sharedMat
===
true
)
child
.
material
=
child
.
material
.
clone
();
child
.
material
.
morphTargets
=
true
;
}
}
}
);
}
// parse nodes in FBXTree.Objects.Model
function
parseModels
(
FBXTree
,
skeletons
,
geometryMap
,
materialMap
,
connections
)
{
...
...
@@ -2337,6 +2372,13 @@
var
rawCurves
=
FBXTree
.
Objects
.
AnimationCurve
;
// TODO: Many values are identical up to roundoff error, but won't be optimised
// e.g. position times: [0, 0.4, 0. 8]
// position values: [7.23538335023477e-7, 93.67518615722656, -0.9982695579528809, 7.23538335023477e-7, 93.67518615722656, -0.9982695579528809, 7.235384487103147e-7, 93.67520904541016, -0.9982695579528809]
// clearly, this should be optimised to
// times: [0], positions [7.23538335023477e-7, 93.67518615722656, -0.9982695579528809]
// this shows up in nearly every FBX file, and generally time array is length > 100
for
(
var
nodeID
in
rawCurves
)
{
var
animationCurve
=
{
...
...
@@ -2387,6 +2429,8 @@
var
layersMap
=
new
Map
();
// console.log( 'rawLayers', rawLayers );
for
(
var
nodeID
in
rawLayers
)
{
var
layerCurveNodes
=
[];
...
...
@@ -2405,19 +2449,18 @@
var
curveNode
=
curveNodesMap
.
get
(
child
.
ID
);
// check that the curves are defined for at least one axis, otherwise ignore the curveNode
if
(
curveNode
.
curves
.
x
!==
undefined
||
curveNode
.
curves
.
y
!==
undefined
||
curveNode
.
curves
.
z
!==
undefined
)
{
if
(
curveNode
.
curves
.
x
!==
undefined
||
curveNode
.
curves
.
y
!==
undefined
||
curveNode
.
curves
.
z
!==
undefined
)
{
if
(
layerCurveNodes
[
i
]
===
undefined
)
{
var
modelID
;
connections
.
get
(
c
urveNode
.
ID
).
parents
.
forEach
(
function
(
parent
)
{
connections
.
get
(
c
hild
.
ID
).
parents
.
forEach
(
function
(
parent
)
{
if
(
parent
.
relationship
!==
undefined
)
modelID
=
parent
.
ID
;
}
);
var
rawModel
=
FBXTree
.
Objects
.
Model
[
modelID
.
toString
()
];
var
node
=
{
...
...
@@ -2530,7 +2573,7 @@
}
// take raw animation
data from parseAnimations and connect it up to the loaded model
s
// take raw animation
clips and turn them into three.js animation clip
s
function
addAnimations
(
FBXTree
,
connections
,
sceneGraph
)
{
sceneGraph
.
animations
=
[];
...
...
@@ -2665,15 +2708,18 @@
}
var
morphNum
=
3
;
function
generateMorphTrack
(
modelName
,
curve
)
{
if
(
curve
.
times
.
length
!==
4
)
return
undefined
;
// HACK only add blink for now
var
values
=
curve
.
values
.
map
(
function
(
val
)
{
return
val
/
100
;
}
);
return
new
THREE
.
NumberKeyframeTrack
(
modelName
+
'
.morphTargetInfluences[
0
]
'
,
curve
.
times
,
values
);
return
new
THREE
.
NumberKeyframeTrack
(
modelName
+
'
.morphTargetInfluences[
3
]
'
,
curve
.
times
,
values
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录