Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
2030f69a
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,发现更多精彩内容 >>
提交
2030f69a
编写于
3月 20, 2011
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge remote branch 'alteredq/experimental' into experimental
上级
6514f67c
6ee446f3
变更
22
展开全部
隐藏空白更改
内联
并排
Showing
22 changed file
with
660 addition
and
682 deletion
+660
-682
build/Three.js
build/Three.js
+254
-272
build/custom/ThreeCanvas.js
build/custom/ThreeCanvas.js
+7
-5
build/custom/ThreeDOM.js
build/custom/ThreeDOM.js
+3
-3
build/custom/ThreeExtras.js
build/custom/ThreeExtras.js
+69
-91
build/custom/ThreeSVG.js
build/custom/ThreeSVG.js
+6
-5
build/custom/ThreeWebGL.js
build/custom/ThreeWebGL.js
+129
-126
examples/obj/female02/Female02_bin.js
examples/obj/female02/Female02_bin.js
+3
-1
examples/obj/female02/Female02_slim.js
examples/obj/female02/Female02_slim.js
+10
-12
examples/obj/lucy/Lucy100k_bin.js
examples/obj/lucy/Lucy100k_bin.js
+3
-1
examples/obj/lucy/Lucy100k_slim.js
examples/obj/lucy/Lucy100k_slim.js
+10
-12
examples/obj/male02/Male02_bin.js
examples/obj/male02/Male02_bin.js
+3
-1
examples/obj/male02/Male02_slim.js
examples/obj/male02/Male02_slim.js
+10
-12
examples/obj/ninja/NinjaLo_bin.js
examples/obj/ninja/NinjaLo_bin.js
+3
-1
examples/obj/torus/Torus_bin.js
examples/obj/torus/Torus_bin.js
+3
-1
examples/obj/torus/Torus_slim.js
examples/obj/torus/Torus_slim.js
+10
-12
examples/obj/walt/WaltHead_bin.js
examples/obj/walt/WaltHead_bin.js
+3
-1
examples/obj/walt/WaltHead_slim.js
examples/obj/walt/WaltHead_slim.js
+10
-12
examples/webgl_objconvert_test.html
examples/webgl_objconvert_test.html
+12
-8
src/extras/geometries/Cube.js
src/extras/geometries/Cube.js
+4
-2
src/extras/geometries/Plane.js
src/extras/geometries/Plane.js
+3
-1
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+17
-7
utils/exporters/convert_obj_three.py
utils/exporters/convert_obj_three.py
+88
-96
未找到文件。
build/Three.js
浏览文件 @
2030f69a
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
build/custom/ThreeCanvas.js
浏览文件 @
2030f69a
...
...
@@ -48,17 +48,18 @@ b,c)}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==undefined?
THREE
.
Quaternion
.
prototype
=
{
set
:
function
(
a
,
b
,
c
,
d
){
this
.
x
=
a
;
this
.
y
=
b
;
this
.
z
=
c
;
this
.
w
=
d
;
return
this
},
setFromEuler
:
function
(
a
){
var
b
=
0.5
*
Math
.
PI
/
360
,
c
=
a
.
x
*
b
,
d
=
a
.
y
*
b
,
e
=
a
.
z
*
b
;
a
=
Math
.
cos
(
d
);
d
=
Math
.
sin
(
d
);
b
=
Math
.
cos
(
-
e
);
e
=
Math
.
sin
(
-
e
);
var
f
=
Math
.
cos
(
c
);
c
=
Math
.
sin
(
c
);
var
g
=
a
*
b
,
i
=
d
*
e
;
this
.
w
=
g
*
f
-
i
*
c
;
this
.
x
=
g
*
c
+
i
*
f
;
this
.
y
=
d
*
b
*
f
+
a
*
e
*
c
;
this
.
z
=
a
*
e
*
f
-
d
*
b
*
c
;
return
this
},
calculateW
:
function
(){
this
.
w
=-
Math
.
sqrt
(
Math
.
abs
(
1
-
this
.
x
*
this
.
x
-
this
.
y
*
this
.
y
-
this
.
z
*
this
.
z
));
return
this
},
inverse
:
function
(){
this
.
x
*=-
1
;
this
.
y
*=
-
1
;
this
.
z
*=-
1
;
return
this
},
length
:
function
(){
return
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
+
this
.
w
*
this
.
w
)},
normalize
:
function
(){
var
a
=
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
+
this
.
w
*
this
.
w
);
if
(
a
==
0
)
this
.
w
=
this
.
z
=
this
.
y
=
this
.
x
=
0
;
else
{
a
=
1
/
a
;
this
.
x
*=
a
;
this
.
y
*=
a
;
this
.
z
*=
a
;
this
.
w
*=
a
}
return
this
},
multiplySelf
:
function
(
a
){
var
b
=
this
.
x
,
c
=
this
.
y
,
d
=
this
.
z
,
e
=
this
.
w
,
f
=
a
.
x
,
g
=
a
.
y
,
i
=
a
.
z
;
a
=
a
.
w
;
this
.
x
=
b
*
a
+
e
*
f
+
c
*
i
-
d
*
g
;
this
.
y
=
c
*
a
+
e
*
g
+
d
*
f
-
b
*
i
;
this
.
z
=
d
*
a
+
e
*
i
+
b
*
g
-
c
*
f
;
this
.
w
=
e
*
a
-
b
*
f
-
c
*
g
-
d
*
i
;
return
this
},
multiplyVector3
:
function
(
a
,
b
){
b
||
(
b
=
a
);
var
c
=
a
.
x
,
d
=
a
.
y
,
e
=
a
.
z
,
f
=
this
.
x
,
g
=
this
.
y
,
i
=
this
.
z
,
h
=
this
.
w
,
j
=
h
*
c
+
g
*
e
-
i
*
d
,
o
=
h
*
d
+
i
*
c
-
f
*
e
,
n
=
h
*
e
+
f
*
d
-
g
*
c
;
c
=-
f
*
c
-
g
*
d
-
i
*
e
;
b
.
x
=
j
*
h
+
c
*-
f
+
o
*-
i
-
n
*-
g
;
b
.
y
=
o
*
h
+
c
*-
g
+
n
*-
f
-
j
*-
i
;
b
.
z
=
n
*
h
+
c
*-
i
+
j
*-
g
-
o
*-
f
;
return
b
}};
THREE
.
Quaternion
.
slerp
=
function
(
a
,
b
,
c
,
d
){
var
e
=
a
.
w
*
b
.
w
+
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
+
a
.
z
*
b
.
z
;
if
(
Math
.
abs
(
e
)
>=
1
){
c
.
w
=
a
.
w
;
c
.
x
=
a
.
x
;
c
.
y
=
a
.
y
;
c
.
z
=
a
.
z
;
return
c
}
var
f
=
Math
.
acos
(
e
),
g
=
Math
.
sqrt
(
1
-
e
*
e
);
if
(
Math
.
abs
(
g
)
<
0.001
){
c
.
w
=
0.5
*
(
a
.
w
+
b
.
w
);
c
.
x
=
0.5
*
(
a
.
x
+
b
.
x
);
c
.
y
=
0.5
*
(
a
.
y
+
b
.
y
);
c
.
z
=
0.5
*
(
a
.
z
+
b
.
z
);
return
c
}
e
=
Math
.
sin
((
1
-
d
)
*
f
)
/
g
;
d
=
Math
.
sin
(
d
*
f
)
/
g
;
c
.
w
=
a
.
w
*
e
+
b
.
w
*
d
;
c
.
x
=
a
.
x
*
e
+
b
.
x
*
d
;
c
.
y
=
a
.
y
*
e
+
b
.
y
*
d
;
c
.
z
=
a
.
z
*
e
+
b
.
z
*
d
;
return
c
};
THREE
.
Quaternion
.
slerp
=
function
(
a
,
b
,
c
,
d
){
var
e
=
a
.
w
*
b
.
w
+
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
+
a
.
z
*
b
.
z
;
if
(
Math
.
abs
(
e
)
>=
1
){
c
.
w
=
a
.
w
;
c
.
x
=
a
.
x
;
c
.
y
=
a
.
y
;
c
.
z
=
a
.
z
;
return
c
}
var
f
=
Math
.
acos
(
e
),
g
=
Math
.
sqrt
(
1
-
e
*
e
);
if
(
Math
.
abs
(
g
)
<
0.001
0
){
c
.
w
=
0.5
*
(
a
.
w
+
b
.
w
);
c
.
x
=
0.5
*
(
a
.
x
+
b
.
x
);
c
.
y
=
0.5
*
(
a
.
y
+
b
.
y
);
c
.
z
=
0.5
*
(
a
.
z
+
b
.
z
);
return
c
}
e
=
Math
.
sin
((
1
-
d
)
*
f
)
/
g
;
d
=
Math
.
sin
(
d
*
f
)
/
g
;
c
.
w
=
a
.
w
*
e
+
b
.
w
*
d
;
c
.
x
=
a
.
x
*
e
+
b
.
x
*
d
;
c
.
y
=
a
.
y
*
e
+
b
.
y
*
d
;
c
.
z
=
a
.
z
*
e
+
b
.
z
*
d
;
return
c
};
THREE
.
Vertex
=
function
(
a
,
b
){
this
.
position
=
a
||
new
THREE
.
Vector3
;
this
.
positionWorld
=
new
THREE
.
Vector3
;
this
.
positionScreen
=
new
THREE
.
Vector4
;
this
.
normal
=
b
||
new
THREE
.
Vector3
;
this
.
normalWorld
=
new
THREE
.
Vector3
;
this
.
normalScreen
=
new
THREE
.
Vector3
;
this
.
tangent
=
new
THREE
.
Vector4
;
this
.
__visible
=!
0
};
THREE
.
Face3
=
function
(
a
,
b
,
c
,
d
,
e
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
centroid
=
new
THREE
.
Vector3
;
this
.
normal
=
d
instanceof
THREE
.
Vector3
?
d
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
d
instanceof
Array
?
d
:[];
this
.
materials
=
e
instanceof
Array
?
e
:[
e
]};
THREE
.
Face4
=
function
(
a
,
b
,
c
,
d
,
e
,
f
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
d
=
d
;
this
.
centroid
=
new
THREE
.
Vector3
;
this
.
normal
=
e
instanceof
THREE
.
Vector3
?
e
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
e
instanceof
Array
?
e
:[];
this
.
materials
=
f
instanceof
Array
?
f
:[
f
]};
THREE
.
UV
=
function
(
a
,
b
){
this
.
set
(
a
||
0
,
b
||
0
)};
THREE
.
UV
.
prototype
=
{
set
:
function
(
a
,
b
){
this
.
u
=
a
;
this
.
v
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
set
(
a
.
u
,
a
.
v
);
return
this
}};
THREE
.
Geometry
=
function
(){
this
.
id
=
"
Geometry
"
+
THREE
.
GeometryIdCounter
++
;
this
.
vertices
=
[];
this
.
faces
=
[];
this
.
uvs
=
[];
this
.
uvs2
=
[];
this
.
colors
=
[];
this
.
morphTargets
=
[];
this
.
skinWeights
=
[];
this
.
skinIndices
=
[];
this
.
boundingSphere
=
this
.
boundingBox
=
null
;
this
.
hasTangents
=!
1
};
THREE
.
Face3
=
function
(
a
,
b
,
c
,
d
,
e
,
f
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
normal
=
d
instanceof
THREE
.
Vector3
?
d
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
d
instanceof
Array
?
d
:[];
this
.
color
=
e
instanceof
THREE
.
Color
?
e
:
new
THREE
.
Color
;
this
.
vertexColors
=
e
instanceof
Array
?
e
:[];
this
.
materials
=
f
instanceof
Array
?
f
:[
f
];
this
.
centroid
=
new
THREE
.
Vector3
};
THREE
.
Face4
=
function
(
a
,
b
,
c
,
d
,
e
,
f
,
g
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
d
=
d
;
this
.
normal
=
e
instanceof
THREE
.
Vector3
?
e
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
e
instanceof
Array
?
e
:[];
this
.
color
=
f
instanceof
THREE
.
Color
?
f
:
new
THREE
.
Color
;
this
.
vertexColors
=
f
instanceof
Array
?
f
:[];
this
.
materials
=
g
instanceof
Array
?
g
:[
g
];
this
.
centroid
=
new
THREE
.
Vector3
};
THREE
.
UV
=
function
(
a
,
b
){
this
.
set
(
a
||
0
,
b
||
0
)};
THREE
.
UV
.
prototype
=
{
set
:
function
(
a
,
b
){
this
.
u
=
a
;
this
.
v
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
set
(
a
.
u
,
a
.
v
);
return
this
}};
THREE
.
Geometry
=
function
(){
this
.
id
=
"
Geometry
"
+
THREE
.
GeometryIdCounter
++
;
this
.
vertices
=
[];
this
.
colors
=
[];
this
.
faces
=
[];
this
.
faceUvs
=
[];
this
.
faceVertexUvs
=
[];
this
.
morphTargets
=
[];
this
.
skinWeights
=
[];
this
.
skinIndices
=
[];
this
.
boundingSphere
=
this
.
boundingBox
=
null
;
this
.
hasTangents
=!
1
};
THREE
.
Geometry
.
prototype
=
{
computeCentroids
:
function
(){
var
a
,
b
,
c
;
a
=
0
;
for
(
b
=
this
.
faces
.
length
;
a
<
b
;
a
++
){
c
=
this
.
faces
[
a
];
c
.
centroid
.
set
(
0
,
0
,
0
);
if
(
c
instanceof
THREE
.
Face3
){
c
.
centroid
.
addSelf
(
this
.
vertices
[
c
.
a
].
position
);
c
.
centroid
.
addSelf
(
this
.
vertices
[
c
.
b
].
position
);
c
.
centroid
.
addSelf
(
this
.
vertices
[
c
.
c
].
position
);
c
.
centroid
.
divideScalar
(
3
)}
else
if
(
c
instanceof
THREE
.
Face4
){
c
.
centroid
.
addSelf
(
this
.
vertices
[
c
.
a
].
position
);
c
.
centroid
.
addSelf
(
this
.
vertices
[
c
.
b
].
position
);
c
.
centroid
.
addSelf
(
this
.
vertices
[
c
.
c
].
position
);
c
.
centroid
.
addSelf
(
this
.
vertices
[
c
.
d
].
position
);
c
.
centroid
.
divideScalar
(
4
)}}},
computeFaceNormals
:
function
(
a
){
var
b
,
c
,
d
,
e
,
f
,
g
,
i
=
new
THREE
.
Vector3
,
h
=
new
THREE
.
Vector3
;
d
=
0
;
for
(
e
=
this
.
vertices
.
length
;
d
<
e
;
d
++
){
f
=
this
.
vertices
[
d
];
f
.
normal
.
set
(
0
,
0
,
0
)}
d
=
0
;
for
(
e
=
this
.
faces
.
length
;
d
<
e
;
d
++
){
f
=
this
.
faces
[
d
];
if
(
a
&&
f
.
vertexNormals
.
length
){
i
.
set
(
0
,
0
,
0
);
b
=
0
;
for
(
c
=
f
.
vertexNormals
.
length
;
b
<
c
;
b
++
)
i
.
addSelf
(
f
.
vertexNormals
[
b
]);
i
.
divideScalar
(
3
)}
else
{
b
=
this
.
vertices
[
f
.
a
];
c
=
this
.
vertices
[
f
.
b
];
g
=
this
.
vertices
[
f
.
c
];
i
.
sub
(
g
.
position
,
c
.
position
);
h
.
sub
(
b
.
position
,
c
.
position
);
i
.
crossSelf
(
h
)}
i
.
isZero
()
||
i
.
normalize
();
f
.
normal
.
copy
(
i
)}},
computeVertexNormals
:
function
(){
var
a
,
b
,
c
,
d
;
if
(
this
.
__tmpVertices
==
undefined
){
d
=
this
.
__tmpVertices
=
Array
(
this
.
vertices
.
length
);
a
=
0
;
for
(
b
=
this
.
vertices
.
length
;
a
<
b
;
a
++
)
d
[
a
]
=
new
THREE
.
Vector3
;
a
=
0
;
for
(
b
=
this
.
faces
.
length
;
a
<
b
;
a
++
){
c
=
this
.
faces
[
a
];
if
(
c
instanceof
THREE
.
Face3
)
c
.
vertexNormals
=
[
new
THREE
.
Vector3
,
new
THREE
.
Vector3
,
new
THREE
.
Vector3
];
else
if
(
c
instanceof
THREE
.
Face4
)
c
.
vertexNormals
=
[
new
THREE
.
Vector3
,
new
THREE
.
Vector3
,
new
THREE
.
Vector3
,
new
THREE
.
Vector3
]}}
else
{
d
=
this
.
__tmpVertices
;
a
=
0
;
for
(
b
=
this
.
vertices
.
length
;
a
<
b
;
a
++
)
d
[
a
].
set
(
0
,
0
,
0
)}
a
=
0
;
for
(
b
=
this
.
faces
.
length
;
a
<
b
;
a
++
){
c
=
this
.
faces
[
a
];
if
(
c
instanceof
THREE
.
Face3
){
d
[
c
.
a
].
addSelf
(
c
.
normal
);
d
[
c
.
b
].
addSelf
(
c
.
normal
);
d
[
c
.
c
].
addSelf
(
c
.
normal
)}
else
if
(
c
instanceof
THREE
.
Face4
){
d
[
c
.
a
].
addSelf
(
c
.
normal
);
d
[
c
.
b
].
addSelf
(
c
.
normal
);
d
[
c
.
c
].
addSelf
(
c
.
normal
);
d
[
c
.
d
].
addSelf
(
c
.
normal
)}}
a
=
0
;
for
(
b
=
this
.
vertices
.
length
;
a
<
b
;
a
++
)
d
[
a
].
normalize
();
a
=
0
;
for
(
b
=
this
.
faces
.
length
;
a
<
b
;
a
++
){
c
=
this
.
faces
[
a
];
if
(
c
instanceof
THREE
.
Face3
){
c
.
vertexNormals
[
0
].
copy
(
d
[
c
.
a
]);
c
.
vertexNormals
[
1
].
copy
(
d
[
c
.
b
]);
c
.
vertexNormals
[
2
].
copy
(
d
[
c
.
c
])}
else
if
(
c
instanceof
THREE
.
Face4
){
c
.
vertexNormals
[
0
].
copy
(
d
[
c
.
a
]);
c
.
vertexNormals
[
1
].
copy
(
d
[
c
.
b
]);
c
.
vertexNormals
[
2
].
copy
(
d
[
c
.
c
]);
c
.
vertexNormals
[
3
].
copy
(
d
[
c
.
d
])}}},
computeTangents
:
function
(){
function
a
(
x
,
z
,
W
,
w
,
O
,
Y
,
H
){
f
=
x
.
vertices
[
z
].
position
;
g
=
x
.
vertices
[
W
].
position
;
i
=
x
.
vertices
[
w
].
position
;
h
=
e
[
O
];
j
=
e
[
Y
];
o
=
e
[
H
];
n
=
g
.
x
-
f
.
x
;
p
=
i
.
x
-
f
.
x
;
m
=
g
.
y
-
f
.
y
;
v
=
i
.
y
-
f
.
y
;
t
=
g
.
z
-
f
.
z
;
s
=
i
.
z
-
f
.
z
;
k
=
j
.
u
-
h
.
u
;
G
=
o
.
u
-
h
.
u
;
F
=
j
.
v
-
h
.
v
;
K
=
o
.
v
-
h
.
v
;
I
=
1
/
(
k
*
K
-
G
*
F
);
A
.
set
((
K
*
n
-
F
*
p
)
*
I
,(
K
*
m
-
F
*
v
)
*
I
,(
K
*
t
-
F
*
s
)
*
I
);
L
.
set
((
k
*
p
-
G
*
n
)
*
I
,(
k
*
v
-
G
*
m
)
*
I
,(
k
*
s
-
G
*
t
)
*
I
);
S
[
z
].
addSelf
(
A
);
S
[
W
].
addSelf
(
A
);
S
[
w
].
addSelf
(
A
);
C
[
z
].
addSelf
(
L
);
C
[
W
].
addSelf
(
L
);
C
[
w
].
addSelf
(
L
)}
var
b
,
c
,
d
,
e
,
f
,
g
,
i
,
h
,
j
,
o
,
n
,
p
,
m
,
v
,
t
,
s
,
k
,
G
,
F
,
K
,
I
,
S
=
[],
C
=
[],
A
=
new
THREE
.
Vector3
,
L
=
new
THREE
.
Vector3
,
y
=
new
THREE
.
Vector3
,
M
=
new
THREE
.
Vector3
,
D
=
new
THREE
.
Vector3
;
b
=
0
;
for
(
c
=
this
.
vertices
.
length
;
b
<
c
;
b
++
){
S
[
b
]
=
new
THREE
.
Vector3
;
C
[
b
]
=
new
THREE
.
Vector3
}
b
=
0
;
for
(
c
=
this
.
faces
.
length
;
b
<
c
;
b
++
){
d
=
this
.
faces
[
b
];
e
=
this
.
uvs
[
b
];
if
(
d
instanceof
THREE
.
Face3
){
a
(
this
,
d
.
a
,
d
.
b
,
d
.
c
,
0
,
1
,
2
);
this
.
vertices
[
d
.
a
].
normal
.
copy
(
d
.
vertexNormals
[
0
]);
this
.
vertices
[
d
.
b
].
normal
.
copy
(
d
.
vertexNormals
[
1
]);
this
.
vertices
[
d
.
c
].
normal
.
copy
(
d
.
vertexNormals
[
2
])}
else
if
(
d
instanceof
THREE
.
Face4
){
a
(
this
,
d
.
a
,
d
.
b
,
d
.
c
,
0
,
1
,
2
);
a
(
this
,
d
.
a
,
d
.
b
,
d
.
d
,
0
,
1
,
3
);
this
.
vertices
[
d
.
a
].
normal
.
copy
(
d
.
vertexNormals
[
0
]);
this
.
vertices
[
d
.
b
].
normal
.
copy
(
d
.
vertexNormals
[
1
]);
this
.
vertices
[
d
.
c
].
normal
.
copy
(
d
.
vertexNormals
[
2
]);
for
(
c
=
this
.
faces
.
length
;
b
<
c
;
b
++
){
d
=
this
.
faces
[
b
];
e
=
this
.
faceVertexUvs
[
b
][
0
];
if
(
d
instanceof
THREE
.
Face3
){
a
(
this
,
d
.
a
,
d
.
b
,
d
.
c
,
0
,
1
,
2
);
this
.
vertices
[
d
.
a
].
normal
.
copy
(
d
.
vertexNormals
[
0
]);
this
.
vertices
[
d
.
b
].
normal
.
copy
(
d
.
vertexNormals
[
1
]);
this
.
vertices
[
d
.
c
].
normal
.
copy
(
d
.
vertexNormals
[
2
])}
else
if
(
d
instanceof
THREE
.
Face4
){
a
(
this
,
d
.
a
,
d
.
b
,
d
.
c
,
0
,
1
,
2
);
a
(
this
,
d
.
a
,
d
.
b
,
d
.
d
,
0
,
1
,
3
);
this
.
vertices
[
d
.
a
].
normal
.
copy
(
d
.
vertexNormals
[
0
]);
this
.
vertices
[
d
.
b
].
normal
.
copy
(
d
.
vertexNormals
[
1
]);
this
.
vertices
[
d
.
c
].
normal
.
copy
(
d
.
vertexNormals
[
2
]);
this
.
vertices
[
d
.
d
].
normal
.
copy
(
d
.
vertexNormals
[
3
])}}
b
=
0
;
for
(
c
=
this
.
vertices
.
length
;
b
<
c
;
b
++
){
D
.
copy
(
this
.
vertices
[
b
].
normal
);
d
=
S
[
b
];
y
.
copy
(
d
);
y
.
subSelf
(
D
.
multiplyScalar
(
D
.
dot
(
d
))).
normalize
();
M
.
cross
(
this
.
vertices
[
b
].
normal
,
d
);
d
=
M
.
dot
(
C
[
b
]);
d
=
d
<
0
?
-
1
:
1
;
this
.
vertices
[
b
].
tangent
.
set
(
y
.
x
,
y
.
y
,
y
.
z
,
d
)}
this
.
hasTangents
=!
0
},
computeBoundingBox
:
function
(){
var
a
;
if
(
this
.
vertices
.
length
>
0
){
this
.
boundingBox
=
{
x
:[
this
.
vertices
[
0
].
position
.
x
,
this
.
vertices
[
0
].
position
.
x
],
y
:[
this
.
vertices
[
0
].
position
.
y
,
this
.
vertices
[
0
].
position
.
y
],
z
:[
this
.
vertices
[
0
].
position
.
z
,
this
.
vertices
[
0
].
position
.
z
]};
for
(
var
b
=
1
,
c
=
this
.
vertices
.
length
;
b
<
c
;
b
++
){
a
=
this
.
vertices
[
b
];
if
(
a
.
position
.
x
<
this
.
boundingBox
.
x
[
0
])
this
.
boundingBox
.
x
[
0
]
=
a
.
position
.
x
;
else
if
(
a
.
position
.
x
>
this
.
boundingBox
.
x
[
1
])
this
.
boundingBox
.
x
[
1
]
=
a
.
position
.
x
;
if
(
a
.
position
.
y
<
this
.
boundingBox
.
y
[
0
])
this
.
boundingBox
.
y
[
0
]
=
a
.
position
.
y
;
else
if
(
a
.
position
.
y
>
this
.
boundingBox
.
y
[
1
])
this
.
boundingBox
.
y
[
1
]
=
a
.
position
.
y
;
if
(
a
.
position
.
z
<
this
.
boundingBox
.
z
[
0
])
this
.
boundingBox
.
z
[
0
]
=
a
.
position
.
z
;
else
if
(
a
.
position
.
z
>
this
.
boundingBox
.
z
[
1
])
this
.
boundingBox
.
z
[
1
]
=
a
.
position
.
z
}}},
computeBoundingSphere
:
function
(){
for
(
var
a
=
this
.
boundingSphere
===
null
?
0
:
this
.
boundingSphere
.
radius
,
b
=
0
,
c
=
this
.
vertices
.
length
;
b
<
c
;
b
++
)
a
=
Math
.
max
(
a
,
this
.
vertices
[
b
].
position
.
length
());
this
.
boundingSphere
=
{
radius
:
a
}}};
THREE
.
GeometryIdCounter
=
0
;
...
...
@@ -84,7 +85,8 @@ THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.po
THREE
.
Camera
.
prototype
.
update
=
function
(
a
,
b
,
c
){
if
(
this
.
useTarget
){
this
.
matrix
.
lookAt
(
this
.
position
,
this
.
target
.
position
,
this
.
up
);
this
.
matrix
.
setPosition
(
this
.
position
);
a
?
this
.
matrixWorld
.
multiply
(
a
,
this
.
matrix
):
this
.
matrixWorld
.
copy
(
this
.
matrix
);
THREE
.
Matrix4
.
makeInvert
(
this
.
matrixWorld
,
this
.
matrixWorldInverse
);
b
=!
0
}
else
{
this
.
matrixAutoUpdate
&&
(
b
|=
this
.
updateMatrix
());
if
(
b
||
this
.
matrixWorldNeedsUpdate
){
a
?
this
.
matrixWorld
.
multiply
(
a
,
this
.
matrix
):
this
.
matrixWorld
.
copy
(
this
.
matrix
);
this
.
matrixWorldNeedsUpdate
=
!
1
;
b
=!
0
;
THREE
.
Matrix4
.
makeInvert
(
this
.
matrixWorld
,
this
.
matrixWorldInverse
)}}
for
(
a
=
0
;
a
<
this
.
children
.
length
;
a
++
)
this
.
children
[
a
].
update
(
this
.
matrixWorld
,
b
,
c
)};
THREE
.
Light
=
function
(
a
){
THREE
.
Object3D
.
call
(
this
);
this
.
color
=
new
THREE
.
Color
(
a
)};
THREE
.
Light
.
prototype
=
new
THREE
.
Object3D
;
THREE
.
Light
.
prototype
.
constructor
=
THREE
.
Light
;
THREE
.
Light
.
prototype
.
supr
=
THREE
.
Object3D
.
prototype
;
THREE
.
AmbientLight
=
function
(
a
){
THREE
.
Light
.
call
(
this
,
a
)};
THREE
.
AmbientLight
.
prototype
=
new
THREE
.
Light
;
THREE
.
AmbientLight
.
prototype
.
constructor
=
THREE
.
AmbientLight
;
THREE
.
DirectionalLight
=
function
(
a
,
b
){
THREE
.
Light
.
call
(
this
,
a
);
this
.
position
=
new
THREE
.
Vector3
(
0
,
1
,
0
);
this
.
intensity
=
b
||
1
};
THREE
.
DirectionalLight
.
prototype
=
new
THREE
.
Light
;
THREE
.
DirectionalLight
.
prototype
.
constructor
=
THREE
.
DirectionalLight
;
THREE
.
PointLight
=
function
(
a
,
b
){
THREE
.
Light
.
call
(
this
,
a
);
this
.
position
=
new
THREE
.
Vector3
;
this
.
intensity
=
b
||
1
};
THREE
.
PointLight
.
prototype
=
new
THREE
.
Light
;
THREE
.
PointLight
.
prototype
.
constructor
=
THREE
.
PointLight
;
THREE
.
FlatShading
=
0
;
THREE
.
SmoothShading
=
1
;
THREE
.
NormalBlending
=
0
;
THREE
.
AdditiveBlending
=
1
;
THREE
.
SubtractiveBlending
=
2
;
THREE
.
BillboardBlending
=
3
;
THREE
.
ReverseSubtractiveBlending
=
4
;
THREE
.
MaterialCounter
=
{
value
:
0
};
THREE
.
CubeReflectionMapping
=
function
(){};
THREE
.
CubeRefractionMapping
=
function
(){};
THREE
.
LatitudeReflectionMapping
=
function
(){};
THREE
.
LatitudeRefractionMapping
=
function
(){};
THREE
.
SphericalReflectionMapping
=
function
(){};
THREE
.
SphericalRefractionMapping
=
function
(){};
THREE
.
UVMapping
=
function
(){};
THREE
.
FlatShading
=
0
;
THREE
.
SmoothShading
=
1
;
THREE
.
MaterialColors
=
0
;
THREE
.
FaceColors
=
1
;
THREE
.
VertexColors
=
2
;
THREE
.
NormalBlending
=
0
;
THREE
.
AdditiveBlending
=
1
;
THREE
.
SubtractiveBlending
=
2
;
THREE
.
BillboardBlending
=
3
;
THREE
.
ReverseSubtractiveBlending
=
4
;
THREE
.
MaterialCounter
=
{
value
:
0
};
THREE
.
CubeReflectionMapping
=
function
(){};
THREE
.
CubeRefractionMapping
=
function
(){};
THREE
.
LatitudeReflectionMapping
=
function
(){};
THREE
.
LatitudeRefractionMapping
=
function
(){};
THREE
.
SphericalReflectionMapping
=
function
(){};
THREE
.
SphericalRefractionMapping
=
function
(){};
THREE
.
UVMapping
=
function
(){};
THREE
.
LineBasicMaterial
=
function
(
a
){
this
.
id
=
THREE
.
MaterialCounter
.
value
++
;
this
.
color
=
new
THREE
.
Color
(
16777215
);
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
depthTest
=!
0
;
this
.
linewidth
=
1
;
this
.
linejoin
=
this
.
linecap
=
"
round
"
;
this
.
vertexColors
=!
1
;
if
(
a
){
a
.
color
!==
undefined
&&
this
.
color
.
setHex
(
a
.
color
);
if
(
a
.
opacity
!==
undefined
)
this
.
opacity
=
a
.
opacity
;
if
(
a
.
blending
!==
undefined
)
this
.
blending
=
a
.
blending
;
if
(
a
.
depthTest
!==
undefined
)
this
.
depthTest
=
a
.
depthTest
;
if
(
a
.
linewidth
!==
undefined
)
this
.
linewidth
=
a
.
linewidth
;
if
(
a
.
linecap
!==
undefined
)
this
.
linecap
=
a
.
linecap
;
if
(
a
.
linejoin
!==
undefined
)
this
.
linejoin
=
a
.
linejoin
;
if
(
a
.
vertexColors
!==
undefined
)
this
.
vertexColors
=
a
.
vertexColors
}};
THREE
.
MeshBasicMaterial
=
function
(
a
){
this
.
id
=
THREE
.
MaterialCounter
.
value
++
;
this
.
color
=
new
THREE
.
Color
(
16777215
);
this
.
opacity
=
1
;
this
.
envMap
=
this
.
lightMap
=
this
.
map
=
null
;
this
.
combine
=
THREE
.
MultiplyOperation
;
this
.
reflectivity
=
1
;
this
.
refractionRatio
=
0.98
;
this
.
fog
=!
0
;
this
.
shading
=
THREE
.
SmoothShading
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
depthTest
=!
0
;
this
.
wireframe
=!
1
;
this
.
wireframeLinewidth
=
1
;
this
.
wireframeLinejoin
=
this
.
wireframeLinecap
=
"
round
"
;
this
.
vertexColors
=!
1
;
this
.
skinning
=!
1
;
this
.
morphTargets
=!
1
;
...
...
build/custom/ThreeDOM.js
浏览文件 @
2030f69a
...
...
@@ -48,10 +48,10 @@ b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?
THREE
.
Quaternion
.
prototype
=
{
set
:
function
(
a
,
b
,
c
,
e
){
this
.
x
=
a
;
this
.
y
=
b
;
this
.
z
=
c
;
this
.
w
=
e
;
return
this
},
setFromEuler
:
function
(
a
){
var
b
=
0.5
*
Math
.
PI
/
360
,
c
=
a
.
x
*
b
,
e
=
a
.
y
*
b
,
d
=
a
.
z
*
b
;
a
=
Math
.
cos
(
e
);
e
=
Math
.
sin
(
e
);
b
=
Math
.
cos
(
-
d
);
d
=
Math
.
sin
(
-
d
);
var
f
=
Math
.
cos
(
c
);
c
=
Math
.
sin
(
c
);
var
g
=
a
*
b
,
i
=
e
*
d
;
this
.
w
=
g
*
f
-
i
*
c
;
this
.
x
=
g
*
c
+
i
*
f
;
this
.
y
=
e
*
b
*
f
+
a
*
d
*
c
;
this
.
z
=
a
*
d
*
f
-
e
*
b
*
c
;
return
this
},
calculateW
:
function
(){
this
.
w
=-
Math
.
sqrt
(
Math
.
abs
(
1
-
this
.
x
*
this
.
x
-
this
.
y
*
this
.
y
-
this
.
z
*
this
.
z
));
return
this
},
inverse
:
function
(){
this
.
x
*=-
1
;
this
.
y
*=
-
1
;
this
.
z
*=-
1
;
return
this
},
length
:
function
(){
return
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
+
this
.
w
*
this
.
w
)},
normalize
:
function
(){
var
a
=
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
+
this
.
w
*
this
.
w
);
if
(
a
==
0
)
this
.
w
=
this
.
z
=
this
.
y
=
this
.
x
=
0
;
else
{
a
=
1
/
a
;
this
.
x
*=
a
;
this
.
y
*=
a
;
this
.
z
*=
a
;
this
.
w
*=
a
}
return
this
},
multiplySelf
:
function
(
a
){
var
b
=
this
.
x
,
c
=
this
.
y
,
e
=
this
.
z
,
d
=
this
.
w
,
f
=
a
.
x
,
g
=
a
.
y
,
i
=
a
.
z
;
a
=
a
.
w
;
this
.
x
=
b
*
a
+
d
*
f
+
c
*
i
-
e
*
g
;
this
.
y
=
c
*
a
+
d
*
g
+
e
*
f
-
b
*
i
;
this
.
z
=
e
*
a
+
d
*
i
+
b
*
g
-
c
*
f
;
this
.
w
=
d
*
a
-
b
*
f
-
c
*
g
-
e
*
i
;
return
this
},
multiplyVector3
:
function
(
a
,
b
){
b
||
(
b
=
a
);
var
c
=
a
.
x
,
e
=
a
.
y
,
d
=
a
.
z
,
f
=
this
.
x
,
g
=
this
.
y
,
i
=
this
.
z
,
h
=
this
.
w
,
j
=
h
*
c
+
g
*
d
-
i
*
e
,
o
=
h
*
e
+
i
*
c
-
f
*
d
,
m
=
h
*
d
+
f
*
e
-
g
*
c
;
c
=-
f
*
c
-
g
*
e
-
i
*
d
;
b
.
x
=
j
*
h
+
c
*-
f
+
o
*-
i
-
m
*-
g
;
b
.
y
=
o
*
h
+
c
*-
g
+
m
*-
f
-
j
*-
i
;
b
.
z
=
m
*
h
+
c
*-
i
+
j
*-
g
-
o
*-
f
;
return
b
}};
THREE
.
Quaternion
.
slerp
=
function
(
a
,
b
,
c
,
e
){
var
d
=
a
.
w
*
b
.
w
+
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
+
a
.
z
*
b
.
z
;
if
(
Math
.
abs
(
d
)
>=
1
){
c
.
w
=
a
.
w
;
c
.
x
=
a
.
x
;
c
.
y
=
a
.
y
;
c
.
z
=
a
.
z
;
return
c
}
var
f
=
Math
.
acos
(
d
),
g
=
Math
.
sqrt
(
1
-
d
*
d
);
if
(
Math
.
abs
(
g
)
<
0.001
){
c
.
w
=
0.5
*
(
a
.
w
+
b
.
w
);
c
.
x
=
0.5
*
(
a
.
x
+
b
.
x
);
c
.
y
=
0.5
*
(
a
.
y
+
b
.
y
);
c
.
z
=
0.5
*
(
a
.
z
+
b
.
z
);
return
c
}
d
=
Math
.
sin
((
1
-
e
)
*
f
)
/
g
;
e
=
Math
.
sin
(
e
*
f
)
/
g
;
c
.
w
=
a
.
w
*
d
+
b
.
w
*
e
;
c
.
x
=
a
.
x
*
d
+
b
.
x
*
e
;
c
.
y
=
a
.
y
*
d
+
b
.
y
*
e
;
c
.
z
=
a
.
z
*
d
+
b
.
z
*
e
;
return
c
};
THREE
.
Quaternion
.
slerp
=
function
(
a
,
b
,
c
,
e
){
var
d
=
a
.
w
*
b
.
w
+
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
+
a
.
z
*
b
.
z
;
if
(
Math
.
abs
(
d
)
>=
1
){
c
.
w
=
a
.
w
;
c
.
x
=
a
.
x
;
c
.
y
=
a
.
y
;
c
.
z
=
a
.
z
;
return
c
}
var
f
=
Math
.
acos
(
d
),
g
=
Math
.
sqrt
(
1
-
d
*
d
);
if
(
Math
.
abs
(
g
)
<
0.001
0
){
c
.
w
=
0.5
*
(
a
.
w
+
b
.
w
);
c
.
x
=
0.5
*
(
a
.
x
+
b
.
x
);
c
.
y
=
0.5
*
(
a
.
y
+
b
.
y
);
c
.
z
=
0.5
*
(
a
.
z
+
b
.
z
);
return
c
}
d
=
Math
.
sin
((
1
-
e
)
*
f
)
/
g
;
e
=
Math
.
sin
(
e
*
f
)
/
g
;
c
.
w
=
a
.
w
*
d
+
b
.
w
*
e
;
c
.
x
=
a
.
x
*
d
+
b
.
x
*
e
;
c
.
y
=
a
.
y
*
d
+
b
.
y
*
e
;
c
.
z
=
a
.
z
*
d
+
b
.
z
*
e
;
return
c
};
THREE
.
Vertex
=
function
(
a
,
b
){
this
.
position
=
a
||
new
THREE
.
Vector3
;
this
.
positionWorld
=
new
THREE
.
Vector3
;
this
.
positionScreen
=
new
THREE
.
Vector4
;
this
.
normal
=
b
||
new
THREE
.
Vector3
;
this
.
normalWorld
=
new
THREE
.
Vector3
;
this
.
normalScreen
=
new
THREE
.
Vector3
;
this
.
tangent
=
new
THREE
.
Vector4
;
this
.
__visible
=!
0
};
THREE
.
Face3
=
function
(
a
,
b
,
c
,
e
,
d
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
centroid
=
new
THREE
.
Vector3
;
this
.
normal
=
e
instanceof
THREE
.
Vector3
?
e
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
e
instanceof
Array
?
e
:[];
this
.
materials
=
d
instanceof
Array
?
d
:[
d
]};
THREE
.
Face4
=
function
(
a
,
b
,
c
,
e
,
d
,
f
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
d
=
e
;
this
.
centroid
=
new
THREE
.
Vector3
;
this
.
normal
=
d
instanceof
THREE
.
Vector3
?
d
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
d
instanceof
Array
?
d
:[];
this
.
materials
=
f
instanceof
Array
?
f
:[
f
]
};
THREE
.
UV
=
function
(
a
,
b
){
this
.
set
(
a
||
0
,
b
||
0
)};
THREE
.
UV
.
prototype
=
{
set
:
function
(
a
,
b
){
this
.
u
=
a
;
this
.
v
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
set
(
a
.
u
,
a
.
v
);
return
this
}};
THREE
.
Face3
=
function
(
a
,
b
,
c
,
e
,
d
,
f
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
normal
=
e
instanceof
THREE
.
Vector3
?
e
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
e
instanceof
Array
?
e
:[];
this
.
color
=
d
instanceof
THREE
.
Color
?
d
:
new
THREE
.
Color
;
this
.
vertexColors
=
d
instanceof
Array
?
d
:[];
this
.
materials
=
f
instanceof
Array
?
f
:[
f
];
this
.
centroid
=
new
THREE
.
Vector3
};
THREE
.
Face4
=
function
(
a
,
b
,
c
,
e
,
d
,
f
,
g
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
d
=
e
;
this
.
normal
=
d
instanceof
THREE
.
Vector3
?
d
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
d
instanceof
Array
?
d
:[];
this
.
color
=
f
instanceof
THREE
.
Color
?
f
:
new
THREE
.
Color
;
this
.
vertexColors
=
f
instanceof
Array
?
f
:[];
this
.
materials
=
g
instanceof
Array
?
g
:[
g
];
this
.
centroid
=
new
THREE
.
Vector3
};
THREE
.
UV
=
function
(
a
,
b
){
this
.
set
(
a
||
0
,
b
||
0
)};
THREE
.
UV
.
prototype
=
{
set
:
function
(
a
,
b
){
this
.
u
=
a
;
this
.
v
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
set
(
a
.
u
,
a
.
v
);
return
this
}};
THREE
.
AnimationHandler
=
function
(){
var
a
=
[],
b
=
{},
c
=
{};
c
.
update
=
function
(
d
){
for
(
var
f
=
0
;
f
<
a
.
length
;
f
++
)
a
[
f
].
update
(
d
)};
c
.
addToUpdate
=
function
(
d
){
a
.
indexOf
(
d
)
===-
1
&&
a
.
push
(
d
)};
c
.
removeFromUpdate
=
function
(
d
){
d
=
a
.
indexOf
(
d
);
d
!==-
1
&&
a
.
splice
(
d
,
1
)};
c
.
add
=
function
(
d
){
b
[
d
.
name
]
!==
undefined
&&
console
.
log
(
"
THREE.AnimationHandler.add: Warning!
"
+
d
.
name
+
"
already exists in library. Overwriting.
"
);
b
[
d
.
name
]
=
d
;
if
(
d
.
initialized
!==!
0
){
for
(
var
f
=
0
;
f
<
d
.
hierarchy
.
length
;
f
++
){
for
(
var
g
=
0
;
g
<
d
.
hierarchy
[
f
].
keys
.
length
;
g
++
){
if
(
d
.
hierarchy
[
f
].
keys
[
g
].
time
<
0
)
d
.
hierarchy
[
f
].
keys
[
g
].
time
=
0
;
if
(
d
.
hierarchy
[
f
].
keys
[
g
].
rot
!==
undefined
&&!
(
d
.
hierarchy
[
f
].
keys
[
g
].
rot
instanceof
THREE
.
Quaternion
)){
var
i
=
d
.
hierarchy
[
f
].
keys
[
g
].
rot
;
d
.
hierarchy
[
f
].
keys
[
g
].
rot
=
new
THREE
.
Quaternion
(
i
[
0
],
i
[
1
],
i
[
2
],
i
[
3
])}}
if
(
d
.
hierarchy
[
f
].
keys
[
0
].
morphTargets
!==
undefined
){
i
=
{};
for
(
g
=
0
;
g
<
d
.
hierarchy
[
f
].
keys
.
length
;
g
++
)
for
(
var
h
=
0
;
h
<
d
.
hierarchy
[
f
].
keys
[
g
].
morphTargets
.
length
;
h
++
){
var
j
=
d
.
hierarchy
[
f
].
keys
[
g
].
morphTargets
[
h
];
i
[
j
]
=-
1
}
d
.
hierarchy
[
f
].
usedMorphTargets
=
i
;
for
(
g
=
0
;
g
<
d
.
hierarchy
[
f
].
keys
.
length
;
g
++
){
var
o
=
{};
for
(
j
in
i
){
for
(
h
=
0
;
h
<
d
.
hierarchy
[
f
].
keys
[
g
].
morphTargets
.
length
;
h
++
)
if
(
d
.
hierarchy
[
f
].
keys
[
g
].
morphTargets
[
h
]
===
j
){
o
[
j
]
=
d
.
hierarchy
[
f
].
keys
[
g
].
morphTargetsInfluences
[
h
];
break
}
h
===
d
.
hierarchy
[
f
].
keys
[
g
].
morphTargets
.
length
&&
(
o
[
j
]
=
0
)}
d
.
hierarchy
[
f
].
keys
[
g
].
morphTargetsInfluences
=
o
}}
for
(
g
=
1
;
g
<
d
.
hierarchy
[
f
].
keys
.
length
;
g
++
)
if
(
d
.
hierarchy
[
f
].
keys
[
g
].
time
===
d
.
hierarchy
[
f
].
keys
[
g
-
1
].
time
){
d
.
hierarchy
[
f
].
keys
.
splice
(
g
,
1
);
g
--
}
for
(
g
=
1
;
g
<
d
.
hierarchy
[
f
].
keys
.
length
;
g
++
)
d
.
hierarchy
[
f
].
keys
[
g
].
index
=
g
}
g
=
parseInt
(
d
.
length
*
...
...
build/custom/ThreeExtras.js
浏览文件 @
2030f69a
此差异已折叠。
点击以展开。
build/custom/ThreeSVG.js
浏览文件 @
2030f69a
...
...
@@ -48,17 +48,18 @@ b,c)}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==undefined?
THREE
.
Quaternion
.
prototype
=
{
set
:
function
(
a
,
b
,
c
,
d
){
this
.
x
=
a
;
this
.
y
=
b
;
this
.
z
=
c
;
this
.
w
=
d
;
return
this
},
setFromEuler
:
function
(
a
){
var
b
=
0.5
*
Math
.
PI
/
360
,
c
=
a
.
x
*
b
,
d
=
a
.
y
*
b
,
e
=
a
.
z
*
b
;
a
=
Math
.
cos
(
d
);
d
=
Math
.
sin
(
d
);
b
=
Math
.
cos
(
-
e
);
e
=
Math
.
sin
(
-
e
);
var
f
=
Math
.
cos
(
c
);
c
=
Math
.
sin
(
c
);
var
g
=
a
*
b
,
i
=
d
*
e
;
this
.
w
=
g
*
f
-
i
*
c
;
this
.
x
=
g
*
c
+
i
*
f
;
this
.
y
=
d
*
b
*
f
+
a
*
e
*
c
;
this
.
z
=
a
*
e
*
f
-
d
*
b
*
c
;
return
this
},
calculateW
:
function
(){
this
.
w
=-
Math
.
sqrt
(
Math
.
abs
(
1
-
this
.
x
*
this
.
x
-
this
.
y
*
this
.
y
-
this
.
z
*
this
.
z
));
return
this
},
inverse
:
function
(){
this
.
x
*=-
1
;
this
.
y
*=
-
1
;
this
.
z
*=-
1
;
return
this
},
length
:
function
(){
return
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
+
this
.
w
*
this
.
w
)},
normalize
:
function
(){
var
a
=
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
+
this
.
w
*
this
.
w
);
if
(
a
==
0
)
this
.
w
=
this
.
z
=
this
.
y
=
this
.
x
=
0
;
else
{
a
=
1
/
a
;
this
.
x
*=
a
;
this
.
y
*=
a
;
this
.
z
*=
a
;
this
.
w
*=
a
}
return
this
},
multiplySelf
:
function
(
a
){
var
b
=
this
.
x
,
c
=
this
.
y
,
d
=
this
.
z
,
e
=
this
.
w
,
f
=
a
.
x
,
g
=
a
.
y
,
i
=
a
.
z
;
a
=
a
.
w
;
this
.
x
=
b
*
a
+
e
*
f
+
c
*
i
-
d
*
g
;
this
.
y
=
c
*
a
+
e
*
g
+
d
*
f
-
b
*
i
;
this
.
z
=
d
*
a
+
e
*
i
+
b
*
g
-
c
*
f
;
this
.
w
=
e
*
a
-
b
*
f
-
c
*
g
-
d
*
i
;
return
this
},
multiplyVector3
:
function
(
a
,
b
){
b
||
(
b
=
a
);
var
c
=
a
.
x
,
d
=
a
.
y
,
e
=
a
.
z
,
f
=
this
.
x
,
g
=
this
.
y
,
i
=
this
.
z
,
h
=
this
.
w
,
j
=
h
*
c
+
g
*
e
-
i
*
d
,
o
=
h
*
d
+
i
*
c
-
f
*
e
,
n
=
h
*
e
+
f
*
d
-
g
*
c
;
c
=-
f
*
c
-
g
*
d
-
i
*
e
;
b
.
x
=
j
*
h
+
c
*-
f
+
o
*-
i
-
n
*-
g
;
b
.
y
=
o
*
h
+
c
*-
g
+
n
*-
f
-
j
*-
i
;
b
.
z
=
n
*
h
+
c
*-
i
+
j
*-
g
-
o
*-
f
;
return
b
}};
THREE
.
Quaternion
.
slerp
=
function
(
a
,
b
,
c
,
d
){
var
e
=
a
.
w
*
b
.
w
+
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
+
a
.
z
*
b
.
z
;
if
(
Math
.
abs
(
e
)
>=
1
){
c
.
w
=
a
.
w
;
c
.
x
=
a
.
x
;
c
.
y
=
a
.
y
;
c
.
z
=
a
.
z
;
return
c
}
var
f
=
Math
.
acos
(
e
),
g
=
Math
.
sqrt
(
1
-
e
*
e
);
if
(
Math
.
abs
(
g
)
<
0.001
){
c
.
w
=
0.5
*
(
a
.
w
+
b
.
w
);
c
.
x
=
0.5
*
(
a
.
x
+
b
.
x
);
c
.
y
=
0.5
*
(
a
.
y
+
b
.
y
);
c
.
z
=
0.5
*
(
a
.
z
+
b
.
z
);
return
c
}
e
=
Math
.
sin
((
1
-
d
)
*
f
)
/
g
;
d
=
Math
.
sin
(
d
*
f
)
/
g
;
c
.
w
=
a
.
w
*
e
+
b
.
w
*
d
;
c
.
x
=
a
.
x
*
e
+
b
.
x
*
d
;
c
.
y
=
a
.
y
*
e
+
b
.
y
*
d
;
c
.
z
=
a
.
z
*
e
+
b
.
z
*
d
;
return
c
};
THREE
.
Quaternion
.
slerp
=
function
(
a
,
b
,
c
,
d
){
var
e
=
a
.
w
*
b
.
w
+
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
+
a
.
z
*
b
.
z
;
if
(
Math
.
abs
(
e
)
>=
1
){
c
.
w
=
a
.
w
;
c
.
x
=
a
.
x
;
c
.
y
=
a
.
y
;
c
.
z
=
a
.
z
;
return
c
}
var
f
=
Math
.
acos
(
e
),
g
=
Math
.
sqrt
(
1
-
e
*
e
);
if
(
Math
.
abs
(
g
)
<
0.001
0
){
c
.
w
=
0.5
*
(
a
.
w
+
b
.
w
);
c
.
x
=
0.5
*
(
a
.
x
+
b
.
x
);
c
.
y
=
0.5
*
(
a
.
y
+
b
.
y
);
c
.
z
=
0.5
*
(
a
.
z
+
b
.
z
);
return
c
}
e
=
Math
.
sin
((
1
-
d
)
*
f
)
/
g
;
d
=
Math
.
sin
(
d
*
f
)
/
g
;
c
.
w
=
a
.
w
*
e
+
b
.
w
*
d
;
c
.
x
=
a
.
x
*
e
+
b
.
x
*
d
;
c
.
y
=
a
.
y
*
e
+
b
.
y
*
d
;
c
.
z
=
a
.
z
*
e
+
b
.
z
*
d
;
return
c
};
THREE
.
Vertex
=
function
(
a
,
b
){
this
.
position
=
a
||
new
THREE
.
Vector3
;
this
.
positionWorld
=
new
THREE
.
Vector3
;
this
.
positionScreen
=
new
THREE
.
Vector4
;
this
.
normal
=
b
||
new
THREE
.
Vector3
;
this
.
normalWorld
=
new
THREE
.
Vector3
;
this
.
normalScreen
=
new
THREE
.
Vector3
;
this
.
tangent
=
new
THREE
.
Vector4
;
this
.
__visible
=!
0
};
THREE
.
Face3
=
function
(
a
,
b
,
c
,
d
,
e
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
centroid
=
new
THREE
.
Vector3
;
this
.
normal
=
d
instanceof
THREE
.
Vector3
?
d
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
d
instanceof
Array
?
d
:[];
this
.
materials
=
e
instanceof
Array
?
e
:[
e
]};
THREE
.
Face4
=
function
(
a
,
b
,
c
,
d
,
e
,
f
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
d
=
d
;
this
.
centroid
=
new
THREE
.
Vector3
;
this
.
normal
=
e
instanceof
THREE
.
Vector3
?
e
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
e
instanceof
Array
?
e
:[];
this
.
materials
=
f
instanceof
Array
?
f
:[
f
]};
THREE
.
UV
=
function
(
a
,
b
){
this
.
set
(
a
||
0
,
b
||
0
)};
THREE
.
UV
.
prototype
=
{
set
:
function
(
a
,
b
){
this
.
u
=
a
;
this
.
v
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
set
(
a
.
u
,
a
.
v
);
return
this
}};
THREE
.
Geometry
=
function
(){
this
.
id
=
"
Geometry
"
+
THREE
.
GeometryIdCounter
++
;
this
.
vertices
=
[];
this
.
faces
=
[];
this
.
uvs
=
[];
this
.
uvs2
=
[];
this
.
colors
=
[];
this
.
morphTargets
=
[];
this
.
skinWeights
=
[];
this
.
skinIndices
=
[];
this
.
boundingSphere
=
this
.
boundingBox
=
null
;
this
.
hasTangents
=!
1
};
THREE
.
Face3
=
function
(
a
,
b
,
c
,
d
,
e
,
f
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
normal
=
d
instanceof
THREE
.
Vector3
?
d
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
d
instanceof
Array
?
d
:[];
this
.
color
=
e
instanceof
THREE
.
Color
?
e
:
new
THREE
.
Color
;
this
.
vertexColors
=
e
instanceof
Array
?
e
:[];
this
.
materials
=
f
instanceof
Array
?
f
:[
f
];
this
.
centroid
=
new
THREE
.
Vector3
};
THREE
.
Face4
=
function
(
a
,
b
,
c
,
d
,
e
,
f
,
g
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
d
=
d
;
this
.
normal
=
e
instanceof
THREE
.
Vector3
?
e
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
e
instanceof
Array
?
e
:[];
this
.
color
=
f
instanceof
THREE
.
Color
?
f
:
new
THREE
.
Color
;
this
.
vertexColors
=
f
instanceof
Array
?
f
:[];
this
.
materials
=
g
instanceof
Array
?
g
:[
g
];
this
.
centroid
=
new
THREE
.
Vector3
};
THREE
.
UV
=
function
(
a
,
b
){
this
.
set
(
a
||
0
,
b
||
0
)};
THREE
.
UV
.
prototype
=
{
set
:
function
(
a
,
b
){
this
.
u
=
a
;
this
.
v
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
set
(
a
.
u
,
a
.
v
);
return
this
}};
THREE
.
Geometry
=
function
(){
this
.
id
=
"
Geometry
"
+
THREE
.
GeometryIdCounter
++
;
this
.
vertices
=
[];
this
.
colors
=
[];
this
.
faces
=
[];
this
.
faceUvs
=
[];
this
.
faceVertexUvs
=
[];
this
.
morphTargets
=
[];
this
.
skinWeights
=
[];
this
.
skinIndices
=
[];
this
.
boundingSphere
=
this
.
boundingBox
=
null
;
this
.
hasTangents
=!
1
};
THREE
.
Geometry
.
prototype
=
{
computeCentroids
:
function
(){
var
a
,
b
,
c
;
a
=
0
;
for
(
b
=
this
.
faces
.
length
;
a
<
b
;
a
++
){
c
=
this
.
faces
[
a
];
c
.
centroid
.
set
(
0
,
0
,
0
);
if
(
c
instanceof
THREE
.
Face3
){
c
.
centroid
.
addSelf
(
this
.
vertices
[
c
.
a
].
position
);
c
.
centroid
.
addSelf
(
this
.
vertices
[
c
.
b
].
position
);
c
.
centroid
.
addSelf
(
this
.
vertices
[
c
.
c
].
position
);
c
.
centroid
.
divideScalar
(
3
)}
else
if
(
c
instanceof
THREE
.
Face4
){
c
.
centroid
.
addSelf
(
this
.
vertices
[
c
.
a
].
position
);
c
.
centroid
.
addSelf
(
this
.
vertices
[
c
.
b
].
position
);
c
.
centroid
.
addSelf
(
this
.
vertices
[
c
.
c
].
position
);
c
.
centroid
.
addSelf
(
this
.
vertices
[
c
.
d
].
position
);
c
.
centroid
.
divideScalar
(
4
)}}},
computeFaceNormals
:
function
(
a
){
var
b
,
c
,
d
,
e
,
f
,
g
,
i
=
new
THREE
.
Vector3
,
h
=
new
THREE
.
Vector3
;
d
=
0
;
for
(
e
=
this
.
vertices
.
length
;
d
<
e
;
d
++
){
f
=
this
.
vertices
[
d
];
f
.
normal
.
set
(
0
,
0
,
0
)}
d
=
0
;
for
(
e
=
this
.
faces
.
length
;
d
<
e
;
d
++
){
f
=
this
.
faces
[
d
];
if
(
a
&&
f
.
vertexNormals
.
length
){
i
.
set
(
0
,
0
,
0
);
b
=
0
;
for
(
c
=
f
.
vertexNormals
.
length
;
b
<
c
;
b
++
)
i
.
addSelf
(
f
.
vertexNormals
[
b
]);
i
.
divideScalar
(
3
)}
else
{
b
=
this
.
vertices
[
f
.
a
];
c
=
this
.
vertices
[
f
.
b
];
g
=
this
.
vertices
[
f
.
c
];
i
.
sub
(
g
.
position
,
c
.
position
);
h
.
sub
(
b
.
position
,
c
.
position
);
i
.
crossSelf
(
h
)}
i
.
isZero
()
||
i
.
normalize
();
f
.
normal
.
copy
(
i
)}},
computeVertexNormals
:
function
(){
var
a
,
b
,
c
,
d
;
if
(
this
.
__tmpVertices
==
undefined
){
d
=
this
.
__tmpVertices
=
Array
(
this
.
vertices
.
length
);
a
=
0
;
for
(
b
=
this
.
vertices
.
length
;
a
<
b
;
a
++
)
d
[
a
]
=
new
THREE
.
Vector3
;
a
=
0
;
for
(
b
=
this
.
faces
.
length
;
a
<
b
;
a
++
){
c
=
this
.
faces
[
a
];
if
(
c
instanceof
THREE
.
Face3
)
c
.
vertexNormals
=
[
new
THREE
.
Vector3
,
new
THREE
.
Vector3
,
new
THREE
.
Vector3
];
else
if
(
c
instanceof
THREE
.
Face4
)
c
.
vertexNormals
=
[
new
THREE
.
Vector3
,
new
THREE
.
Vector3
,
new
THREE
.
Vector3
,
new
THREE
.
Vector3
]}}
else
{
d
=
this
.
__tmpVertices
;
a
=
0
;
for
(
b
=
this
.
vertices
.
length
;
a
<
b
;
a
++
)
d
[
a
].
set
(
0
,
0
,
0
)}
a
=
0
;
for
(
b
=
this
.
faces
.
length
;
a
<
b
;
a
++
){
c
=
this
.
faces
[
a
];
if
(
c
instanceof
THREE
.
Face3
){
d
[
c
.
a
].
addSelf
(
c
.
normal
);
d
[
c
.
b
].
addSelf
(
c
.
normal
);
d
[
c
.
c
].
addSelf
(
c
.
normal
)}
else
if
(
c
instanceof
THREE
.
Face4
){
d
[
c
.
a
].
addSelf
(
c
.
normal
);
d
[
c
.
b
].
addSelf
(
c
.
normal
);
d
[
c
.
c
].
addSelf
(
c
.
normal
);
d
[
c
.
d
].
addSelf
(
c
.
normal
)}}
a
=
0
;
for
(
b
=
this
.
vertices
.
length
;
a
<
b
;
a
++
)
d
[
a
].
normalize
();
a
=
0
;
for
(
b
=
this
.
faces
.
length
;
a
<
b
;
a
++
){
c
=
this
.
faces
[
a
];
if
(
c
instanceof
THREE
.
Face3
){
c
.
vertexNormals
[
0
].
copy
(
d
[
c
.
a
]);
c
.
vertexNormals
[
1
].
copy
(
d
[
c
.
b
]);
c
.
vertexNormals
[
2
].
copy
(
d
[
c
.
c
])}
else
if
(
c
instanceof
THREE
.
Face4
){
c
.
vertexNormals
[
0
].
copy
(
d
[
c
.
a
]);
c
.
vertexNormals
[
1
].
copy
(
d
[
c
.
b
]);
c
.
vertexNormals
[
2
].
copy
(
d
[
c
.
c
]);
c
.
vertexNormals
[
3
].
copy
(
d
[
c
.
d
])}}},
computeTangents
:
function
(){
function
a
(
t
,
C
,
S
,
y
,
K
,
D
,
w
){
f
=
t
.
vertices
[
C
].
position
;
g
=
t
.
vertices
[
S
].
position
;
i
=
t
.
vertices
[
y
].
position
;
h
=
e
[
K
];
j
=
e
[
D
];
o
=
e
[
w
];
n
=
g
.
x
-
f
.
x
;
m
=
i
.
x
-
f
.
x
;
k
=
g
.
y
-
f
.
y
;
q
=
i
.
y
-
f
.
y
;
s
=
g
.
z
-
f
.
z
;
v
=
i
.
z
-
f
.
z
;
l
=
j
.
u
-
h
.
u
;
J
=
o
.
u
-
h
.
u
;
r
=
j
.
v
-
h
.
v
;
A
=
o
.
v
-
h
.
v
;
F
=
1
/
(
l
*
A
-
J
*
r
);
z
.
set
((
A
*
n
-
r
*
m
)
*
F
,(
A
*
k
-
r
*
q
)
*
F
,(
A
*
s
-
r
*
v
)
*
F
);
L
.
set
((
l
*
m
-
J
*
n
)
*
F
,(
l
*
q
-
J
*
k
)
*
F
,(
l
*
v
-
J
*
s
)
*
F
);
R
[
C
].
addSelf
(
z
);
R
[
S
].
addSelf
(
z
);
R
[
y
].
addSelf
(
z
);
B
[
C
].
addSelf
(
L
);
B
[
S
].
addSelf
(
L
);
B
[
y
].
addSelf
(
L
)}
var
b
,
c
,
d
,
e
,
f
,
g
,
i
,
h
,
j
,
o
,
n
,
m
,
k
,
q
,
s
,
v
,
l
,
J
,
r
,
A
,
F
,
R
=
[],
B
=
[],
z
=
new
THREE
.
Vector3
,
L
=
new
THREE
.
Vector3
,
G
=
new
THREE
.
Vector3
,
N
=
new
THREE
.
Vector3
,
H
=
new
THREE
.
Vector3
;
b
=
0
;
for
(
c
=
this
.
vertices
.
length
;
b
<
c
;
b
++
){
R
[
b
]
=
new
THREE
.
Vector3
;
B
[
b
]
=
new
THREE
.
Vector3
}
b
=
0
;
for
(
c
=
this
.
faces
.
length
;
b
<
c
;
b
++
){
d
=
this
.
faces
[
b
];
e
=
this
.
uvs
[
b
];
if
(
d
instanceof
THREE
.
Face3
){
a
(
this
,
d
.
a
,
d
.
b
,
d
.
c
,
0
,
1
,
2
);
this
.
vertices
[
d
.
a
].
normal
.
copy
(
d
.
vertexNormals
[
0
]);
this
.
vertices
[
d
.
b
].
normal
.
copy
(
d
.
vertexNormals
[
1
]);
this
.
vertices
[
d
.
c
].
normal
.
copy
(
d
.
vertexNormals
[
2
])}
else
if
(
d
instanceof
THREE
.
Face4
){
a
(
this
,
d
.
a
,
d
.
b
,
d
.
c
,
0
,
1
,
2
);
a
(
this
,
d
.
a
,
d
.
b
,
d
.
d
,
0
,
1
,
3
);
this
.
vertices
[
d
.
a
].
normal
.
copy
(
d
.
vertexNormals
[
0
]);
this
.
vertices
[
d
.
b
].
normal
.
copy
(
d
.
vertexNormals
[
1
]);
this
.
vertices
[
d
.
c
].
normal
.
copy
(
d
.
vertexNormals
[
2
]);
for
(
c
=
this
.
faces
.
length
;
b
<
c
;
b
++
){
d
=
this
.
faces
[
b
];
e
=
this
.
faceVertexUvs
[
b
][
0
];
if
(
d
instanceof
THREE
.
Face3
){
a
(
this
,
d
.
a
,
d
.
b
,
d
.
c
,
0
,
1
,
2
);
this
.
vertices
[
d
.
a
].
normal
.
copy
(
d
.
vertexNormals
[
0
]);
this
.
vertices
[
d
.
b
].
normal
.
copy
(
d
.
vertexNormals
[
1
]);
this
.
vertices
[
d
.
c
].
normal
.
copy
(
d
.
vertexNormals
[
2
])}
else
if
(
d
instanceof
THREE
.
Face4
){
a
(
this
,
d
.
a
,
d
.
b
,
d
.
c
,
0
,
1
,
2
);
a
(
this
,
d
.
a
,
d
.
b
,
d
.
d
,
0
,
1
,
3
);
this
.
vertices
[
d
.
a
].
normal
.
copy
(
d
.
vertexNormals
[
0
]);
this
.
vertices
[
d
.
b
].
normal
.
copy
(
d
.
vertexNormals
[
1
]);
this
.
vertices
[
d
.
c
].
normal
.
copy
(
d
.
vertexNormals
[
2
]);
this
.
vertices
[
d
.
d
].
normal
.
copy
(
d
.
vertexNormals
[
3
])}}
b
=
0
;
for
(
c
=
this
.
vertices
.
length
;
b
<
c
;
b
++
){
H
.
copy
(
this
.
vertices
[
b
].
normal
);
d
=
R
[
b
];
G
.
copy
(
d
);
G
.
subSelf
(
H
.
multiplyScalar
(
H
.
dot
(
d
))).
normalize
();
N
.
cross
(
this
.
vertices
[
b
].
normal
,
d
);
d
=
N
.
dot
(
B
[
b
]);
d
=
d
<
0
?
-
1
:
1
;
this
.
vertices
[
b
].
tangent
.
set
(
G
.
x
,
G
.
y
,
G
.
z
,
d
)}
this
.
hasTangents
=!
0
},
computeBoundingBox
:
function
(){
var
a
;
if
(
this
.
vertices
.
length
>
0
){
this
.
boundingBox
=
{
x
:[
this
.
vertices
[
0
].
position
.
x
,
this
.
vertices
[
0
].
position
.
x
],
y
:[
this
.
vertices
[
0
].
position
.
y
,
this
.
vertices
[
0
].
position
.
y
],
z
:[
this
.
vertices
[
0
].
position
.
z
,
this
.
vertices
[
0
].
position
.
z
]};
for
(
var
b
=
1
,
c
=
this
.
vertices
.
length
;
b
<
c
;
b
++
){
a
=
this
.
vertices
[
b
];
if
(
a
.
position
.
x
<
this
.
boundingBox
.
x
[
0
])
this
.
boundingBox
.
x
[
0
]
=
a
.
position
.
x
;
else
if
(
a
.
position
.
x
>
this
.
boundingBox
.
x
[
1
])
this
.
boundingBox
.
x
[
1
]
=
a
.
position
.
x
;
if
(
a
.
position
.
y
<
this
.
boundingBox
.
y
[
0
])
this
.
boundingBox
.
y
[
0
]
=
a
.
position
.
y
;
else
if
(
a
.
position
.
y
>
this
.
boundingBox
.
y
[
1
])
this
.
boundingBox
.
y
[
1
]
=
a
.
position
.
y
;
if
(
a
.
position
.
z
<
this
.
boundingBox
.
z
[
0
])
this
.
boundingBox
.
z
[
0
]
=
a
.
position
.
z
;
else
if
(
a
.
position
.
z
>
this
.
boundingBox
.
z
[
1
])
this
.
boundingBox
.
z
[
1
]
=
a
.
position
.
z
}}},
computeBoundingSphere
:
function
(){
for
(
var
a
=
this
.
boundingSphere
===
null
?
0
:
this
.
boundingSphere
.
radius
,
b
=
0
,
c
=
this
.
vertices
.
length
;
b
<
c
;
b
++
)
a
=
Math
.
max
(
a
,
this
.
vertices
[
b
].
position
.
length
());
this
.
boundingSphere
=
{
radius
:
a
}}};
THREE
.
GeometryIdCounter
=
0
;
...
...
@@ -84,7 +85,7 @@ THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.po
THREE
.
Camera
.
prototype
.
update
=
function
(
a
,
b
,
c
){
if
(
this
.
useTarget
){
this
.
matrix
.
lookAt
(
this
.
position
,
this
.
target
.
position
,
this
.
up
);
this
.
matrix
.
setPosition
(
this
.
position
);
a
?
this
.
matrixWorld
.
multiply
(
a
,
this
.
matrix
):
this
.
matrixWorld
.
copy
(
this
.
matrix
);
THREE
.
Matrix4
.
makeInvert
(
this
.
matrixWorld
,
this
.
matrixWorldInverse
);
b
=!
0
}
else
{
this
.
matrixAutoUpdate
&&
(
b
|=
this
.
updateMatrix
());
if
(
b
||
this
.
matrixWorldNeedsUpdate
){
a
?
this
.
matrixWorld
.
multiply
(
a
,
this
.
matrix
):
this
.
matrixWorld
.
copy
(
this
.
matrix
);
this
.
matrixWorldNeedsUpdate
=
!
1
;
b
=!
0
;
THREE
.
Matrix4
.
makeInvert
(
this
.
matrixWorld
,
this
.
matrixWorldInverse
)}}
for
(
a
=
0
;
a
<
this
.
children
.
length
;
a
++
)
this
.
children
[
a
].
update
(
this
.
matrixWorld
,
b
,
c
)};
THREE
.
Light
=
function
(
a
){
THREE
.
Object3D
.
call
(
this
);
this
.
color
=
new
THREE
.
Color
(
a
)};
THREE
.
Light
.
prototype
=
new
THREE
.
Object3D
;
THREE
.
Light
.
prototype
.
constructor
=
THREE
.
Light
;
THREE
.
Light
.
prototype
.
supr
=
THREE
.
Object3D
.
prototype
;
THREE
.
AmbientLight
=
function
(
a
){
THREE
.
Light
.
call
(
this
,
a
)};
THREE
.
AmbientLight
.
prototype
=
new
THREE
.
Light
;
THREE
.
AmbientLight
.
prototype
.
constructor
=
THREE
.
AmbientLight
;
THREE
.
DirectionalLight
=
function
(
a
,
b
){
THREE
.
Light
.
call
(
this
,
a
);
this
.
position
=
new
THREE
.
Vector3
(
0
,
1
,
0
);
this
.
intensity
=
b
||
1
};
THREE
.
DirectionalLight
.
prototype
=
new
THREE
.
Light
;
THREE
.
DirectionalLight
.
prototype
.
constructor
=
THREE
.
DirectionalLight
;
THREE
.
PointLight
=
function
(
a
,
b
){
THREE
.
Light
.
call
(
this
,
a
);
this
.
position
=
new
THREE
.
Vector3
;
this
.
intensity
=
b
||
1
};
THREE
.
PointLight
.
prototype
=
new
THREE
.
Light
;
THREE
.
PointLight
.
prototype
.
constructor
=
THREE
.
PointLight
;
THREE
.
FlatShading
=
0
;
THREE
.
SmoothShading
=
1
;
THREE
.
NormalBlending
=
0
;
THREE
.
AdditiveBlending
=
1
;
THREE
.
SubtractiveBlending
=
2
;
THREE
.
BillboardBlending
=
3
;
THREE
.
ReverseSubtractiveBlending
=
4
;
THREE
.
MaterialCounter
=
{
value
:
0
};
THREE
.
FlatShading
=
0
;
THREE
.
SmoothShading
=
1
;
THREE
.
MaterialColors
=
0
;
THREE
.
FaceColors
=
1
;
THREE
.
VertexColors
=
2
;
THREE
.
NormalBlending
=
0
;
THREE
.
AdditiveBlending
=
1
;
THREE
.
SubtractiveBlending
=
2
;
THREE
.
BillboardBlending
=
3
;
THREE
.
ReverseSubtractiveBlending
=
4
;
THREE
.
MaterialCounter
=
{
value
:
0
};
THREE
.
LineBasicMaterial
=
function
(
a
){
this
.
id
=
THREE
.
MaterialCounter
.
value
++
;
this
.
color
=
new
THREE
.
Color
(
16777215
);
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
depthTest
=!
0
;
this
.
linewidth
=
1
;
this
.
linejoin
=
this
.
linecap
=
"
round
"
;
this
.
vertexColors
=!
1
;
if
(
a
){
a
.
color
!==
undefined
&&
this
.
color
.
setHex
(
a
.
color
);
if
(
a
.
opacity
!==
undefined
)
this
.
opacity
=
a
.
opacity
;
if
(
a
.
blending
!==
undefined
)
this
.
blending
=
a
.
blending
;
if
(
a
.
depthTest
!==
undefined
)
this
.
depthTest
=
a
.
depthTest
;
if
(
a
.
linewidth
!==
undefined
)
this
.
linewidth
=
a
.
linewidth
;
if
(
a
.
linecap
!==
undefined
)
this
.
linecap
=
a
.
linecap
;
if
(
a
.
linejoin
!==
undefined
)
this
.
linejoin
=
a
.
linejoin
;
if
(
a
.
vertexColors
!==
undefined
)
this
.
vertexColors
=
a
.
vertexColors
}};
THREE
.
MeshBasicMaterial
=
function
(
a
){
this
.
id
=
THREE
.
MaterialCounter
.
value
++
;
this
.
color
=
new
THREE
.
Color
(
16777215
);
this
.
opacity
=
1
;
this
.
envMap
=
this
.
lightMap
=
this
.
map
=
null
;
this
.
combine
=
THREE
.
MultiplyOperation
;
this
.
reflectivity
=
1
;
this
.
refractionRatio
=
0.98
;
this
.
fog
=!
0
;
this
.
shading
=
THREE
.
SmoothShading
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
depthTest
=!
0
;
this
.
wireframe
=!
1
;
this
.
wireframeLinewidth
=
1
;
this
.
wireframeLinejoin
=
this
.
wireframeLinecap
=
"
round
"
;
this
.
vertexColors
=!
1
;
this
.
skinning
=!
1
;
this
.
morphTargets
=!
1
;
...
...
build/custom/ThreeWebGL.js
浏览文件 @
2030f69a
此差异已折叠。
点击以展开。
examples/obj/female02/Female02_bin.js
浏览文件 @
2030f69a
...
...
@@ -4,10 +4,12 @@
// materials: 6
//
// Generated with OBJ -> Three.js converter
// http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three
js_slim
.py
// http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three.py
var
model
=
{
'
version
'
:
1
,
'
materials
'
:
[
{
"
DbgColor
"
:
0xeeeeee
,
"
DbgIndex
"
:
0
,
...
...
examples/obj/female02/Female02_slim.js
浏览文件 @
2030f69a
此差异已折叠。
点击以展开。
examples/obj/lucy/Lucy100k_bin.js
浏览文件 @
2030f69a
...
...
@@ -4,10 +4,12 @@
// materials: 0
//
// Generated with OBJ -> Three.js converter
// http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three
js_slim
.py
// http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three.py
var
model
=
{
'
version
'
:
1
,
'
materials
'
:
[
{
"
DbgColor
"
:
0xeeeeee
,
"
DbgIndex
"
:
0
,
...
...
examples/obj/lucy/Lucy100k_slim.js
浏览文件 @
2030f69a
此差异已折叠。
点击以展开。
examples/obj/male02/Male02_bin.js
浏览文件 @
2030f69a
...
...
@@ -4,10 +4,12 @@
// materials: 5
//
// Generated with OBJ -> Three.js converter
// http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three
js_slim
.py
// http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three.py
var
model
=
{
'
version
'
:
1
,
'
materials
'
:
[
{
"
DbgColor
"
:
0xeeeeee
,
"
DbgIndex
"
:
0
,
...
...
examples/obj/male02/Male02_slim.js
浏览文件 @
2030f69a
此差异已折叠。
点击以展开。
examples/obj/ninja/NinjaLo_bin.js
浏览文件 @
2030f69a
...
...
@@ -4,10 +4,12 @@
// materials: 0
//
// Generated with OBJ -> Three.js converter
// http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three
js_slim
.py
// http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three.py
var
model
=
{
'
version
'
:
1
,
'
materials
'
:
[
{
"
DbgColor
"
:
0xeeeeee
,
"
DbgIndex
"
:
0
,
...
...
examples/obj/torus/Torus_bin.js
浏览文件 @
2030f69a
...
...
@@ -4,10 +4,12 @@
// materials: 1
//
// Generated with OBJ -> Three.js converter
// http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three
js_slim
.py
// http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three.py
var
model
=
{
'
version
'
:
1
,
'
materials
'
:
[
{
"
DbgColor
"
:
0xeeeeee
,
"
DbgIndex
"
:
0
,
...
...
examples/obj/torus/Torus_slim.js
浏览文件 @
2030f69a
此差异已折叠。
点击以展开。
examples/obj/walt/WaltHead_bin.js
浏览文件 @
2030f69a
...
...
@@ -4,10 +4,12 @@
// materials: 1
//
// Generated with OBJ -> Three.js converter
// http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three
js_slim
.py
// http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three.py
var
model
=
{
'
version
'
:
1
,
'
materials
'
:
[
{
"
DbgColor
"
:
0xeeeeee
,
"
DbgIndex
"
:
0
,
...
...
examples/obj/walt/WaltHead_slim.js
浏览文件 @
2030f69a
此差异已折叠。
点击以展开。
examples/webgl_objconvert_test.html
浏览文件 @
2030f69a
...
...
@@ -112,11 +112,15 @@
xm
.
map
.
needsUpdate
=
true
;
geometry
=
new
Plane
(
100
,
100
,
15
,
10
);
for
(
var
i
=
0
;
i
<
geometry
.
uvs
.
length
;
i
++
)
{
var
uvs
=
geometry
.
uvs
[
i
];
for
(
var
i
=
0
;
i
<
geometry
.
faceVertexUvs
[
0
].
length
;
i
++
)
{
var
uvs
=
geometry
.
faceVertexUvs
[
0
][
i
];
for
(
j
=
0
,
jl
=
uvs
.
length
;
j
<
jl
;
j
++
)
{
uvs
[
j
].
u
*=
10
;
uvs
[
j
].
v
*=
10
;
uvs
[
j
].
u
*=
10
;
uvs
[
j
].
v
*=
10
;
}
}
...
...
@@ -192,11 +196,11 @@
callbackMale
=
function
(
geometry
)
{
createScene
(
geometry
,
90
,
50
,
FLOOR
,
105
)
},
callbackFemale
=
function
(
geometry
)
{
createScene
(
geometry
,
-
80
,
50
,
FLOOR
,
0
)
};
//
loader.loadAscii( { model: "obj/male02/Male02_slim.js", callback: callbackMale } );
//
loader.loadAscii( { model: "obj/female02/Female02_slim.js", callback: callbackFemale } );
loader
.
loadAscii
(
{
model
:
"
obj/male02/Male02_slim.js
"
,
callback
:
callbackMale
}
);
loader
.
loadAscii
(
{
model
:
"
obj/female02/Female02_slim.js
"
,
callback
:
callbackFemale
}
);
loader
.
loadBinary
(
{
model
:
"
obj/male02/Male02_bin.js
"
,
callback
:
callbackMale
}
);
loader
.
loadBinary
(
{
model
:
"
obj/female02/Female02_bin.js
"
,
callback
:
callbackFemale
}
);
//
loader.loadBinary( { model: "obj/male02/Male02_bin.js", callback: callbackMale } );
//
loader.loadBinary( { model: "obj/female02/Female02_bin.js", callback: callbackFemale } );
}
...
...
src/extras/geometries/Cube.js
浏览文件 @
2030f69a
...
...
@@ -107,6 +107,8 @@ var Cube = function ( width, height, depth, segmentsWidth, segmentsHeight, segme
}
scope
.
faceVertexUvs
[
0
]
=
[];
for
(
iy
=
0
;
iy
<
gridY
;
iy
++
)
{
for
(
ix
=
0
;
ix
<
gridX
;
ix
++
)
{
...
...
@@ -116,8 +118,8 @@ var Cube = function ( width, height, depth, segmentsWidth, segmentsHeight, segme
var
c
=
(
ix
+
1
)
+
gridX1
*
(
iy
+
1
);
var
d
=
(
ix
+
1
)
+
gridX1
*
iy
;
scope
.
faces
.
push
(
new
THREE
.
Face4
(
a
+
offset
,
b
+
offset
,
c
+
offset
,
d
+
offset
,
null
,
material
)
);
scope
.
uvs
.
push
(
[
scope
.
faces
.
push
(
new
THREE
.
Face4
(
a
+
offset
,
b
+
offset
,
c
+
offset
,
d
+
offset
,
null
,
null
,
material
)
);
scope
.
faceVertexUvs
[
0
]
.
push
(
[
new
THREE
.
UV
(
ix
/
gridX
,
iy
/
gridY
),
new
THREE
.
UV
(
ix
/
gridX
,
(
iy
+
1
)
/
gridY
),
new
THREE
.
UV
(
(
ix
+
1
)
/
gridX
,
(
iy
+
1
)
/
gridY
),
...
...
src/extras/geometries/Plane.js
浏览文件 @
2030f69a
...
...
@@ -31,6 +31,8 @@ var Plane = function ( width, height, segmentsWidth, segmentsHeight ) {
}
this
.
faceVertexUvs
[
0
]
=
[];
for
(
iy
=
0
;
iy
<
gridY
;
iy
++
)
{
for
(
ix
=
0
;
ix
<
gridX
;
ix
++
)
{
...
...
@@ -41,7 +43,7 @@ var Plane = function ( width, height, segmentsWidth, segmentsHeight ) {
var
d
=
(
ix
+
1
)
+
gridX1
*
iy
;
this
.
faces
.
push
(
new
THREE
.
Face4
(
a
,
b
,
c
,
d
)
);
this
.
uvs
.
push
(
[
this
.
faceVertexUvs
[
0
]
.
push
(
[
new
THREE
.
UV
(
ix
/
gridX
,
iy
/
gridY
),
new
THREE
.
UV
(
ix
/
gridX
,
(
iy
+
1
)
/
gridY
),
new
THREE
.
UV
(
(
ix
+
1
)
/
gridX
,
(
iy
+
1
)
/
gridY
),
...
...
src/renderers/WebGLRenderer.js
浏览文件 @
2030f69a
...
...
@@ -512,8 +512,18 @@ THREE.WebGLRenderer = function ( parameters ) {
fi
=
chunk_faces
[
f
];
face
=
obj_faces
[
fi
];
uv
=
obj_uvs
[
fi
];
uv2
=
obj_uvs2
[
fi
];
if
(
obj_uvs
)
{
uv
=
obj_uvs
[
fi
];
}
if
(
obj_uvs2
)
{
uv2
=
obj_uvs2
[
fi
];
}
vertexNormals
=
face
.
vertexNormals
;
faceNormal
=
face
.
normal
;
...
...
@@ -751,7 +761,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
if
(
dirtyUvs
&&
uv
)
{
if
(
dirtyUvs
&&
uv
!==
undefined
)
{
for
(
i
=
0
;
i
<
3
;
i
++
)
{
...
...
@@ -766,7 +776,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
if
(
dirtyUvs
&&
uv2
)
{
if
(
dirtyUvs
&&
uv2
!==
undefined
)
{
for
(
i
=
0
;
i
<
3
;
i
++
)
{
...
...
@@ -1081,7 +1091,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
if
(
dirtyUvs
&&
uv
)
{
if
(
dirtyUvs
&&
uv
!==
undefined
)
{
for
(
i
=
0
;
i
<
4
;
i
++
)
{
...
...
@@ -1096,7 +1106,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
if
(
dirtyUvs
&&
uv2
)
{
if
(
dirtyUvs
&&
uv2
!==
undefined
)
{
for
(
i
=
0
;
i
<
4
;
i
++
)
{
...
...
@@ -3503,7 +3513,7 @@ THREE.WebGLRenderer = function ( parameters ) {
m
=
materials
[
i
];
if
(
m
instanceof
THREE
.
MeshBasicMaterial
||
m
instanceof
MeshDepthMaterial
)
continue
;
if
(
m
instanceof
THREE
.
MeshBasicMaterial
||
m
instanceof
THREE
.
MeshDepthMaterial
)
continue
;
if
(
materialNeedsSmoothNormals
(
m
)
)
{
...
...
utils/exporters/convert_obj_three
js_slim
.py
→
utils/exporters/convert_obj_three.py
浏览文件 @
2030f69a
"""Convert Wavefront OBJ / MTL files into Three.js (
slim models
version, to be used with web worker based ascii / binary loader)
"""Convert Wavefront OBJ / MTL files into Three.js (
JSON model
version, to be used with web worker based ascii / binary loader)
-------------------------
How to use this converter
-------------------------
python convert_obj_three
js_slim
.py -i infile.obj -o outfile.js [-m morphfiles*.obj] [-a center|top|bottom] [-s smooth|flat] [-t ascii|binary] [-d invert|normal]
python convert_obj_three.py -i infile.obj -o outfile.js [-m morphfiles*.obj] [-a center|top|bottom] [-s smooth|flat] [-t ascii|binary] [-d invert|normal]
Notes:
...
...
@@ -32,7 +32,7 @@ How to use generated JS file in your HTML document
var loader = new THREE.Loader();
// load ascii model
loader.loadAscii( "Model_
slim
.js", function( geometry ) { createScene( geometry) }, path_to_textures );
loader.loadAscii( "Model_
ascii
.js", function( geometry ) { createScene( geometry) }, path_to_textures );
// load binary model
loader.loadBinary( "Model_bin.js", function( geometry ) { createScene( geometry) }, path_to_textures );
...
...
@@ -147,32 +147,28 @@ TEMPLATE_FILE_ASCII = u"""\
// Converted from: %(fname)s
// vertices: %(nvertex)d
// faces: %(nface)d
// normals: %(nnormal)d
// uvs: %(nuv)d
// materials: %(nmaterial)d
//
// Generated with OBJ -> Three.js converter
// http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three
js_slim
.py
// http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three.py
var model = {
'version' : 2,
'materials': [%(materials)s],
'normals': [%(normals)s],
'vertices': [%(vertices)s],
'morphTargets': [%(morphTargets)s],
'uvs': [%(uvs)s],
'triangles': [%(triangles)s],
'trianglesUvs': [%(trianglesUvs)s],
'trianglesNormals': [%(trianglesNormals)s],
'trianglesNormalsUvs': [%(trianglesNormalsUvs)s],
'normals': [%(normals)s],
'uvs': [%(uvs)s],
'quads': [%(quads)s],
'quadsUvs': [%(quadsUvs)s],
'quadsNormals': [%(quadsNormals)s],
'quadsNormalsUvs': [%(quadsNormalsUvs)s],
'faces': [%(faces)s],
'end': (new Date).getTime()
}
...
...
@@ -187,10 +183,12 @@ TEMPLATE_FILE_BIN = u"""\
// materials: %(nmaterial)d
//
// Generated with OBJ -> Three.js converter
// http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three
js_slim
.py
// http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three.py
var model = {
'version' : 1,
'materials': [%(materials)s],
'buffers': '%(buffers)s',
...
...
@@ -203,21 +201,6 @@ postMessage( model );
TEMPLATE_VERTEX
=
"%f,%f,%f"
TEMPLATE_UV_TRI
=
"%f,%f,%f,%f,%f,%f"
TEMPLATE_UV_QUAD
=
"%f,%f,%f,%f,%f,%f,%f,%f"
TEMPLATE_TRI
=
"%d,%d,%d,%d"
TEMPLATE_QUAD
=
"%d,%d,%d,%d,%d"
TEMPLATE_TRI_UV
=
"%d,%d,%d,%d,%d,%d,%d"
TEMPLATE_QUAD_UV
=
"%d,%d,%d,%d,%d,%d,%d,%d,%d"
TEMPLATE_TRI_N
=
"%d,%d,%d,%d,%d,%d,%d"
TEMPLATE_QUAD_N
=
"%d,%d,%d,%d,%d,%d,%d,%d,%d"
TEMPLATE_TRI_N_UV
=
"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d"
TEMPLATE_QUAD_N_UV
=
"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d"
TEMPLATE_N
=
"%f,%f,%f"
TEMPLATE_UV
=
"%f,%f"
...
...
@@ -571,64 +554,78 @@ def parse_obj(fname):
# #####################################################
# Generator
# #####################################################
def
setBit
(
value
,
position
,
on
):
if
on
:
mask
=
1
<<
position
return
(
value
|
mask
)
else
:
mask
=
~
(
1
<<
position
)
return
(
value
&
mask
)
def
generate_vertex
(
v
):
return
TEMPLATE_VERTEX
%
(
v
[
0
],
v
[
1
],
v
[
2
])
def
generate_triangle
(
f
):
v
=
f
[
'vertex'
]
return
TEMPLATE_TRI
%
(
v
[
0
]
-
1
,
v
[
1
]
-
1
,
v
[
2
]
-
1
,
f
[
'material'
])
def
generate_triangle_uv
(
f
):
v
=
f
[
'vertex'
]
uv
=
f
[
'uv'
]
return
TEMPLATE_TRI_UV
%
(
v
[
0
]
-
1
,
v
[
1
]
-
1
,
v
[
2
]
-
1
,
f
[
'material'
],
uv
[
0
]
-
1
,
uv
[
1
]
-
1
,
uv
[
2
]
-
1
)
def
generate_triangle_n
(
f
):
v
=
f
[
'vertex'
]
n
=
f
[
'normal'
]
return
TEMPLATE_TRI_N
%
(
v
[
0
]
-
1
,
v
[
1
]
-
1
,
v
[
2
]
-
1
,
f
[
'material'
],
n
[
0
]
-
1
,
n
[
1
]
-
1
,
n
[
2
]
-
1
)
def
generate_triangle_n_uv
(
f
):
v
=
f
[
'vertex'
]
n
=
f
[
'normal'
]
uv
=
f
[
'uv'
]
return
TEMPLATE_TRI_N_UV
%
(
v
[
0
]
-
1
,
v
[
1
]
-
1
,
v
[
2
]
-
1
,
f
[
'material'
],
n
[
0
]
-
1
,
n
[
1
]
-
1
,
n
[
2
]
-
1
,
uv
[
0
]
-
1
,
uv
[
1
]
-
1
,
uv
[
2
]
-
1
)
def
generate_quad
(
f
):
vi
=
f
[
'vertex'
]
return
TEMPLATE_QUAD
%
(
vi
[
0
]
-
1
,
vi
[
1
]
-
1
,
vi
[
2
]
-
1
,
vi
[
3
]
-
1
,
f
[
'material'
])
def
generate_face
(
f
):
isTriangle
=
(
len
(
f
[
'vertex'
])
==
3
)
if
isTriangle
:
nVertices
=
3
else
:
nVertices
=
4
hasMaterial
=
True
# for the moment OBJs without materials get default material
hasFaceUvs
=
False
# not supported in OBJ
hasFaceVertexUvs
=
(
len
(
f
[
'uv'
])
==
nVertices
)
def
generate_quad_uv
(
f
):
v
=
f
[
'vertex'
]
uv
=
f
[
'uv'
]
return
TEMPLATE_QUAD_UV
%
(
v
[
0
]
-
1
,
v
[
1
]
-
1
,
v
[
2
]
-
1
,
v
[
3
]
-
1
,
f
[
'material'
],
uv
[
0
]
-
1
,
uv
[
1
]
-
1
,
uv
[
2
]
-
1
,
uv
[
3
]
-
1
)
def
generate_quad_n
(
f
):
v
=
f
[
'vertex'
]
n
=
f
[
'normal'
]
return
TEMPLATE_QUAD_N
%
(
v
[
0
]
-
1
,
v
[
1
]
-
1
,
v
[
2
]
-
1
,
v
[
3
]
-
1
,
f
[
'material'
],
n
[
0
]
-
1
,
n
[
1
]
-
1
,
n
[
2
]
-
1
,
n
[
3
]
-
1
)
def
generate_quad_n_uv
(
f
):
v
=
f
[
'vertex'
]
n
=
f
[
'normal'
]
uv
=
f
[
'uv'
]
return
TEMPLATE_QUAD_N_UV
%
(
v
[
0
]
-
1
,
v
[
1
]
-
1
,
v
[
2
]
-
1
,
v
[
3
]
-
1
,
f
[
'material'
],
n
[
0
]
-
1
,
n
[
1
]
-
1
,
n
[
2
]
-
1
,
n
[
3
]
-
1
,
uv
[
0
]
-
1
,
uv
[
1
]
-
1
,
uv
[
2
]
-
1
,
uv
[
3
]
-
1
)
hasFaceNormals
=
False
# don't export any face normals (as they are computed in engine)
hasFaceVertexNormals
=
(
len
(
f
[
"normal"
])
==
nVertices
and
SHADING
==
"smooth"
)
hasFaceColors
=
False
# not supported in OBJ
hasFaceVertexColors
=
False
# not supported in OBJ
faceType
=
0
faceType
=
setBit
(
faceType
,
0
,
not
isTriangle
)
faceType
=
setBit
(
faceType
,
1
,
hasMaterial
)
faceType
=
setBit
(
faceType
,
2
,
hasFaceUvs
)
faceType
=
setBit
(
faceType
,
3
,
hasFaceVertexUvs
)
faceType
=
setBit
(
faceType
,
4
,
hasFaceNormals
)
faceType
=
setBit
(
faceType
,
5
,
hasFaceVertexNormals
)
faceType
=
setBit
(
faceType
,
6
,
hasFaceColors
)
faceType
=
setBit
(
faceType
,
7
,
hasFaceVertexColors
)
faceData
=
[]
# order is important, must match order in JSONLoader
# face type
# vertex indices
# material index
# face uvs index
# face vertex uvs indices
# face color index
# face vertex colors indices
faceData
.
append
(
faceType
)
# must clamp in case on polygons bigger than quads
for
i
in
xrange
(
nVertices
):
index
=
f
[
'vertex'
][
i
]
-
1
faceData
.
append
(
index
)
faceData
.
append
(
f
[
'material'
]
)
if
hasFaceVertexUvs
:
for
i
in
xrange
(
nVertices
):
index
=
f
[
'uv'
][
i
]
-
1
faceData
.
append
(
index
)
if
hasFaceVertexNormals
:
for
i
in
xrange
(
nVertices
):
index
=
f
[
'normal'
][
i
]
-
1
faceData
.
append
(
index
)
return
","
.
join
(
map
(
str
,
faceData
)
)
def
generate_normal
(
n
):
return
TEMPLATE_N
%
(
n
[
0
],
n
[
1
],
n
[
2
])
...
...
@@ -819,11 +816,11 @@ def convert_ascii(infile, morphfiles, outfile):
n_vertices
=
len
(
vertices
)
nnormal
=
0
normals_string
=
""
if
SHADING
==
"smooth"
:
normals_string
=
","
.
join
(
generate_normal
(
n
)
for
n
in
normals
)
sfaces
=
sort_faces
(
faces
)
nnormal
=
len
(
normals
)
skipOriginalMorph
=
False
norminfile
=
os
.
path
.
normpath
(
infile
)
...
...
@@ -860,6 +857,8 @@ def convert_ascii(infile, morphfiles, outfile):
"fname"
:
infile
,
"nvertex"
:
len
(
vertices
),
"nface"
:
len
(
faces
),
"nuv"
:
len
(
uvs
),
"nnormal"
:
nnormal
,
"nmaterial"
:
len
(
materials
),
"materials"
:
generate_materials_string
(
materials
,
mtllib
),
...
...
@@ -870,14 +869,7 @@ def convert_ascii(infile, morphfiles, outfile):
"morphTargets"
:
morphTargets
,
"triangles"
:
","
.
join
(
generate_triangle
(
f
)
for
f
in
sfaces
[
'triangles_flat'
]),
"trianglesUvs"
:
","
.
join
(
generate_triangle_uv
(
f
)
for
f
in
sfaces
[
'triangles_flat_uv'
]),
"trianglesNormals"
:
","
.
join
(
generate_triangle_n
(
f
)
for
f
in
sfaces
[
'triangles_smooth'
]),
"trianglesNormalsUvs"
:
","
.
join
(
generate_triangle_n_uv
(
f
)
for
f
in
sfaces
[
'triangles_smooth_uv'
]),
"quads"
:
","
.
join
(
generate_quad
(
f
)
for
f
in
sfaces
[
'quads_flat'
]),
"quadsUvs"
:
","
.
join
(
generate_quad_uv
(
f
)
for
f
in
sfaces
[
'quads_flat_uv'
]),
"quadsNormals"
:
","
.
join
(
generate_quad_n
(
f
)
for
f
in
sfaces
[
'quads_smooth'
]),
"quadsNormalsUvs"
:
","
.
join
(
generate_quad_n_uv
(
f
)
for
f
in
sfaces
[
'quads_smooth_uv'
])
"faces"
:
","
.
join
(
generate_face
(
f
)
for
f
in
faces
)
}
out
=
open
(
outfile
,
"w"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录