Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
284f9600
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,发现更多精彩内容 >>
提交
284f9600
编写于
3月 27, 2017
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FBXLoader2: Performance optimisations and clean up.
上级
e704f793
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
47 addition
and
45 deletion
+47
-45
examples/js/loaders/FBXLoader2.js
examples/js/loaders/FBXLoader2.js
+47
-45
未找到文件。
examples/js/loaders/FBXLoader2.js
浏览文件 @
284f9600
...
...
@@ -545,32 +545,34 @@
var
geometry
=
new
Geometry
();
var
subNodes
=
geometryNode
.
subNodes
;
// First, each index is going to be its own vertex.
var
vertexBuffer
=
parseFloatArray
(
geometryNode
.
subNodes
.
Vertices
.
properties
.
a
);
var
indexBuffer
=
parseIntArray
(
geometryNode
.
subNodes
.
PolygonVertexIndex
.
properties
.
a
);
var
vertexBuffer
=
parseFloatArray
(
subNodes
.
Vertices
.
properties
.
a
);
var
indexBuffer
=
parseIntArray
(
subNodes
.
PolygonVertexIndex
.
properties
.
a
);
if
(
'
LayerElementNormal
'
in
geometryNode
.
subNodes
)
{
if
(
subNodes
.
LayerElementNormal
)
{
var
normalInfo
=
getNormals
(
geometryNode
);
var
normalInfo
=
getNormals
(
subNodes
.
LayerElementNormal
[
0
]
);
}
if
(
'
LayerElementUV
'
in
geometryNode
.
subNodes
)
{
if
(
subNodes
.
LayerElementUV
)
{
var
uvInfo
=
getUVs
(
geometryNode
);
var
uvInfo
=
getUVs
(
subNodes
.
LayerElementUV
[
0
]
);
}
if
(
'
LayerElementColor
'
in
geometryNode
.
subNodes
)
{
if
(
subNodes
.
LayerElementColor
)
{
var
colorInfo
=
getColors
(
geometryNode
);
var
colorInfo
=
getColors
(
subNodes
.
LayerElementColor
[
0
]
);
}
if
(
'
LayerElementMaterial
'
in
geometryNode
.
subNodes
)
{
if
(
subNodes
.
LayerElementMaterial
)
{
var
materialInfo
=
getMaterials
(
geometryNode
);
var
materialInfo
=
getMaterials
(
subNodes
.
LayerElementMaterial
[
0
]
);
}
...
...
@@ -698,6 +700,7 @@
geometry
.
faces
.
push
(
face
);
faceVertexBuffer
=
[];
polygonIndex
++
;
endOfFace
=
false
;
}
...
...
@@ -723,7 +726,7 @@
geo
.
addAttribute
(
'
uv
'
,
new
THREE
.
BufferAttribute
(
new
Float32Array
(
bufferInfo
.
uvBuffer
),
2
)
);
}
if
(
'
LayerElementColor
'
in
geometryNode
.
subNodes
)
{
if
(
subNodes
.
LayerElementColor
)
{
geo
.
addAttribute
(
'
color
'
,
new
THREE
.
BufferAttribute
(
new
Float32Array
(
bufferInfo
.
colorBuffer
),
3
)
);
...
...
@@ -767,9 +770,7 @@
* @param {FBXGeometryNode} geometryNode
* @returns {{dataSize: number, buffer: number[], indices: number[], mappingType: string, referenceType: string}}
*/
function
getNormals
(
geometryNode
)
{
var
NormalNode
=
geometryNode
.
subNodes
.
LayerElementNormal
[
0
];
function
getNormals
(
NormalNode
)
{
var
mappingType
=
NormalNode
.
properties
.
MappingInformationType
;
var
referenceType
=
NormalNode
.
properties
.
ReferenceInformationType
;
...
...
@@ -804,9 +805,7 @@
* @param {FBXGeometryNode} geometryNode
* @returns {{dataSize: number, buffer: number[], indices: number[], mappingType: string, referenceType: string}}
*/
function
getUVs
(
geometryNode
)
{
var
UVNode
=
geometryNode
.
subNodes
.
LayerElementUV
[
0
];
function
getUVs
(
UVNode
)
{
var
mappingType
=
UVNode
.
properties
.
MappingInformationType
;
var
referenceType
=
UVNode
.
properties
.
ReferenceInformationType
;
...
...
@@ -833,9 +832,7 @@
* @param {FBXGeometryNode} geometryNode
* @returns {{dataSize: number, buffer: number[], indices: number[], mappingType: string, referenceType: string}}
*/
function
getColors
(
geometryNode
)
{
var
ColorNode
=
geometryNode
.
subNodes
.
LayerElementColor
[
0
];
function
getColors
(
ColorNode
)
{
var
mappingType
=
ColorNode
.
properties
.
MappingInformationType
;
var
referenceType
=
ColorNode
.
properties
.
ReferenceInformationType
;
...
...
@@ -862,11 +859,11 @@
* @param {FBXGeometryNode}
* @returns {{dataSize: number, buffer: number[], indices: number[], mappingType: string, referenceType: string}}
*/
function
getMaterials
(
geometry
Node
)
{
function
getMaterials
(
Material
Node
)
{
var
MaterialNode
=
geometryNode
.
subNodes
.
LayerElementMaterial
[
0
];
var
mappingType
=
MaterialNode
.
properties
.
MappingInformationType
;
var
referenceType
=
MaterialNode
.
properties
.
ReferenceInformationType
;
if
(
mappingType
===
'
NoMappingInformation
'
)
{
return
{
...
...
@@ -878,12 +875,14 @@
};
}
var
materialIndexBuffer
=
parseIntArray
(
MaterialNode
.
subNodes
.
Materials
.
properties
.
a
);
// Since materials are stored as indices, there's a bit of a mismatch between FBX and what
// we expect. So we create an intermediate buffer that points to the index in the buffer,
// for conforming with the other functions we've written for other data.
var
materialIndices
=
[];
for
(
var
materialIndexBufferIndex
=
0
,
materialIndexBufferLength
=
materialIndexBuffer
.
length
;
materialIndexBufferIndex
<
materialIndexBufferLength
;
++
materialIndexBufferIndex
)
{
materialIndices
.
push
(
materialIndexBufferIndex
);
...
...
@@ -1150,23 +1149,12 @@
var
deformer
=
deformers
[
FBX_ID
];
var
subDeformers
=
deformer
.
map
;
var
subDeformer
=
subDeformers
[
conns
.
parents
[
i
].
ID
];
if
(
subDeformer
s
[
conns
.
parents
[
i
].
ID
]
!==
undefined
)
{
if
(
subDeformer
)
{
model
=
new
THREE
.
Bone
();
for
(
var
key
in
subDeformers
)
{
var
subDeformer
=
subDeformers
[
key
];
if
(
subDeformer
.
FBX_ID
===
conns
.
parents
[
i
].
ID
)
{
deformer
.
bones
[
subDeformer
.
index
]
=
model
;
break
;
}
}
deformer
.
bones
[
subDeformer
.
index
]
=
model
;
}
...
...
@@ -3701,7 +3689,7 @@
case
"
ColorRGB
"
:
case
"
Vector3D
"
:
innerPropValue
=
new
THREE
.
Vector3
().
fromArray
(
innerPropValue
.
split
(
'
,
'
).
map
(
parseFloatMap
)
);
innerPropValue
=
new
THREE
.
Vector3
().
fromArray
(
parseFloatArray
(
innerPropValue
)
);
break
;
}
...
...
@@ -3951,11 +3939,17 @@
*/
function
parseFloatArray
(
string
)
{
return
string
.
split
(
'
,
'
).
map
(
parseFloatMap
);
var
array
=
string
.
split
(
'
,
'
);
}
for
(
var
i
=
0
,
l
=
array
.
length
;
i
<
l
;
i
++
)
{
array
[
i
]
=
parseFloat
(
array
[
i
]
);
}
return
array
;
function
parseFloatMap
(
string
)
{
return
parseFloat
(
string
);
}
}
/**
* Parses comma separated list of int numbers and returns them in an array.
...
...
@@ -3966,11 +3960,17 @@
*/
function
parseIntArray
(
string
)
{
return
string
.
split
(
'
,
'
).
map
(
parseIntMap
);
var
array
=
string
.
split
(
'
,
'
);
}
for
(
var
i
=
0
,
l
=
array
.
length
;
i
<
l
;
i
++
)
{
array
[
i
]
=
parseInt
(
array
[
i
]
);
}
function
parseIntMap
(
string
)
{
return
parseInt
(
string
);
}
return
array
;
}
/**
* Parses Vector3 property from FBXTree. Property is given as .value.x, .value.y, etc.
...
...
@@ -3990,7 +3990,7 @@
*/
function
parseColor
(
property
)
{
return
new
THREE
.
Color
(
).
fromArray
(
parseVector3
(
property
).
toArray
(
)
);
return
new
THREE
.
Color
(
parseFloat
(
property
.
value
.
x
),
parseFloat
(
property
.
value
.
y
),
parseFloat
(
property
.
value
.
z
)
);
}
...
...
@@ -4007,10 +4007,12 @@
*/
function
degreeToRadian
(
value
)
{
return
value
*
Math
.
PI
/
180
;
return
value
*
DEG2RAD
;
}
var
DEG2RAD
=
Math
.
PI
/
180
;
//
function
findIndex
(
array
,
func
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录