Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
09db6d49
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,发现更多精彩内容 >>
提交
09db6d49
编写于
2月 04, 2017
作者:
M
Mr.doob
提交者:
GitHub
2月 04, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10721 from Kyle-Larson/feature/Issues/10703
FBXLoader2: Support for PreRotation
上级
ecd33267
83ffd72f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
97 addition
and
26 deletion
+97
-26
examples/js/loaders/FBXLoader2.js
examples/js/loaders/FBXLoader2.js
+94
-26
examples/webgl_loader_fbx.html
examples/webgl_loader_fbx.html
+3
-0
未找到文件。
examples/js/loaders/FBXLoader2.js
浏览文件 @
09db6d49
...
...
@@ -59,23 +59,22 @@
this
.
fileLoader
.
load
(
url
,
function
(
text
)
{
if
(
!
isFbxFormatASCII
(
text
)
)
{
try
{
console
.
error
(
'
FBXLoader: FBX Binary format not supported.
'
);
self
.
manager
.
itemError
(
url
);
return
;
var
scene
=
self
.
parse
(
text
,
resourceDirectory
);
onLoad
(
scene
);
}
if
(
getFbxVersion
(
text
)
<
7000
)
{
}
catch
(
error
)
{
console
.
error
(
'
FBXLoader: FBX version not supported for file at
'
+
url
+
'
, FileVersion:
'
+
getFbxVersion
(
text
)
);
self
.
manager
.
itemError
(
url
);
return
;
window
.
setTimeout
(
function
()
{
}
if
(
onError
)
onError
(
error
);
self
.
manager
.
itemError
(
url
);
},
0
);
var
scene
=
self
.
parse
(
text
,
resourceDirectory
);
onLoad
(
scene
);
}
},
onProgress
,
onError
);
...
...
@@ -93,6 +92,24 @@
var
loader
=
this
;
if
(
!
isFbxFormatASCII
(
FBXText
)
)
{
throw
new
Error
(
'
FBXLoader: FBX Binary format not supported.
'
);
self
.
manager
.
itemError
(
url
);
return
;
//TODO: Support Binary parsing. Hopefully in the future,
//we call var FBXTree = new BinaryParser().parse( FBXText );
}
if
(
getFbxVersion
(
FBXText
)
<
7000
)
{
throw
new
Error
(
'
FBXLoader: FBX version not supported for file at
'
+
url
+
'
, FileVersion:
'
+
getFbxVersion
(
text
)
);
self
.
manager
.
itemError
(
url
);
return
;
}
var
FBXTree
=
new
TextParser
().
parse
(
FBXText
);
var
connections
=
parseConnections
(
FBXTree
);
...
...
@@ -1193,11 +1210,7 @@
if
(
'
Lcl_Rotation
'
in
node
.
properties
)
{
var
rotation
=
parseFloatArray
(
node
.
properties
.
Lcl_Rotation
.
value
).
map
(
function
(
value
)
{
return
value
*
Math
.
PI
/
180
;
}
);
var
rotation
=
parseFloatArray
(
node
.
properties
.
Lcl_Rotation
.
value
).
map
(
degreeToRadian
);
rotation
.
push
(
'
ZYX
'
);
model
.
rotation
.
fromArray
(
rotation
);
...
...
@@ -1209,6 +1222,16 @@
}
if
(
'
PreRotation
'
in
node
.
properties
)
{
var
preRotations
=
new
THREE
.
Euler
().
setFromVector3
(
parseVector3
(
node
.
properties
.
PreRotation
).
multiplyScalar
(
Math
.
PI
/
180
),
'
ZYX
'
);
preRotations
=
new
THREE
.
Quaternion
().
setFromEuler
(
preRotations
);
var
currentRotation
=
new
THREE
.
Quaternion
().
setFromEuler
(
model
.
rotation
);
preRotations
.
multiply
(
currentRotation
);
model
.
rotation
.
setFromQuaternion
(
preRotations
,
'
ZYX
'
);
}
var
conns
=
connections
.
get
(
model
.
FBX_ID
);
for
(
var
parentIndex
=
0
;
parentIndex
<
conns
.
parents
.
length
;
parentIndex
++
)
{
...
...
@@ -1333,11 +1356,7 @@
if
(
'
Lcl_Rotation
'
in
node
.
properties
)
{
var
rotation
=
parseFloatArray
(
node
.
properties
.
Lcl_Rotation
.
value
).
map
(
function
(
value
)
{
return
value
*
Math
.
PI
/
180
;
}
);
var
rotation
=
parseFloatArray
(
node
.
properties
.
Lcl_Rotation
.
value
).
map
(
degreeToRadian
);
rotation
.
push
(
'
ZYX
'
);
model
.
rotation
.
fromArray
(
rotation
);
...
...
@@ -1349,6 +1368,16 @@
}
if
(
'
PreRotation
'
in
node
.
properties
)
{
var
preRotations
=
new
THREE
.
Euler
().
setFromVector3
(
parseVector3
(
node
.
properties
.
PreRotation
).
multiplyScalar
(
Math
.
PI
/
180
),
'
ZYX
'
);
preRotations
=
new
THREE
.
Quaternion
().
setFromEuler
(
preRotations
);
var
currentRotation
=
new
THREE
.
Quaternion
().
setFromEuler
(
model
.
rotation
);
preRotations
.
multiply
(
currentRotation
);
model
.
rotation
.
setFromQuaternion
(
preRotations
,
'
ZYX
'
);
}
}
// Silly hack with the animation parsing. We're gonna pretend the scene graph has a skeleton
...
...
@@ -1377,6 +1406,7 @@
var
rawCurves
=
FBXTree
.
Objects
.
subNodes
.
AnimationCurve
;
var
rawLayers
=
FBXTree
.
Objects
.
subNodes
.
AnimationLayer
;
var
rawStacks
=
FBXTree
.
Objects
.
subNodes
.
AnimationStack
;
var
rawModels
=
FBXTree
.
Objects
.
subNodes
.
Model
;
/**
* @type {{
...
...
@@ -1890,6 +1920,33 @@
}
returnObject
.
curves
.
get
(
id
)[
curveNode
.
attr
]
=
curveNode
;
if
(
curveNode
.
attr
===
'
R
'
)
{
var
curves
=
curveNode
.
curves
;
curves
.
x
.
values
=
curves
.
x
.
values
.
map
(
degreeToRadian
);
curves
.
y
.
values
=
curves
.
y
.
values
.
map
(
degreeToRadian
);
curves
.
z
.
values
=
curves
.
z
.
values
.
map
(
degreeToRadian
);
if
(
curveNode
.
preRotations
!==
null
)
{
var
preRotations
=
new
THREE
.
Euler
().
setFromVector3
(
curveNode
.
preRotations
,
'
ZYX
'
);
preRotations
=
new
THREE
.
Quaternion
().
setFromEuler
(
preRotations
);
var
frameRotation
=
new
THREE
.
Euler
();
var
frameRotationQuaternion
=
new
THREE
.
Quaternion
();
for
(
var
frame
=
0
;
frame
<
curves
.
x
.
times
.
length
;
++
frame
)
{
frameRotation
.
set
(
curves
.
x
.
values
[
frame
],
curves
.
y
.
values
[
frame
],
curves
.
z
.
values
[
frame
],
'
ZYX
'
);
frameRotationQuaternion
.
setFromEuler
(
frameRotation
).
premultiply
(
preRotations
);
frameRotation
.
setFromQuaternion
(
frameRotationQuaternion
,
'
ZYX
'
);
curves
.
x
.
values
[
frame
]
=
frameRotation
.
x
;
curves
.
y
.
values
[
frame
]
=
frameRotation
.
y
;
curves
.
z
.
values
[
frame
]
=
frameRotation
.
z
;
}
}
}
}
);
...
...
@@ -2350,7 +2407,12 @@
x
:
null
,
y
:
null
,
z
:
null
}
},
/**
* @type {number[]}
*/
preRotations
:
null
};
if
(
returnObject
.
attr
.
match
(
/S|R|T/
)
)
{
...
...
@@ -2395,6 +2457,12 @@
returnObject
.
containerBoneID
=
boneID
;
returnObject
.
containerID
=
containerIndices
[
containerIndicesIndex
].
ID
;
var
model
=
rawModels
[
returnObject
.
containerID
.
toString
()
];
if
(
'
PreRotation
'
in
model
.
properties
)
{
returnObject
.
preRotations
=
parseVector3
(
model
.
properties
.
PreRotation
).
multiplyScalar
(
Math
.
PI
/
180
);
}
break
;
}
...
...
@@ -2905,9 +2973,9 @@
if
(
hasCurve
(
animationNode
,
'
R
'
)
&&
hasKeyOnFrame
(
animationNode
.
R
,
frame
)
)
{
var
rotationX
=
degreeToRadian
(
animationNode
.
R
.
curves
.
x
.
values
[
frame
]
)
;
var
rotationY
=
degreeToRadian
(
animationNode
.
R
.
curves
.
y
.
values
[
frame
]
)
;
var
rotationZ
=
degreeToRadian
(
animationNode
.
R
.
curves
.
z
.
values
[
frame
]
)
;
var
rotationX
=
animationNode
.
R
.
curves
.
x
.
values
[
frame
]
;
var
rotationY
=
animationNode
.
R
.
curves
.
y
.
values
[
frame
]
;
var
rotationZ
=
animationNode
.
R
.
curves
.
z
.
values
[
frame
]
;
var
euler
=
new
THREE
.
Euler
(
rotationX
,
rotationY
,
rotationZ
,
'
ZYX
'
);
key
.
rot
=
new
THREE
.
Quaternion
().
setFromEuler
(
euler
).
toArray
();
...
...
examples/webgl_loader_fbx.html
浏览文件 @
09db6d49
...
...
@@ -92,6 +92,9 @@
};
var
onError
=
function
(
xhr
)
{
console
.
error
(
xhr
);
};
var
loader
=
new
THREE
.
FBXLoader
(
manager
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录