Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
18efee3e
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,发现更多精彩内容 >>
提交
18efee3e
编写于
9月 24, 2017
作者:
L
Lewy Blue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed conflicts
上级
4ed5f096
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
143 addition
and
4 deletion
+143
-4
examples/js/loaders/FBXLoader.js
examples/js/loaders/FBXLoader.js
+143
-4
未找到文件。
examples/js/loaders/FBXLoader.js
浏览文件 @
18efee3e
...
...
@@ -112,7 +112,7 @@
}
//
console.log( FBXTree );
console
.
log
(
FBXTree
);
var
connections
=
parseConnections
(
FBXTree
);
var
images
=
parseImages
(
FBXTree
);
...
...
@@ -1449,6 +1449,145 @@
}
break
;
case
'
Light
'
:
/* ***********
* Supported light types:
* DirectionalLight
* PointLight
* SpotLight
*
* TODO: Support DirectionalLight and SpotLight targets
************** */
var
lightAttribute
;
for
(
var
childrenIndex
=
0
,
childrenLength
=
conns
.
children
.
length
;
childrenIndex
<
childrenLength
;
++
childrenIndex
)
{
var
childID
=
conns
.
children
[
childrenIndex
].
ID
;
var
attr
=
FBXTree
.
Objects
.
subNodes
.
NodeAttribute
[
childID
];
if
(
attr
!==
undefined
&&
attr
.
properties
!==
undefined
)
{
lightAttribute
=
attr
.
properties
;
}
}
if
(
lightAttribute
===
undefined
)
{
model
=
new
THREE
.
Object3D
();
}
else
{
console
.
log
(
lightAttribute
);
var
type
;
// LightType is undefined for Point lights
if
(
lightAttribute
.
LightType
===
undefined
)
{
type
=
'
0
'
;
}
else
{
type
=
lightAttribute
.
LightType
.
value
;
}
var
color
=
0xffffff
;
if
(
lightAttribute
.
Color
!==
undefined
)
{
var
temp
=
lightAttribute
.
Color
.
value
.
split
(
'
,
'
);
var
r
=
parseInt
(
temp
[
0
],
10
);
var
g
=
parseInt
(
temp
[
1
],
10
);
var
b
=
parseInt
(
temp
[
1
],
10
);
color
=
new
THREE
.
Color
(
r
,
g
,
b
);
}
var
intensity
=
(
lightAttribute
.
Intensity
===
undefined
)
?
1
:
lightAttribute
.
Intensity
.
value
/
100
;
// light disabled
if
(
lightAttribute
.
CastLightOnObject
!==
undefined
&&
lightAttribute
.
CastLightOnObject
.
value
===
'
0
'
)
{
intensity
=
0
;
}
var
distance
=
0
;
if
(
lightAttribute
.
FarAttenuationEnd
!==
undefined
)
{
if
(
lightAttribute
.
EnableFarAttenuation
!==
undefined
&&
lightAttribute
.
EnableFarAttenuation
.
value
===
'
0
'
)
{
distance
=
0
;
}
else
{
distance
=
lightAttribute
.
FarAttenuationEnd
.
value
/
1000
;
}
}
// TODO
// could be calculated linearly from FarAttenuationStart to FarAttenuationEnd ?
var
decay
=
1
;
switch
(
type
)
{
case
'
0
'
:
// Point
model
=
new
THREE
.
PointLight
(
color
,
intensity
,
distance
,
decay
);
break
;
case
'
1
'
:
// Directional
model
=
new
THREE
.
DirectionalLight
(
color
,
intensity
);
break
;
case
'
2
'
:
// Spot
var
angle
=
Math
.
PI
/
3
;
if
(
lightAttribute
.
InnerAngle
!==
undefined
)
{
angle
=
THREE
.
Math
.
degToRad
(
lightAttribute
.
InnerAngle
.
value
);
}
var
penumbra
=
0
;
// Falloff / Field
if
(
lightAttribute
.
OuterAngle
!==
undefined
)
{
// note: this is not correct - FBX calculates outer and inner angle in degrees
// with OuterAngle > InnerAngle && OuterAngle <= Math.PI
// while three.js uses a penumbra between (0, 1) to attenuate the inner angle
penumbra
=
THREE
.
Math
.
degToRad
(
lightAttribute
.
OuterAngle
.
value
);
penumbra
=
Math
.
max
(
penumbra
,
1
);
}
model
=
new
THREE
.
SpotLight
(
color
,
intensity
,
distance
,
angle
,
penumbra
,
decay
);
break
;
default
:
console
.
warn
(
'
THREE.FBXLoader: Unknown light type
'
+
lightAttribute
.
LightType
+
'
, defaulting to a THREE.PointLight.
'
);
model
=
new
THREE
.
PointLight
(
color
,
intensity
);
break
;
}
if
(
lightAttribute
.
CastShadows
!==
undefined
&&
lightAttribute
.
CastShadows
.
value
===
'
1
'
)
{
model
.
castShadow
=
true
;
}
}
break
;
case
'
NurbsCurve
'
:
var
geometry
=
null
;
...
...
@@ -1651,13 +1790,13 @@
addAnimations
(
sceneGraph
,
animations
);
/*
parse ambient color - if it's not set to black (default), create an ambient light
*/
// parse ambient color - if it's not set to black (default), create an ambient light
var
ambientColor
=
FBXTree
.
GlobalSettings
.
properties
.
AmbientColor
.
value
;
var
r
=
ambientColor
[
0
];
var
g
=
ambientColor
[
1
];
var
b
=
ambientColor
[
2
];
if
(
r
!==
0
||
g
!==
0
||
b
!==
0
)
{
var
color
=
new
THREE
.
Color
(
r
,
g
,
b
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录