Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
aebe8986
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,发现更多精彩内容 >>
提交
aebe8986
编写于
11月 15, 2010
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Forgot to commit MeshDepthMaterial
上级
98dc841a
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
43 addition
and
2 deletion
+43
-2
build/Three.js
build/Three.js
+1
-1
build/ThreeDebug.js
build/ThreeDebug.js
+1
-1
src/materials/MeshDepthMaterial.js
src/materials/MeshDepthMaterial.js
+40
-0
src/renderers/CanvasRenderer.js
src/renderers/CanvasRenderer.js
+1
-0
未找到文件。
build/Three.js
浏览文件 @
aebe8986
// Three.js r28 - http://github.com/mrdoob/three.js
var
THREE
=
THREE
||
{};
THREE
.
Color
=
function
(
a
){
this
.
autoUpdate
=
true
;
this
.
setHex
(
a
)};
THREE
.
Color
.
prototype
=
{
setRGBA
:
function
(
f
,
e
,
c
,
d
){
this
.
r
=
f
;
this
.
g
=
e
;
this
.
b
=
c
;
this
.
a
=
d
;
if
(
this
.
autoUpdate
){
this
.
updateHex
();
this
.
updateStyleString
()}},
setHex
:
function
(
a
){
this
.
hex
=
(
~~
a
).
toString
(
16
).
length
<
8
?
255
<<
24
^
a
:
a
;
if
(
this
.
autoUpdate
){
this
.
updateRGBA
();
this
.
updateStyleString
()}},
copyRGB
:
function
(
a
){
this
.
r
=
a
.
r
;
this
.
g
=
a
.
g
;
this
.
b
=
a
.
b
},
copyRGBA
:
function
(
a
){
this
.
r
=
a
.
r
;
this
.
g
=
a
.
g
;
this
.
b
=
a
.
b
;
this
.
a
=
a
.
a
},
multiplySelfRGB
:
function
(
a
){
this
.
r
*=
a
.
r
;
this
.
g
*=
a
.
g
;
this
.
b
*=
a
.
b
},
updateHex
:
function
(){
this
.
hex
=~~
(
this
.
a
*
255
)
<<
24
^~~
(
this
.
r
*
255
)
<<
16
^~~
(
this
.
g
*
255
)
<<
8
^~~
(
this
.
b
*
255
)},
updateRGBA
:
function
(){
this
.
a
=
(
this
.
hex
>>
24
&
255
)
/
255
;
this
.
r
=
(
this
.
hex
>>
16
&
255
)
/
255
;
this
.
g
=
(
this
.
hex
>>
8
&
255
)
/
255
;
this
.
b
=
(
this
.
hex
&
255
)
/
255
},
updateStyleString
:
function
(){
this
.
__styleString
=
"
rgba(
"
+~~
(
this
.
r
*
255
)
+
"
,
"
+~~
(
this
.
g
*
255
)
+
"
,
"
+~~
(
this
.
b
*
255
)
+
"
,
"
+
this
.
a
+
"
)
"
},
toString
:
function
(){
return
"
THREE.Color ( r:
"
+
this
.
r
+
"
, g:
"
+
this
.
g
+
"
, b:
"
+
this
.
b
+
"
, a:
"
+
this
.
a
+
"
, hex:
"
+
this
.
hex
+
"
)
"
}};
THREE
.
Vector2
=
function
(
a
,
b
){
this
.
x
=
a
||
0
;
this
.
y
=
b
||
0
};
THREE
.
Vector2
.
prototype
=
{
set
:
function
(
a
,
b
){
this
.
x
=
a
;
this
.
y
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
x
=
a
.
x
;
this
.
y
=
a
.
y
;
return
this
},
addSelf
:
function
(
a
){
this
.
x
+=
a
.
x
;
this
.
y
+=
a
.
y
;
return
this
},
add
:
function
(
b
,
a
){
this
.
x
=
b
.
x
+
a
.
x
;
this
.
y
=
b
.
y
+
a
.
y
;
return
this
},
subSelf
:
function
(
a
){
this
.
x
-=
a
.
x
;
this
.
y
-=
a
.
y
;
return
this
},
sub
:
function
(
b
,
a
){
this
.
x
=
b
.
x
-
a
.
x
;
this
.
y
=
b
.
y
-
a
.
y
;
return
this
},
multiplyScalar
:
function
(
a
){
this
.
x
*=
a
;
this
.
y
*=
a
;
return
this
},
unit
:
function
(){
this
.
multiplyScalar
(
1
/
this
.
length
());
return
this
},
length
:
function
(){
return
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
)},
lengthSq
:
function
(){
return
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
},
negate
:
function
(){
this
.
x
=-
this
.
x
;
this
.
y
=-
this
.
y
;
return
this
},
clone
:
function
(){
return
new
THREE
.
Vector2
(
this
.
x
,
this
.
y
)},
toString
:
function
(){
return
"
THREE.Vector2 (
"
+
this
.
x
+
"
,
"
+
this
.
y
+
"
)
"
}};
THREE
.
Vector3
=
function
(
a
,
c
,
b
){
this
.
x
=
a
||
0
;
this
.
y
=
c
||
0
;
this
.
z
=
b
||
0
};
THREE
.
Vector3
.
prototype
=
{
set
:
function
(
a
,
c
,
b
){
this
.
x
=
a
;
this
.
y
=
c
;
this
.
z
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
x
=
a
.
x
;
this
.
y
=
a
.
y
;
this
.
z
=
a
.
z
;
return
this
},
add
:
function
(
b
,
a
){
this
.
x
=
b
.
x
+
a
.
x
;
this
.
y
=
b
.
y
+
a
.
y
;
this
.
z
=
b
.
z
+
a
.
z
;
return
this
},
addSelf
:
function
(
a
){
this
.
x
+=
a
.
x
;
this
.
y
+=
a
.
y
;
this
.
z
+=
a
.
z
;
return
this
},
addScalar
:
function
(
a
){
this
.
x
+=
a
;
this
.
y
+=
a
;
this
.
z
+=
a
;
return
this
},
sub
:
function
(
b
,
a
){
this
.
x
=
b
.
x
-
a
.
x
;
this
.
y
=
b
.
y
-
a
.
y
;
this
.
z
=
b
.
z
-
a
.
z
;
return
this
},
subSelf
:
function
(
a
){
this
.
x
-=
a
.
x
;
this
.
y
-=
a
.
y
;
this
.
z
-=
a
.
z
;
return
this
},
cross
:
function
(
b
,
a
){
this
.
x
=
b
.
y
*
a
.
z
-
b
.
z
*
a
.
y
;
this
.
y
=
b
.
z
*
a
.
x
-
b
.
x
*
a
.
z
;
this
.
z
=
b
.
x
*
a
.
y
-
b
.
y
*
a
.
x
;
return
this
},
crossSelf
:
function
(
c
){
var
b
=
this
.
x
,
a
=
this
.
y
,
d
=
this
.
z
;
this
.
x
=
a
*
c
.
z
-
d
*
c
.
y
;
this
.
y
=
d
*
c
.
x
-
b
*
c
.
z
;
this
.
z
=
b
*
c
.
y
-
a
*
c
.
x
;
return
this
},
multiplySelf
:
function
(
a
){
this
.
x
*=
a
.
x
;
this
.
y
*=
a
.
y
;
this
.
z
*=
a
.
z
;
return
this
},
multiplyScalar
:
function
(
a
){
this
.
x
*=
a
;
this
.
y
*=
a
;
this
.
z
*=
a
;
return
this
},
divideScalar
:
function
(
a
){
this
.
x
/=
a
;
this
.
y
/=
a
;
this
.
z
/=
a
;
return
this
},
dot
:
function
(
a
){
return
this
.
x
*
a
.
x
+
this
.
y
*
a
.
y
+
this
.
z
*
a
.
z
},
distanceTo
:
function
(
a
){
return
Math
.
sqrt
(
this
.
distanceToSquared
(
a
))},
distanceToSquared
:
function
(
d
){
var
c
=
this
.
x
-
d
.
x
,
b
=
this
.
y
-
d
.
y
,
a
=
this
.
z
-
d
.
z
;
return
c
*
c
+
b
*
b
+
a
*
a
},
length
:
function
(){
return
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
)},
lengthSq
:
function
(){
return
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
},
negate
:
function
(){
this
.
x
=-
this
.
x
;
this
.
y
=-
this
.
y
;
this
.
z
=-
this
.
z
;
return
this
},
normalize
:
function
(){
if
(
this
.
length
()
>
0
){
this
.
multiplyScalar
(
1
/
this
.
length
())}
else
{
this
.
multiplyScalar
(
0
)}
return
this
},
setLength
:
function
(
a
){
return
this
.
normalize
().
multiplyScalar
(
a
)},
isZero
:
function
(){
var
a
=
0.0001
;
return
(
Math
.
abs
(
this
.
x
)
<
a
)
&&
(
Math
.
abs
(
this
.
y
)
<
a
)
&&
(
Math
.
abs
(
this
.
z
)
<
a
)},
clone
:
function
(){
return
new
THREE
.
Vector3
(
this
.
x
,
this
.
y
,
this
.
z
)},
toString
:
function
(){
return
"
THREE.Vector3 (
"
+
this
.
x
+
"
,
"
+
this
.
y
+
"
,
"
+
this
.
z
+
"
)
"
}};
THREE
.
Vector4
=
function
(
a
,
d
,
c
,
b
){
this
.
x
=
a
||
0
;
this
.
y
=
d
||
0
;
this
.
z
=
c
||
0
;
this
.
w
=
b
||
1
};
THREE
.
Vector4
.
prototype
=
{
set
:
function
(
a
,
d
,
c
,
b
){
this
.
x
=
a
;
this
.
y
=
d
;
this
.
z
=
c
;
this
.
w
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
x
=
a
.
x
;
this
.
y
=
a
.
y
;
this
.
z
=
a
.
z
;
this
.
w
=
a
.
w
;
return
this
},
add
:
function
(
b
,
a
){
this
.
x
=
b
.
x
+
a
.
x
;
this
.
y
=
b
.
y
+
a
.
y
;
this
.
z
=
b
.
z
+
a
.
z
;
this
.
w
=
b
.
w
+
a
.
w
;
return
this
},
addSelf
:
function
(
a
){
this
.
x
+=
a
.
x
;
this
.
y
+=
a
.
y
;
this
.
z
+=
a
.
z
;
this
.
w
+=
a
.
w
;
return
this
},
sub
:
function
(
b
,
a
){
this
.
x
=
b
.
x
-
a
.
x
;
this
.
y
=
b
.
y
-
a
.
y
;
this
.
z
=
b
.
z
-
a
.
z
;
this
.
w
=
b
.
w
-
a
.
w
;
return
this
},
subSelf
:
function
(
a
){
this
.
x
-=
a
.
x
;
this
.
y
-=
a
.
y
;
this
.
z
-=
a
.
z
;
this
.
w
-=
a
.
w
;
return
this
},
clone
:
function
(){
return
new
THREE
.
Vector4
(
this
.
x
,
this
.
y
,
this
.
z
,
this
.
w
)},
toString
:
function
(){
return
"
THREE.Vector4 (
"
+
this
.
x
+
"
,
"
+
this
.
y
+
"
,
"
+
this
.
z
+
"
,
"
+
this
.
w
+
"
)
"
}};
THREE
.
Ray
=
function
(
a
,
b
){
this
.
origin
=
a
||
new
THREE
.
Vector3
();
this
.
direction
=
b
||
new
THREE
.
Vector3
()};
THREE
.
Ray
.
prototype
=
{
intersectScene
:
function
(
f
){
var
c
,
a
,
b
,
e
=
f
.
objects
,
d
=
[];
for
(
c
=
0
,
a
=
e
.
length
;
c
<
a
;
c
++
){
b
=
e
[
c
];
if
(
b
instanceof
THREE
.
Mesh
){
d
=
d
.
concat
(
this
.
intersectObject
(
b
))}}
d
.
sort
(
function
(
h
,
g
){
return
h
.
distance
-
g
.
distance
});
return
d
},
intersectObject
:
function
(
w
){
var
n
,
j
,
i
,
t
,
s
,
q
,
p
,
v
,
k
,
x
,
u
,
r
,
g
=
w
.
geometry
,
h
=
g
.
vertices
,
o
,
e
=
[],
m
;
for
(
n
=
0
,
j
=
g
.
faces
.
length
;
n
<
j
;
n
++
){
i
=
g
.
faces
[
n
];
u
=
this
.
origin
.
clone
();
r
=
this
.
direction
.
clone
();
t
=
w
.
matrix
.
transform
(
h
[
i
.
a
].
position
.
clone
());
s
=
w
.
matrix
.
transform
(
h
[
i
.
b
].
position
.
clone
());
q
=
w
.
matrix
.
transform
(
h
[
i
.
c
].
position
.
clone
());
p
=
i
instanceof
THREE
.
Face4
?
w
.
matrix
.
transform
(
h
[
i
.
d
].
position
.
clone
()):
null
;
v
=
w
.
matrixRotation
.
transform
(
i
.
normal
.
clone
());
k
=
r
.
dot
(
v
);
if
(
k
<
0
){
x
=
v
.
dot
(
new
THREE
.
Vector3
().
sub
(
t
,
u
))
/
k
;
m
=
u
.
addSelf
(
r
.
multiplyScalar
(
x
));
if
(
i
instanceof
THREE
.
Face3
){
if
(
l
(
m
,
t
,
s
,
q
)){
o
=
{
distance
:
this
.
origin
.
distanceTo
(
m
),
point
:
m
,
face
:
i
,
object
:
w
};
e
.
push
(
o
)}}
else
{
if
(
i
instanceof
THREE
.
Face4
){
if
(
l
(
m
,
t
,
s
,
p
)
||
l
(
m
,
s
,
q
,
p
)){
o
=
{
distance
:
this
.
origin
.
distanceTo
(
m
),
point
:
m
,
face
:
i
,
object
:
w
};
e
.
push
(
o
)}}}}}
return
e
;
function
l
(
d
,
G
,
D
,
B
){
var
J
=
B
.
clone
().
subSelf
(
G
),
H
=
D
.
clone
().
subSelf
(
G
),
E
=
d
.
clone
().
subSelf
(
G
),
F
=
J
.
dot
(
J
),
C
=
J
.
dot
(
H
),
A
=
J
.
dot
(
E
),
z
=
H
.
dot
(
H
),
f
=
H
.
dot
(
E
),
y
=
1
/
(
F
*
z
-
C
*
C
),
K
=
(
z
*
A
-
C
*
f
)
*
y
,
I
=
(
F
*
f
-
C
*
A
)
*
y
;
return
(
K
>
0
)
&&
(
I
>
0
)
&&
(
K
+
I
<
1
)}}};
THREE
.
Rectangle
=
function
(){
var
e
,
g
,
h
,
d
,
a
,
c
,
f
=
true
;
function
b
(){
a
=
h
-
e
;
c
=
d
-
g
}
this
.
getX
=
function
(){
return
e
};
this
.
getY
=
function
(){
return
g
};
this
.
getWidth
=
function
(){
return
a
};
this
.
getHeight
=
function
(){
return
c
};
this
.
getLeft
=
function
(){
return
e
};
this
.
getTop
=
function
(){
return
g
};
this
.
getRight
=
function
(){
return
h
};
this
.
getBottom
=
function
(){
return
d
};
this
.
set
=
function
(
l
,
k
,
j
,
i
){
f
=
false
;
e
=
l
;
g
=
k
;
h
=
j
;
d
=
i
;
b
()};
this
.
addPoint
=
function
(
i
,
j
){
if
(
f
){
f
=
false
;
e
=
i
;
g
=
j
;
h
=
i
;
d
=
j
}
else
{
e
=
Math
.
min
(
e
,
i
);
g
=
Math
.
min
(
g
,
j
);
h
=
Math
.
max
(
h
,
i
);
d
=
Math
.
max
(
d
,
j
)}
b
()};
this
.
addRectangle
=
function
(
i
){
if
(
f
){
f
=
false
;
e
=
i
.
getLeft
();
g
=
i
.
getTop
();
h
=
i
.
getRight
();
d
=
i
.
getBottom
()}
else
{
e
=
Math
.
min
(
e
,
i
.
getLeft
());
g
=
Math
.
min
(
g
,
i
.
getTop
());
h
=
Math
.
max
(
h
,
i
.
getRight
());
d
=
Math
.
max
(
d
,
i
.
getBottom
())}
b
()};
this
.
inflate
=
function
(
i
){
e
-=
i
;
g
-=
i
;
h
+=
i
;
d
+=
i
;
b
()};
this
.
minSelf
=
function
(
i
){
e
=
Math
.
max
(
e
,
i
.
getLeft
());
g
=
Math
.
max
(
g
,
i
.
getTop
());
h
=
Math
.
min
(
h
,
i
.
getRight
());
d
=
Math
.
min
(
d
,
i
.
getBottom
());
b
()};
this
.
instersects
=
function
(
i
){
return
Math
.
min
(
h
,
i
.
getRight
())
-
Math
.
max
(
e
,
i
.
getLeft
())
>=
0
&&
Math
.
min
(
d
,
i
.
getBottom
())
-
Math
.
max
(
g
,
i
.
getTop
())
>=
0
};
this
.
empty
=
function
(){
f
=
true
;
e
=
0
;
g
=
0
;
h
=
0
;
d
=
0
;
b
()};
this
.
isEmpty
=
function
(){
return
f
};
this
.
toString
=
function
(){
return
"
THREE.Rectangle ( left:
"
+
e
+
"
, right:
"
+
h
+
"
, top:
"
+
g
+
"
, bottom:
"
+
d
+
"
, width:
"
+
a
+
"
, height:
"
+
c
+
"
)
"
}};
THREE
.
Matrix3
=
function
(){
this
.
m
=
[]};
THREE
.
Matrix3
.
prototype
=
{
transpose
:
function
(){
var
a
;
a
=
this
.
m
[
1
];
this
.
m
[
1
]
=
this
.
m
[
3
];
this
.
m
[
3
]
=
a
;
a
=
this
.
m
[
2
];
this
.
m
[
2
]
=
this
.
m
[
6
];
this
.
m
[
6
]
=
a
;
a
=
this
.
m
[
5
];
this
.
m
[
5
]
=
this
.
m
[
7
];
this
.
m
[
7
]
=
a
;
return
this
}};
THREE
.
Matrix4
=
function
(){
this
.
_x
=
new
THREE
.
Vector3
();
this
.
_y
=
new
THREE
.
Vector3
();
this
.
_z
=
new
THREE
.
Vector3
()};
THREE
.
Matrix4
.
prototype
=
{
n11
:
1
,
n12
:
0
,
n13
:
0
,
n14
:
0
,
n21
:
0
,
n22
:
1
,
n23
:
0
,
n24
:
0
,
n31
:
0
,
n32
:
0
,
n33
:
1
,
n34
:
0
,
n41
:
0
,
n42
:
0
,
n43
:
0
,
n44
:
1
,
identity
:
function
(){
this
.
n11
=
1
;
this
.
n12
=
0
;
this
.
n13
=
0
;
this
.
n14
=
0
;
this
.
n21
=
0
;
this
.
n22
=
1
;
this
.
n23
=
0
;
this
.
n24
=
0
;
this
.
n31
=
0
;
this
.
n32
=
0
;
this
.
n33
=
1
;
this
.
n34
=
0
;
this
.
n41
=
0
;
this
.
n42
=
0
;
this
.
n43
=
0
;
this
.
n44
=
1
},
copy
:
function
(
a
){
this
.
n11
=
a
.
n11
;
this
.
n12
=
a
.
n12
;
this
.
n13
=
a
.
n13
;
this
.
n14
=
a
.
n14
;
this
.
n21
=
a
.
n21
;
this
.
n22
=
a
.
n22
;
this
.
n23
=
a
.
n23
;
this
.
n24
=
a
.
n24
;
this
.
n31
=
a
.
n31
;
this
.
n32
=
a
.
n32
;
this
.
n33
=
a
.
n33
;
this
.
n34
=
a
.
n34
;
this
.
n41
=
a
.
n41
;
this
.
n42
=
a
.
n42
;
this
.
n43
=
a
.
n43
;
this
.
n44
=
a
.
n44
},
lookAt
:
function
(
d
,
c
,
b
){
var
a
=
this
.
_x
,
f
=
this
.
_y
,
e
=
this
.
_z
;
e
.
sub
(
d
,
c
);
e
.
normalize
();
a
.
cross
(
b
,
e
);
a
.
normalize
();
f
.
cross
(
e
,
a
);
f
.
normalize
();
this
.
n11
=
a
.
x
;
this
.
n12
=
a
.
y
;
this
.
n13
=
a
.
z
;
this
.
n14
=-
a
.
dot
(
d
);
this
.
n21
=
f
.
x
;
this
.
n22
=
f
.
y
;
this
.
n23
=
f
.
z
;
this
.
n24
=-
f
.
dot
(
d
);
this
.
n31
=
e
.
x
;
this
.
n32
=
e
.
y
;
this
.
n33
=
e
.
z
;
this
.
n34
=-
e
.
dot
(
d
);
this
.
n41
=
0
;
this
.
n42
=
0
;
this
.
n43
=
0
;
this
.
n44
=
1
},
transform
:
function
(
a
){
var
d
=
a
.
x
,
c
=
a
.
y
,
b
=
a
.
z
,
e
=
a
.
w
?
a
.
w
:
1
;
a
.
x
=
this
.
n11
*
d
+
this
.
n12
*
c
+
this
.
n13
*
b
+
this
.
n14
*
e
;
a
.
y
=
this
.
n21
*
d
+
this
.
n22
*
c
+
this
.
n23
*
b
+
this
.
n24
*
e
;
a
.
z
=
this
.
n31
*
d
+
this
.
n32
*
c
+
this
.
n33
*
b
+
this
.
n34
*
e
;
e
=
this
.
n41
*
d
+
this
.
n42
*
c
+
this
.
n43
*
b
+
this
.
n44
*
e
;
if
(
a
.
w
){
a
.
w
=
e
}
else
{
a
.
x
=
a
.
x
/
e
;
a
.
y
=
a
.
y
/
e
;
a
.
z
=
a
.
z
/
e
}
return
a
},
crossVector
:
function
(
b
){
var
c
=
new
THREE
.
Vector4
();
c
.
x
=
this
.
n11
*
b
.
x
+
this
.
n12
*
b
.
y
+
this
.
n13
*
b
.
z
+
this
.
n14
*
b
.
w
;
c
.
y
=
this
.
n21
*
b
.
x
+
this
.
n22
*
b
.
y
+
this
.
n23
*
b
.
z
+
this
.
n24
*
b
.
w
;
c
.
z
=
this
.
n31
*
b
.
x
+
this
.
n32
*
b
.
y
+
this
.
n33
*
b
.
z
+
this
.
n34
*
b
.
w
;
c
.
w
=
(
b
.
w
)?
this
.
n41
*
b
.
x
+
this
.
n42
*
b
.
y
+
this
.
n43
*
b
.
z
+
this
.
n44
*
b
.
w
:
1
;
return
c
},
multiply
:
function
(
d
,
c
){
this
.
n11
=
d
.
n11
*
c
.
n11
+
d
.
n12
*
c
.
n21
+
d
.
n13
*
c
.
n31
+
d
.
n14
*
c
.
n41
;
this
.
n12
=
d
.
n11
*
c
.
n12
+
d
.
n12
*
c
.
n22
+
d
.
n13
*
c
.
n32
+
d
.
n14
*
c
.
n42
;
this
.
n13
=
d
.
n11
*
c
.
n13
+
d
.
n12
*
c
.
n23
+
d
.
n13
*
c
.
n33
+
d
.
n14
*
c
.
n43
;
this
.
n14
=
d
.
n11
*
c
.
n14
+
d
.
n12
*
c
.
n24
+
d
.
n13
*
c
.
n34
+
d
.
n14
*
c
.
n44
;
this
.
n21
=
d
.
n21
*
c
.
n11
+
d
.
n22
*
c
.
n21
+
d
.
n23
*
c
.
n31
+
d
.
n24
*
c
.
n41
;
this
.
n22
=
d
.
n21
*
c
.
n12
+
d
.
n22
*
c
.
n22
+
d
.
n23
*
c
.
n32
+
d
.
n24
*
c
.
n42
;
this
.
n23
=
d
.
n21
*
c
.
n13
+
d
.
n22
*
c
.
n23
+
d
.
n23
*
c
.
n33
+
d
.
n24
*
c
.
n43
;
this
.
n24
=
d
.
n21
*
c
.
n14
+
d
.
n22
*
c
.
n24
+
d
.
n23
*
c
.
n34
+
d
.
n24
*
c
.
n44
;
this
.
n31
=
d
.
n31
*
c
.
n11
+
d
.
n32
*
c
.
n21
+
d
.
n33
*
c
.
n31
+
d
.
n34
*
c
.
n41
;
this
.
n32
=
d
.
n31
*
c
.
n12
+
d
.
n32
*
c
.
n22
+
d
.
n33
*
c
.
n32
+
d
.
n34
*
c
.
n42
;
this
.
n33
=
d
.
n31
*
c
.
n13
+
d
.
n32
*
c
.
n23
+
d
.
n33
*
c
.
n33
+
d
.
n34
*
c
.
n43
;
this
.
n34
=
d
.
n31
*
c
.
n14
+
d
.
n32
*
c
.
n24
+
d
.
n33
*
c
.
n34
+
d
.
n34
*
c
.
n44
;
this
.
n41
=
d
.
n41
*
c
.
n11
+
d
.
n42
*
c
.
n21
+
d
.
n43
*
c
.
n31
+
d
.
n44
*
c
.
n41
;
this
.
n42
=
d
.
n41
*
c
.
n12
+
d
.
n42
*
c
.
n22
+
d
.
n43
*
c
.
n32
+
d
.
n44
*
c
.
n42
;
this
.
n43
=
d
.
n41
*
c
.
n13
+
d
.
n42
*
c
.
n23
+
d
.
n43
*
c
.
n33
+
d
.
n44
*
c
.
n43
;
this
.
n44
=
d
.
n41
*
c
.
n14
+
d
.
n42
*
c
.
n24
+
d
.
n43
*
c
.
n34
+
d
.
n44
*
c
.
n44
},
multiplySelf
:
function
(
c
){
var
o
=
this
.
n11
,
n
=
this
.
n12
,
k
=
this
.
n13
,
i
=
this
.
n14
,
f
=
this
.
n21
,
e
=
this
.
n22
,
d
=
this
.
n23
,
b
=
this
.
n24
,
a
=
this
.
n31
,
r
=
this
.
n32
,
q
=
this
.
n33
,
p
=
this
.
n34
,
l
=
this
.
n41
,
j
=
this
.
n42
,
h
=
this
.
n43
,
g
=
this
.
n44
;
this
.
n11
=
o
*
c
.
n11
+
n
*
c
.
n21
+
k
*
c
.
n31
+
i
*
c
.
n41
;
this
.
n12
=
o
*
c
.
n12
+
n
*
c
.
n22
+
k
*
c
.
n32
+
i
*
c
.
n42
;
this
.
n13
=
o
*
c
.
n13
+
n
*
c
.
n23
+
k
*
c
.
n33
+
i
*
c
.
n43
;
this
.
n14
=
o
*
c
.
n14
+
n
*
c
.
n24
+
k
*
c
.
n34
+
i
*
c
.
n44
;
this
.
n21
=
f
*
c
.
n11
+
e
*
c
.
n21
+
d
*
c
.
n31
+
b
*
c
.
n41
;
this
.
n22
=
f
*
c
.
n12
+
e
*
c
.
n22
+
d
*
c
.
n32
+
b
*
c
.
n42
;
this
.
n23
=
f
*
c
.
n13
+
e
*
c
.
n23
+
d
*
c
.
n33
+
b
*
c
.
n43
;
this
.
n24
=
f
*
c
.
n14
+
e
*
c
.
n24
+
d
*
c
.
n34
+
b
*
c
.
n44
;
this
.
n31
=
a
*
c
.
n11
+
r
*
c
.
n21
+
q
*
c
.
n31
+
p
*
c
.
n41
;
this
.
n32
=
a
*
c
.
n12
+
r
*
c
.
n22
+
q
*
c
.
n32
+
p
*
c
.
n42
;
this
.
n33
=
a
*
c
.
n13
+
r
*
c
.
n23
+
q
*
c
.
n33
+
p
*
c
.
n43
;
this
.
n34
=
a
*
c
.
n14
+
r
*
c
.
n24
+
q
*
c
.
n34
+
p
*
c
.
n44
;
this
.
n41
=
l
*
c
.
n11
+
j
*
c
.
n21
+
h
*
c
.
n31
+
g
*
c
.
n41
;
this
.
n42
=
l
*
c
.
n12
+
j
*
c
.
n22
+
h
*
c
.
n32
+
g
*
c
.
n42
;
this
.
n43
=
l
*
c
.
n13
+
j
*
c
.
n23
+
h
*
c
.
n33
+
g
*
c
.
n43
;
this
.
n44
=
l
*
c
.
n14
+
j
*
c
.
n24
+
h
*
c
.
n34
+
g
*
c
.
n44
},
multiplyScalar
:
function
(
a
){
this
.
n11
*=
a
;
this
.
n12
*=
a
;
this
.
n13
*=
a
;
this
.
n14
*=
a
;
this
.
n21
*=
a
;
this
.
n22
*=
a
;
this
.
n23
*=
a
;
this
.
n24
*=
a
;
this
.
n31
*=
a
;
this
.
n32
*=
a
;
this
.
n33
*=
a
;
this
.
n34
*=
a
;
this
.
n41
*=
a
;
this
.
n42
*=
a
;
this
.
n43
*=
a
;
this
.
n44
*=
a
},
determinant
:
function
(){
return
(
this
.
n14
*
this
.
n23
*
this
.
n32
*
this
.
n41
-
this
.
n13
*
this
.
n24
*
this
.
n32
*
this
.
n41
-
this
.
n14
*
this
.
n22
*
this
.
n33
*
this
.
n41
+
this
.
n12
*
this
.
n24
*
this
.
n33
*
this
.
n41
+
this
.
n13
*
this
.
n22
*
this
.
n34
*
this
.
n41
-
this
.
n12
*
this
.
n23
*
this
.
n34
*
this
.
n41
-
this
.
n14
*
this
.
n23
*
this
.
n31
*
this
.
n42
+
this
.
n13
*
this
.
n24
*
this
.
n31
*
this
.
n42
+
this
.
n14
*
this
.
n21
*
this
.
n33
*
this
.
n42
-
this
.
n11
*
this
.
n24
*
this
.
n33
*
this
.
n42
-
this
.
n13
*
this
.
n21
*
this
.
n34
*
this
.
n42
+
this
.
n11
*
this
.
n23
*
this
.
n34
*
this
.
n42
+
this
.
n14
*
this
.
n22
*
this
.
n31
*
this
.
n43
-
this
.
n12
*
this
.
n24
*
this
.
n31
*
this
.
n43
-
this
.
n14
*
this
.
n21
*
this
.
n32
*
this
.
n43
+
this
.
n11
*
this
.
n24
*
this
.
n32
*
this
.
n43
+
this
.
n12
*
this
.
n21
*
this
.
n34
*
this
.
n43
-
this
.
n11
*
this
.
n22
*
this
.
n34
*
this
.
n43
-
this
.
n13
*
this
.
n22
*
this
.
n31
*
this
.
n44
+
this
.
n12
*
this
.
n23
*
this
.
n31
*
this
.
n44
+
this
.
n13
*
this
.
n21
*
this
.
n32
*
this
.
n44
-
this
.
n11
*
this
.
n23
*
this
.
n32
*
this
.
n44
-
this
.
n12
*
this
.
n21
*
this
.
n33
*
this
.
n44
+
this
.
n11
*
this
.
n22
*
this
.
n33
*
this
.
n44
)},
transpose
:
function
(){
function
a
(
d
,
e
,
c
){
var
b
=
d
[
e
];
d
[
e
]
=
d
[
c
];
d
[
c
]
=
b
}
a
(
this
,
"
n21
"
,
"
n12
"
);
a
(
this
,
"
n31
"
,
"
n13
"
);
a
(
this
,
"
n32
"
,
"
n23
"
);
a
(
this
,
"
n41
"
,
"
n14
"
);
a
(
this
,
"
n42
"
,
"
n24
"
);
a
(
this
,
"
n43
"
,
"
n34
"
);
return
this
},
clone
:
function
(){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
this
.
n11
;
a
.
n12
=
this
.
n12
;
a
.
n13
=
this
.
n13
;
a
.
n14
=
this
.
n14
;
a
.
n21
=
this
.
n21
;
a
.
n22
=
this
.
n22
;
a
.
n23
=
this
.
n23
;
a
.
n24
=
this
.
n24
;
a
.
n31
=
this
.
n31
;
a
.
n32
=
this
.
n32
;
a
.
n33
=
this
.
n33
;
a
.
n34
=
this
.
n34
;
a
.
n41
=
this
.
n41
;
a
.
n42
=
this
.
n42
;
a
.
n43
=
this
.
n43
;
a
.
n44
=
this
.
n44
;
return
a
},
flatten
:
function
(){
return
[
this
.
n11
,
this
.
n21
,
this
.
n31
,
this
.
n41
,
this
.
n12
,
this
.
n22
,
this
.
n32
,
this
.
n42
,
this
.
n13
,
this
.
n23
,
this
.
n33
,
this
.
n43
,
this
.
n14
,
this
.
n24
,
this
.
n34
,
this
.
n44
]},
toString
:
function
(){
return
"
|
"
+
this
.
n11
+
"
"
+
this
.
n12
+
"
"
+
this
.
n13
+
"
"
+
this
.
n14
+
"
|
\n
|
"
+
this
.
n21
+
"
"
+
this
.
n22
+
"
"
+
this
.
n23
+
"
"
+
this
.
n24
+
"
|
\n
|
"
+
this
.
n31
+
"
"
+
this
.
n32
+
"
"
+
this
.
n33
+
"
"
+
this
.
n34
+
"
|
\n
|
"
+
this
.
n41
+
"
"
+
this
.
n42
+
"
"
+
this
.
n43
+
"
"
+
this
.
n44
+
"
|
"
}};
THREE
.
Matrix4
.
translationMatrix
=
function
(
b
,
d
,
c
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n14
=
b
;
a
.
n24
=
d
;
a
.
n34
=
c
;
return
a
};
THREE
.
Matrix4
.
scaleMatrix
=
function
(
b
,
d
,
c
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
b
;
a
.
n22
=
d
;
a
.
n33
=
c
;
return
a
};
THREE
.
Matrix4
.
rotationXMatrix
=
function
(
b
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n22
=
a
.
n33
=
Math
.
cos
(
b
);
a
.
n32
=
Math
.
sin
(
b
);
a
.
n23
=-
a
.
n32
;
return
a
};
THREE
.
Matrix4
.
rotationYMatrix
=
function
(
b
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
a
.
n33
=
Math
.
cos
(
b
);
a
.
n13
=
Math
.
sin
(
b
);
a
.
n31
=-
a
.
n13
;
return
a
};
THREE
.
Matrix4
.
rotationZMatrix
=
function
(
b
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
a
.
n22
=
Math
.
cos
(
b
);
a
.
n21
=
Math
.
sin
(
b
);
a
.
n12
=-
a
.
n21
;
return
a
};
THREE
.
Matrix4
.
rotationAxisAngleMatrix
=
function
(
b
,
d
){
var
a
=
new
THREE
.
Matrix4
(),
f
=
Math
.
cos
(
d
),
j
=
Math
.
sin
(
d
),
i
=
1
-
f
,
h
=
b
.
x
,
g
=
b
.
y
,
e
=
b
.
z
;
a
.
n11
=
i
*
h
*
h
+
f
;
a
.
n12
=
i
*
h
*
g
-
j
*
e
;
a
.
n13
=
i
*
h
*
e
+
j
*
g
;
a
.
n21
=
i
*
h
*
g
+
j
*
e
;
a
.
n22
=
i
*
g
*
g
+
f
;
a
.
n23
=
i
*
g
*
e
-
j
*
h
;
a
.
n31
=
i
*
h
*
e
-
j
*
g
;
a
.
n32
=
i
*
g
*
e
+
j
*
h
;
a
.
n33
=
i
*
e
*
e
+
f
;
return
a
};
THREE
.
Matrix4
.
makeInvert
=
function
(
b
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
b
.
n23
*
b
.
n34
*
b
.
n42
-
b
.
n24
*
b
.
n33
*
b
.
n42
+
b
.
n24
*
b
.
n32
*
b
.
n43
-
b
.
n22
*
b
.
n34
*
b
.
n43
-
b
.
n23
*
b
.
n32
*
b
.
n44
+
b
.
n22
*
b
.
n33
*
b
.
n44
;
a
.
n12
=
b
.
n14
*
b
.
n33
*
b
.
n42
-
b
.
n13
*
b
.
n34
*
b
.
n42
-
b
.
n14
*
b
.
n32
*
b
.
n43
+
b
.
n12
*
b
.
n34
*
b
.
n43
+
b
.
n13
*
b
.
n32
*
b
.
n44
-
b
.
n12
*
b
.
n33
*
b
.
n44
;
a
.
n13
=
b
.
n13
*
b
.
n24
*
b
.
n42
-
b
.
n14
*
b
.
n23
*
b
.
n42
+
b
.
n14
*
b
.
n22
*
b
.
n43
-
b
.
n12
*
b
.
n24
*
b
.
n43
-
b
.
n13
*
b
.
n22
*
b
.
n44
+
b
.
n12
*
b
.
n23
*
b
.
n44
;
a
.
n14
=
b
.
n14
*
b
.
n23
*
b
.
n32
-
b
.
n13
*
b
.
n24
*
b
.
n32
-
b
.
n14
*
b
.
n22
*
b
.
n33
+
b
.
n12
*
b
.
n24
*
b
.
n33
+
b
.
n13
*
b
.
n22
*
b
.
n34
-
b
.
n12
*
b
.
n23
*
b
.
n34
;
a
.
n21
=
b
.
n24
*
b
.
n33
*
b
.
n41
-
b
.
n23
*
b
.
n34
*
b
.
n41
-
b
.
n24
*
b
.
n31
*
b
.
n43
+
b
.
n21
*
b
.
n34
*
b
.
n43
+
b
.
n23
*
b
.
n31
*
b
.
n44
-
b
.
n21
*
b
.
n33
*
b
.
n44
;
a
.
n22
=
b
.
n13
*
b
.
n34
*
b
.
n41
-
b
.
n14
*
b
.
n33
*
b
.
n41
+
b
.
n14
*
b
.
n31
*
b
.
n43
-
b
.
n11
*
b
.
n34
*
b
.
n43
-
b
.
n13
*
b
.
n31
*
b
.
n44
+
b
.
n11
*
b
.
n33
*
b
.
n44
;
a
.
n23
=
b
.
n14
*
b
.
n23
*
b
.
n41
-
b
.
n13
*
b
.
n24
*
b
.
n41
-
b
.
n14
*
b
.
n21
*
b
.
n43
+
b
.
n11
*
b
.
n24
*
b
.
n43
+
b
.
n13
*
b
.
n21
*
b
.
n44
-
b
.
n11
*
b
.
n23
*
b
.
n44
;
a
.
n24
=
b
.
n13
*
b
.
n24
*
b
.
n31
-
b
.
n14
*
b
.
n23
*
b
.
n31
+
b
.
n14
*
b
.
n21
*
b
.
n33
-
b
.
n11
*
b
.
n24
*
b
.
n33
-
b
.
n13
*
b
.
n21
*
b
.
n34
+
b
.
n11
*
b
.
n23
*
b
.
n34
;
a
.
n31
=
b
.
n22
*
b
.
n34
*
b
.
n41
-
b
.
n24
*
b
.
n32
*
b
.
n41
+
b
.
n24
*
b
.
n31
*
b
.
n42
-
b
.
n21
*
b
.
n34
*
b
.
n42
-
b
.
n22
*
b
.
n31
*
b
.
n44
+
b
.
n21
*
b
.
n32
*
b
.
n44
;
a
.
n32
=
b
.
n14
*
b
.
n32
*
b
.
n41
-
b
.
n12
*
b
.
n34
*
b
.
n41
-
b
.
n14
*
b
.
n31
*
b
.
n42
+
b
.
n11
*
b
.
n34
*
b
.
n42
+
b
.
n12
*
b
.
n31
*
b
.
n44
-
b
.
n11
*
b
.
n32
*
b
.
n44
;
a
.
n33
=
b
.
n13
*
b
.
n24
*
b
.
n41
-
b
.
n14
*
b
.
n22
*
b
.
n41
+
b
.
n14
*
b
.
n21
*
b
.
n42
-
b
.
n11
*
b
.
n24
*
b
.
n42
-
b
.
n12
*
b
.
n21
*
b
.
n44
+
b
.
n11
*
b
.
n22
*
b
.
n44
;
a
.
n34
=
b
.
n14
*
b
.
n22
*
b
.
n31
-
b
.
n12
*
b
.
n24
*
b
.
n31
-
b
.
n14
*
b
.
n21
*
b
.
n32
+
b
.
n11
*
b
.
n24
*
b
.
n32
+
b
.
n12
*
b
.
n21
*
b
.
n34
-
b
.
n11
*
b
.
n22
*
b
.
n34
;
a
.
n41
=
b
.
n23
*
b
.
n32
*
b
.
n41
-
b
.
n22
*
b
.
n33
*
b
.
n41
-
b
.
n23
*
b
.
n31
*
b
.
n42
+
b
.
n21
*
b
.
n33
*
b
.
n42
+
b
.
n22
*
b
.
n31
*
b
.
n43
-
b
.
n21
*
b
.
n32
*
b
.
n43
;
a
.
n42
=
b
.
n12
*
b
.
n33
*
b
.
n41
-
b
.
n13
*
b
.
n32
*
b
.
n41
+
b
.
n13
*
b
.
n31
*
b
.
n42
-
b
.
n11
*
b
.
n33
*
b
.
n42
-
b
.
n12
*
b
.
n31
*
b
.
n43
+
b
.
n11
*
b
.
n32
*
b
.
n43
;
a
.
n43
=
b
.
n13
*
b
.
n22
*
b
.
n41
-
b
.
n12
*
b
.
n23
*
b
.
n41
-
b
.
n13
*
b
.
n21
*
b
.
n42
+
b
.
n11
*
b
.
n23
*
b
.
n42
+
b
.
n12
*
b
.
n21
*
b
.
n43
-
b
.
n11
*
b
.
n22
*
b
.
n43
;
a
.
n44
=
b
.
n12
*
b
.
n23
*
b
.
n31
-
b
.
n13
*
b
.
n22
*
b
.
n31
+
b
.
n13
*
b
.
n21
*
b
.
n32
-
b
.
n11
*
b
.
n23
*
b
.
n32
-
b
.
n12
*
b
.
n21
*
b
.
n33
+
b
.
n11
*
b
.
n22
*
b
.
n33
;
a
.
multiplyScalar
(
1
/
b
.
determinant
());
return
a
};
THREE
.
Matrix4
.
makeInvert3x3
=
function
(
o
){
var
e
=
o
.
flatten
(),
l
=
new
THREE
.
Matrix3
(),
n
=
e
[
10
]
*
e
[
5
]
-
e
[
6
]
*
e
[
9
],
i
=-
e
[
10
]
*
e
[
1
]
+
e
[
2
]
*
e
[
9
],
d
=
e
[
6
]
*
e
[
1
]
-
e
[
2
]
*
e
[
5
],
k
=-
e
[
10
]
*
e
[
4
]
+
e
[
6
]
*
e
[
8
],
g
=
e
[
10
]
*
e
[
0
]
-
e
[
2
]
*
e
[
8
],
c
=-
e
[
6
]
*
e
[
0
]
+
e
[
2
]
*
e
[
4
],
j
=
e
[
9
]
*
e
[
4
]
-
e
[
5
]
*
e
[
8
],
f
=-
e
[
9
]
*
e
[
0
]
+
e
[
1
]
*
e
[
8
],
a
=
e
[
5
]
*
e
[
0
]
-
e
[
1
]
*
e
[
4
],
h
=
e
[
0
]
*
(
n
)
+
e
[
1
]
*
(
k
)
+
e
[
2
]
*
(
j
),
b
;
if
(
h
==
0
){
throw
"
matrix not invertible
"
}
b
=
1
/
h
;
l
.
m
[
0
]
=
b
*
n
;
l
.
m
[
1
]
=
b
*
i
;
l
.
m
[
2
]
=
b
*
d
;
l
.
m
[
3
]
=
b
*
k
;
l
.
m
[
4
]
=
b
*
g
;
l
.
m
[
5
]
=
b
*
c
;
l
.
m
[
6
]
=
b
*
j
;
l
.
m
[
7
]
=
b
*
f
;
l
.
m
[
8
]
=
b
*
a
;
return
l
};
THREE
.
Matrix4
.
makeFrustum
=
function
(
f
,
r
,
e
,
o
,
i
,
h
){
var
g
,
q
,
n
,
p
,
l
,
k
,
j
;
g
=
new
THREE
.
Matrix4
();
q
=
2
*
i
/
(
r
-
f
);
n
=
2
*
i
/
(
o
-
e
);
p
=
(
r
+
f
)
/
(
r
-
f
);
l
=
(
o
+
e
)
/
(
o
-
e
);
k
=-
(
h
+
i
)
/
(
h
-
i
);
j
=-
2
*
h
*
i
/
(
h
-
i
);
g
.
n11
=
q
;
g
.
n12
=
0
;
g
.
n13
=
p
;
g
.
n14
=
0
;
g
.
n21
=
0
;
g
.
n22
=
n
;
g
.
n23
=
l
;
g
.
n24
=
0
;
g
.
n31
=
0
;
g
.
n32
=
0
;
g
.
n33
=
k
;
g
.
n34
=
j
;
g
.
n41
=
0
;
g
.
n42
=
0
;
g
.
n43
=-
1
;
g
.
n44
=
0
;
return
g
};
THREE
.
Matrix4
.
makePerspective
=
function
(
e
,
c
,
g
,
b
){
var
a
,
f
,
h
,
d
;
a
=
g
*
Math
.
tan
(
e
*
Math
.
PI
/
360
);
f
=-
a
;
h
=
f
*
c
;
d
=
a
*
c
;
return
THREE
.
Matrix4
.
makeFrustum
(
h
,
d
,
f
,
a
,
g
,
b
)};
THREE
.
Matrix4
.
makeOrtho
=
function
(
c
,
o
,
k
,
a
,
g
,
f
){
var
d
,
l
,
j
,
i
,
n
,
e
,
b
;
d
=
new
THREE
.
Matrix4
();
n
=
o
-
c
;
e
=
k
-
a
;
b
=
f
-
g
;
l
=
(
o
+
c
)
/
n
;
j
=
(
k
+
a
)
/
e
;
i
=
(
f
+
g
)
/
b
;
d
.
n11
=
2
/
n
;
d
.
n12
=
0
;
d
.
n13
=
0
;
d
.
n14
=-
l
;
d
.
n21
=
0
;
d
.
n22
=
2
/
e
;
d
.
n23
=
0
;
d
.
n24
=-
j
;
d
.
n31
=
0
;
d
.
n32
=
0
;
d
.
n33
=-
2
/
b
;
d
.
n34
=-
i
;
d
.
n41
=
0
;
d
.
n42
=
0
;
d
.
n43
=
0
;
d
.
n44
=
1
;
return
d
};
THREE
.
Vertex
=
function
(
a
,
b
){
this
.
position
=
a
||
new
THREE
.
Vector3
();
this
.
positionWorld
=
new
THREE
.
Vector3
();
this
.
positionScreen
=
new
THREE
.
Vector3
();
this
.
normal
=
b
||
new
THREE
.
Vector3
();
this
.
normalWorld
=
new
THREE
.
Vector3
();
this
.
normalScreen
=
new
THREE
.
Vector3
();
this
.
__visible
=
true
};
THREE
.
Vertex
.
prototype
=
{
toString
:
function
(){
return
"
THREE.Vertex ( position:
"
+
this
.
position
+
"
, normal:
"
+
this
.
normal
+
"
)
"
}};
THREE
.
Face3
=
function
(
e
,
d
,
h
,
g
,
f
){
this
.
a
=
e
;
this
.
b
=
d
;
this
.
c
=
h
;
this
.
centroid
=
new
THREE
.
Vector3
();
this
.
normal
=
g
instanceof
THREE
.
Vector3
?
g
:
new
THREE
.
Vector3
();
this
.
vertexNormals
=
g
instanceof
Array
?
g
:[];
this
.
material
=
f
instanceof
Array
?
f
:[
f
]};
THREE
.
Face3
.
prototype
=
{
toString
:
function
(){
return
"
THREE.Face3 (
"
+
this
.
a
+
"
,
"
+
this
.
b
+
"
,
"
+
this
.
c
+
"
)
"
}};
THREE
.
Face4
=
function
(
f
,
e
,
j
,
i
,
h
,
g
){
this
.
a
=
f
;
this
.
b
=
e
;
this
.
c
=
j
;
this
.
d
=
i
;
this
.
centroid
=
new
THREE
.
Vector3
();
this
.
normal
=
h
instanceof
THREE
.
Vector3
?
h
:
new
THREE
.
Vector3
();
this
.
vertexNormals
=
h
instanceof
Array
?
h
:[];
this
.
material
=
g
instanceof
Array
?
g
:[
g
]};
THREE
.
Face4
.
prototype
=
{
toString
:
function
(){
return
"
THREE.Face4 (
"
+
this
.
a
+
"
,
"
+
this
.
b
+
"
,
"
+
this
.
c
+
"
"
+
this
.
d
+
"
)
"
}};
THREE
.
UV
=
function
(
b
,
a
){
this
.
u
=
b
||
0
;
this
.
v
=
a
||
0
};
THREE
.
UV
.
prototype
=
{
copy
:
function
(
a
){
this
.
u
=
a
.
u
;
this
.
v
=
a
.
v
},
toString
:
function
(){
return
"
THREE.UV (
"
+
this
.
u
+
"
,
"
+
this
.
v
+
"
)
"
}};
THREE
.
Geometry
=
function
(){
this
.
vertices
=
[];
this
.
faces
=
[];
this
.
uvs
=
[]};
THREE
.
Geometry
.
prototype
=
{
computeCentroids
:
function
(){
var
c
,
b
,
a
;
for
(
c
=
0
,
b
=
this
.
faces
.
length
;
c
<
b
;
c
++
){
a
=
this
.
faces
[
c
];
a
.
centroid
.
set
(
0
,
0
,
0
);
if
(
a
instanceof
THREE
.
Face3
){
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
a
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
b
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
c
].
position
);
a
.
centroid
.
divideScalar
(
3
)}
else
{
if
(
a
instanceof
THREE
.
Face4
){
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
a
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
b
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
c
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
d
].
position
);
a
.
centroid
.
divideScalar
(
4
)}}}},
computeNormals
:
function
(
m
){
var
e
,
b
,
o
,
g
,
i
,
j
,
l
,
k
,
d
,
c
,
a
,
h
=
new
THREE
.
Vector3
(),
p
=
new
THREE
.
Vector3
();
for
(
o
=
0
,
g
=
this
.
vertices
.
length
;
o
<
g
;
o
++
){
i
=
this
.
vertices
[
o
];
i
.
normal
.
set
(
0
,
0
,
0
)}
for
(
j
=
0
,
l
=
this
.
faces
.
length
;
j
<
l
;
j
++
){
k
=
this
.
faces
[
j
];
if
(
m
&&
k
.
vertexNormals
.
length
){
h
.
set
(
0
,
0
,
0
);
for
(
e
=
0
,
b
=
k
.
normal
.
length
;
e
<
b
;
e
++
){
h
.
addSelf
(
k
.
vertexNormals
[
e
])}
h
.
divideScalar
(
3
);
if
(
!
h
.
isZero
()){
h
.
normalize
()}
k
.
normal
.
copy
(
h
)}
else
{
d
=
this
.
vertices
[
k
.
a
];
c
=
this
.
vertices
[
k
.
b
];
a
=
this
.
vertices
[
k
.
c
];
h
.
sub
(
a
.
position
,
c
.
position
);
p
.
sub
(
d
.
position
,
c
.
position
);
h
.
crossSelf
(
p
);
if
(
!
h
.
isZero
()){
h
.
normalize
()}
k
.
normal
.
copy
(
h
)}}},
computeBoundingBox
:
function
(){
if
(
this
.
vertices
.
length
>
0
){
this
.
bbox
=
{
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
a
=
1
,
b
=
this
.
vertices
.
length
;
a
<
b
;
a
++
){
vertex
=
this
.
vertices
[
a
];
if
(
vertex
.
position
.
x
<
this
.
bbox
.
x
[
0
]){
this
.
bbox
.
x
[
0
]
=
vertex
.
position
.
x
}
else
{
if
(
vertex
.
position
.
x
>
this
.
bbox
.
x
[
1
]){
this
.
bbox
.
x
[
1
]
=
vertex
.
position
.
x
}}
if
(
vertex
.
position
.
y
<
this
.
bbox
.
y
[
0
]){
this
.
bbox
.
y
[
0
]
=
vertex
.
position
.
y
}
else
{
if
(
vertex
.
position
.
y
>
this
.
bbox
.
y
[
1
]){
this
.
bbox
.
y
[
1
]
=
vertex
.
position
.
y
}}
if
(
vertex
.
position
.
z
<
this
.
bbox
.
z
[
0
]){
this
.
bbox
.
z
[
0
]
=
vertex
.
position
.
z
}
else
{
if
(
vertex
.
position
.
z
>
this
.
bbox
.
z
[
1
]){
this
.
bbox
.
z
[
1
]
=
vertex
.
position
.
z
}}}}},
toString
:
function
(){
return
"
THREE.Geometry ( vertices:
"
+
this
.
vertices
+
"
, faces:
"
+
this
.
faces
+
"
)
"
}};
THREE
.
Camera
=
function
(
c
,
b
,
d
,
a
){
this
.
position
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
this
.
target
=
{
position
:
new
THREE
.
Vector3
(
0
,
0
,
0
)};
this
.
up
=
new
THREE
.
Vector3
(
0
,
1
,
0
);
this
.
matrix
=
new
THREE
.
Matrix4
();
this
.
projectionMatrix
=
THREE
.
Matrix4
.
makePerspective
(
c
,
b
,
d
,
a
);
this
.
autoUpdateMatrix
=
true
;
this
.
updateMatrix
=
function
(){
this
.
matrix
.
lookAt
(
this
.
position
,
this
.
target
.
position
,
this
.
up
)};
this
.
toString
=
function
(){
return
"
THREE.Camera (
"
+
this
.
position
+
"
,
"
+
this
.
target
.
position
+
"
)
"
}};
THREE
.
Loader
=
function
(){};
THREE
.
Loader
.
prototype
=
{
loadAsciiOld
:
function
(
a
,
c
){
var
b
=
document
.
createElement
(
"
script
"
);
b
.
type
=
"
text/javascript
"
;
b
.
onload
=
c
;
b
.
src
=
a
;
document
.
getElementsByTagName
(
"
head
"
)[
0
].
appendChild
(
b
)},
loadAscii
:
function
(
a
,
e
,
b
){
var
c
=
(
new
Date
).
getTime
(),
d
=
new
Worker
(
a
);
d
.
onmessage
=
function
(
f
){
THREE
.
Loader
.
prototype
.
createModel
(
f
.
data
,
e
,
b
)};
d
.
postMessage
(
c
)},
loadBinary
:
function
(
a
,
e
,
b
){
var
c
=
(
new
Date
).
getTime
(),
d
=
new
Worker
(
a
);
d
.
onmessage
=
function
(
h
){
var
g
=
h
.
data
.
materials
,
f
=
h
.
data
.
buffers
;
THREE
.
Loader
.
prototype
.
loadAjaxBuffers
(
f
,
g
,
e
,
b
)};
d
.
onerror
=
function
(
f
){
alert
(
"
worker.onerror:
"
+
f
.
message
+
"
\n
"
+
f
.
data
);
f
.
preventDefault
()};
d
.
postMessage
(
c
)},
loadAjaxBuffers
:
function
(
b
,
a
,
f
,
d
){
var
e
=
new
XMLHttpRequest
(),
c
=
d
+
"
/
"
+
b
;
e
.
onreadystatechange
=
function
(){
if
(
e
.
readyState
==
4
){
if
(
e
.
status
==
200
||
e
.
status
==
0
){
THREE
.
Loader
.
prototype
.
createBinModel
(
e
.
responseText
,
f
,
d
,
a
)}
else
{
alert
(
"
Couldn't load [
"
+
c
+
"
] [
"
+
e
.
status
+
"
]
"
)}}};
e
.
open
(
"
GET
"
,
c
,
true
);
e
.
overrideMimeType
(
"
text/plain; charset=x-user-defined
"
);
e
.
setRequestHeader
(
"
Content-Type
"
,
"
text/plain
"
);
e
.
send
(
null
)},
createBinModel
:
function
(
c
,
e
,
b
,
a
){
var
d
=
function
(
aa
){
var
I
=
this
,
h
=
0
,
x
,
A
=
[],
L
=
[],
V
,
T
,
O
,
U
,
R
,
P
,
D
,
C
,
B
,
y
,
r
,
q
,
p
,
o
,
u
,
t
,
N
,
K
,
J
;
THREE
.
Geometry
.
call
(
this
);
THREE
.
Loader
.
prototype
.
init_materials
(
I
,
a
,
aa
);
x
=
W
(
c
,
h
);
h
+=
x
.
header_bytes
;
V
=
x
.
vertex_index_bytes
,
T
=
x
.
vertex_index_bytes
*
2
,
O
=
x
.
vertex_index_bytes
*
3
,
U
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
,
R
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
,
P
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
2
,
D
=
x
.
vertex_index_bytes
,
C
=
x
.
vertex_index_bytes
*
2
,
B
=
x
.
vertex_index_bytes
*
3
,
y
=
x
.
vertex_index_bytes
*
4
,
r
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
,
q
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
,
p
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
2
,
o
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
3
,
u
=
x
.
uv_index_bytes
,
t
=
x
.
uv_index_bytes
*
2
,
N
=
x
.
uv_index_bytes
,
K
=
x
.
uv_index_bytes
*
2
,
J
=
x
.
uv_index_bytes
*
3
;
h
+=
w
(
h
);
h
+=
H
(
h
);
h
+=
G
(
h
);
h
+=
Q
(
h
);
h
+=
S
(
h
);
h
+=
ab
(
h
);
h
+=
n
(
h
);
h
+=
g
(
h
);
h
+=
k
(
h
);
h
+=
s
(
h
);
h
+=
z
(
h
);
this
.
computeCentroids
();
this
.
computeNormals
();
function
W
(
ad
,
ae
){
var
ac
=
{
signature
:
F
(
ad
,
ae
,
8
),
header_bytes
:
j
(
ad
,
ae
+
8
),
vertex_coordinate_bytes
:
j
(
ad
,
ae
+
9
),
normal_coordinate_bytes
:
j
(
ad
,
ae
+
10
),
uv_coordinate_bytes
:
j
(
ad
,
ae
+
11
),
vertex_index_bytes
:
j
(
ad
,
ae
+
12
),
normal_index_bytes
:
j
(
ad
,
ae
+
13
),
uv_index_bytes
:
j
(
ad
,
ae
+
14
),
material_index_bytes
:
j
(
ad
,
ae
+
15
),
nvertices
:
v
(
ad
,
ae
+
16
),
nnormals
:
v
(
ad
,
ae
+
16
+
4
*
1
),
nuvs
:
v
(
ad
,
ae
+
16
+
4
*
2
),
ntri_flat
:
v
(
ad
,
ae
+
16
+
4
*
3
),
ntri_smooth
:
v
(
ad
,
ae
+
16
+
4
*
4
),
ntri_flat_uv
:
v
(
ad
,
ae
+
16
+
4
*
5
),
ntri_smooth_uv
:
v
(
ad
,
ae
+
16
+
4
*
6
),
nquad_flat
:
v
(
ad
,
ae
+
16
+
4
*
7
),
nquad_smooth
:
v
(
ad
,
ae
+
16
+
4
*
8
),
nquad_flat_uv
:
v
(
ad
,
ae
+
16
+
4
*
9
),
nquad_smooth_uv
:
v
(
ad
,
ae
+
16
+
4
*
10
)};
return
ac
}
function
F
(
ad
,
ae
,
ac
){
return
ad
.
substr
(
ae
,
ac
)}
function
f
(
af
,
ae
){
var
ag
=
j
(
af
,
ae
),
ai
=
j
(
af
,
ae
+
1
),
aj
=
j
(
af
,
ae
+
2
),
ak
=
j
(
af
,
ae
+
3
),
ad
=
1
-
(
2
*
(
ak
>>
7
)),
ah
=
(((
ak
<<
1
)
&
255
)
|
(
aj
>>
7
))
-
127
,
ac
=
((
aj
&
127
)
<<
16
)
|
(
ai
<<
8
)
|
ag
;
if
(
ac
==
0
&&
ah
==-
127
){
return
0
}
return
ad
*
(
1
+
ac
*
Math
.
pow
(
2
,
-
23
))
*
Math
.
pow
(
2
,
ah
)}
function
v
(
ag
,
ah
){
var
af
=
j
(
ag
,
ah
),
ae
=
j
(
ag
,
ah
+
1
),
ad
=
j
(
ag
,
ah
+
2
),
ac
=
j
(
ag
,
ah
+
3
);
return
(
ac
<<
24
)
+
(
ad
<<
16
)
+
(
ae
<<
8
)
+
af
}
function
Z
(
ae
,
af
){
var
ad
=
j
(
ae
,
af
),
ac
=
j
(
ae
,
af
+
1
);
return
(
ac
<<
8
)
+
ad
}
function
i
(
ad
,
ae
){
var
ac
=
j
(
ad
,
ae
);
return
ac
>
127
?
ac
-
256
:
ac
}
function
j
(
ac
,
ad
){
return
ac
.
charCodeAt
(
ad
)
&
255
}
function
w
(
ai
){
var
ae
,
ac
,
ah
,
ag
,
af
=
x
.
vertex_coordinate_bytes
*
3
,
ad
=
ai
+
x
.
nvertices
*
af
;
for
(
ae
=
ai
;
ae
<
ad
;
ae
+=
af
){
ac
=
f
(
c
,
ae
);
ah
=
f
(
c
,
ae
+
x
.
vertex_coordinate_bytes
);
ag
=
f
(
c
,
ae
+
x
.
vertex_coordinate_bytes
*
2
);
THREE
.
Loader
.
prototype
.
v
(
I
,
ac
,
ah
,
ag
)}
return
x
.
nvertices
*
af
}
function
H
(
ai
){
var
ae
,
ac
,
ah
,
ag
,
af
=
x
.
normal_coordinate_bytes
*
3
,
ad
=
ai
+
x
.
nnormals
*
af
;
for
(
ae
=
ai
;
ae
<
ad
;
ae
+=
af
){
ac
=
i
(
c
,
ae
);
ah
=
i
(
c
,
ae
+
x
.
normal_coordinate_bytes
);
ag
=
i
(
c
,
ae
+
x
.
normal_coordinate_bytes
*
2
);
A
.
push
(
ac
/
127
,
ah
/
127
,
ag
/
127
)}
return
x
.
nnormals
*
af
}
function
G
(
ah
){
var
af
,
ae
,
ad
,
ag
=
x
.
uv_coordinate_bytes
*
2
,
ac
=
ah
+
x
.
nuvs
*
ag
;
for
(
af
=
ah
;
af
<
ac
;
af
+=
ag
){
ae
=
f
(
c
,
af
);
ad
=
f
(
c
,
af
+
x
.
uv_coordinate_bytes
);
L
.
push
(
ae
,
ad
)}
return
x
.
nuvs
*
ag
}
function
M
(
af
){
var
ae
,
ad
,
ag
,
ac
;
ae
=
v
(
c
,
af
);
ad
=
v
(
c
,
af
+
V
);
ag
=
v
(
c
,
af
+
T
);
ac
=
Z
(
c
,
af
+
O
);
THREE
.
Loader
.
prototype
.
f3
(
I
,
ae
,
ad
,
ag
,
ac
)}
function
m
(
ah
){
var
ag
,
ae
,
aj
,
ad
,
af
,
ac
,
ai
;
ag
=
v
(
c
,
ah
);
ae
=
v
(
c
,
ah
+
V
);
aj
=
v
(
c
,
ah
+
T
);
ad
=
Z
(
c
,
ah
+
O
);
af
=
v
(
c
,
ah
+
U
);
ac
=
v
(
c
,
ah
+
R
);
ai
=
v
(
c
,
ah
+
P
);
THREE
.
Loader
.
prototype
.
f3n
(
I
,
A
,
ag
,
ae
,
aj
,
ad
,
af
,
ac
,
ai
)}
function
E
(
af
){
var
ae
,
ad
,
ah
,
ag
,
ac
;
ae
=
v
(
c
,
af
);
ad
=
v
(
c
,
af
+
D
);
ah
=
v
(
c
,
af
+
C
);
ag
=
v
(
c
,
af
+
B
);
ac
=
Z
(
c
,
af
+
y
);
THREE
.
Loader
.
prototype
.
f4
(
I
,
ae
,
ad
,
ah
,
ag
,
ac
)}
function
l
(
af
){
var
al
,
ak
,
aj
,
ai
,
ac
,
ah
,
ag
,
ae
,
ad
;
al
=
v
(
c
,
af
);
ak
=
v
(
c
,
af
+
D
);
aj
=
v
(
c
,
af
+
C
);
ai
=
v
(
c
,
af
+
B
);
ac
=
Z
(
c
,
af
+
y
);
ah
=
v
(
c
,
af
+
r
);
ag
=
v
(
c
,
af
+
q
);
ae
=
v
(
c
,
af
+
p
);
ad
=
v
(
c
,
af
+
o
);
THREE
.
Loader
.
prototype
.
f4n
(
I
,
A
,
al
,
ak
,
aj
,
ai
,
ac
,
ah
,
ag
,
ae
,
ad
)}
function
Y
(
ai
){
var
ah
,
ae
,
ac
,
ag
,
af
,
ad
,
al
,
ak
,
aj
;
ah
=
v
(
c
,
ai
);
ae
=
v
(
c
,
ai
+
u
);
ac
=
v
(
c
,
ai
+
t
);
ag
=
L
[
ah
*
2
];
al
=
L
[
ah
*
2
+
1
];
af
=
L
[
ae
*
2
];
ak
=
L
[
ae
*
2
+
1
];
ad
=
L
[
ac
*
2
];
aj
=
L
[
ac
*
2
+
1
];
THREE
.
Loader
.
prototype
.
uv
(
I
,
ag
,
al
,
af
,
ak
,
ad
,
aj
)}
function
X
(
ak
){
var
aj
,
ag
,
ae
,
ad
,
ai
,
ah
,
af
,
ac
,
ao
,
an
,
am
,
al
;
aj
=
v
(
c
,
ak
);
ag
=
v
(
c
,
ak
+
N
);
ae
=
v
(
c
,
ak
+
K
);
ad
=
v
(
c
,
ak
+
J
);
ai
=
L
[
aj
*
2
];
ao
=
L
[
aj
*
2
+
1
];
ah
=
L
[
ag
*
2
];
an
=
L
[
ag
*
2
+
1
];
af
=
L
[
ae
*
2
];
am
=
L
[
ae
*
2
+
1
];
ac
=
L
[
ad
*
2
];
al
=
L
[
ad
*
2
+
1
];
THREE
.
Loader
.
prototype
.
uv
(
I
,
ai
,
ao
,
ah
,
an
,
af
,
am
,
ac
,
al
)}
function
Q
(
af
){
var
ad
,
ae
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
,
ac
=
af
+
x
.
ntri_flat
*
ae
;
for
(
ad
=
af
;
ad
<
ac
;
ad
+=
ae
){
M
(
ad
)}
return
ac
-
af
}
function
ab
(
ag
){
var
ad
,
af
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
,
ae
=
af
+
x
.
uv_index_bytes
*
3
,
ac
=
ag
+
x
.
ntri_flat_uv
*
ae
;
for
(
ad
=
ag
;
ad
<
ac
;
ad
+=
ae
){
M
(
ad
);
Y
(
ad
+
af
)}
return
ac
-
ag
}
function
S
(
af
){
var
ad
,
ae
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
3
,
ac
=
af
+
x
.
ntri_smooth
*
ae
;
for
(
ad
=
af
;
ad
<
ac
;
ad
+=
ae
){
m
(
ad
)}
return
ac
-
af
}
function
n
(
ag
){
var
ad
,
af
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
3
,
ae
=
af
+
x
.
uv_index_bytes
*
3
,
ac
=
ag
+
x
.
ntri_smooth_uv
*
ae
;
for
(
ad
=
ag
;
ad
<
ac
;
ad
+=
ae
){
m
(
ad
);
Y
(
ad
+
af
)}
return
ac
-
ag
}
function
g
(
af
){
var
ad
,
ae
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
,
ac
=
af
+
x
.
nquad_flat
*
ae
;
for
(
ad
=
af
;
ad
<
ac
;
ad
+=
ae
){
E
(
ad
)}
return
ac
-
af
}
function
s
(
ag
){
var
ad
,
af
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
,
ae
=
af
+
x
.
uv_index_bytes
*
4
,
ac
=
ag
+
x
.
nquad_flat_uv
*
ae
;
for
(
ad
=
ag
;
ad
<
ac
;
ad
+=
ae
){
E
(
ad
);
X
(
ad
+
af
)}
return
ac
-
ag
}
function
k
(
af
){
var
ad
,
ae
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
4
,
ac
=
af
+
x
.
nquad_smooth
*
ae
;
for
(
ad
=
af
;
ad
<
ac
;
ad
+=
ae
){
l
(
ad
)}
return
ac
-
af
}
function
z
(
ag
){
var
ad
,
af
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
4
,
ae
=
af
+
x
.
uv_index_bytes
*
4
,
ac
=
ag
+
x
.
nquad_smooth_uv
*
ae
;
for
(
ad
=
ag
;
ad
<
ac
;
ad
+=
ae
){
l
(
ad
);
X
(
ad
+
af
)}
return
ac
-
ag
}};
d
.
prototype
=
new
THREE
.
Geometry
();
d
.
prototype
.
constructor
=
d
;
e
(
new
d
(
b
))},
createModel
:
function
(
b
,
d
,
a
){
var
c
=
function
(
f
){
var
g
=
this
;
THREE
.
Geometry
.
call
(
this
);
THREE
.
Loader
.
prototype
.
init_materials
(
g
,
b
.
materials
,
f
);
e
();
h
();
this
.
computeCentroids
();
this
.
computeNormals
();
function
e
(){
var
m
,
k
,
j
,
o
,
n
;
for
(
m
=
0
,
k
=
b
.
vertices
.
length
;
m
<
k
;
m
+=
3
){
j
=
b
.
vertices
[
m
];
o
=
b
.
vertices
[
m
+
1
];
n
=
b
.
vertices
[
m
+
2
];
THREE
.
Loader
.
prototype
.
v
(
g
,
j
,
o
,
n
)}}
function
h
(){
function
p
(
v
,
u
){
var
t
,
s
,
w
,
l
;
t
=
v
[
u
];
s
=
v
[
u
+
1
];
w
=
v
[
u
+
2
];
l
=
v
[
u
+
3
];
THREE
.
Loader
.
prototype
.
f3
(
g
,
t
,
s
,
w
,
l
)}
function
k
(
l
,
u
){
var
z
,
y
,
x
,
s
,
w
,
v
,
t
;
z
=
l
[
u
];
y
=
l
[
u
+
1
];
x
=
l
[
u
+
2
];
s
=
l
[
u
+
3
];
w
=
l
[
u
+
4
];
v
=
l
[
u
+
5
];
t
=
l
[
u
+
6
];
THREE
.
Loader
.
prototype
.
f3n
(
g
,
b
.
normals
,
z
,
y
,
x
,
s
,
w
,
v
,
t
)}
function
o
(
w
,
u
){
var
t
,
s
,
x
,
v
,
l
;
t
=
w
[
u
];
s
=
w
[
u
+
1
];
x
=
w
[
u
+
2
];
v
=
w
[
u
+
3
];
l
=
w
[
u
+
4
];
THREE
.
Loader
.
prototype
.
f4
(
g
,
t
,
s
,
x
,
v
,
l
)}
function
j
(
l
,
v
){
var
B
,
A
,
z
,
y
,
s
,
x
,
w
,
u
,
t
;
B
=
l
[
v
];
A
=
l
[
v
+
1
];
z
=
l
[
v
+
2
];
y
=
l
[
v
+
3
];
s
=
l
[
v
+
4
];
x
=
l
[
v
+
5
];
w
=
l
[
v
+
6
];
u
=
l
[
v
+
7
];
t
=
l
[
v
+
8
];
THREE
.
Loader
.
prototype
.
f4n
(
g
,
b
.
normals
,
B
,
A
,
z
,
y
,
s
,
x
,
w
,
u
,
t
)}
function
r
(
l
,
y
){
var
x
,
u
,
s
,
w
,
v
,
t
,
B
,
A
,
z
;
x
=
l
[
y
];
u
=
l
[
y
+
1
];
s
=
l
[
y
+
2
];
w
=
b
.
uvs
[
x
*
2
];
B
=
b
.
uvs
[
x
*
2
+
1
];
v
=
b
.
uvs
[
u
*
2
];
A
=
b
.
uvs
[
u
*
2
+
1
];
t
=
b
.
uvs
[
s
*
2
];
z
=
b
.
uvs
[
s
*
2
+
1
];
THREE
.
Loader
.
prototype
.
uv
(
g
,
w
,
B
,
v
,
A
,
t
,
z
)}
function
q
(
s
,
A
){
var
z
,
w
,
v
,
t
,
y
,
x
,
u
,
l
,
E
,
D
,
C
,
B
;
z
=
s
[
A
];
w
=
s
[
A
+
1
];
v
=
s
[
A
+
2
];
t
=
s
[
A
+
3
];
y
=
b
.
uvs
[
z
*
2
];
E
=
b
.
uvs
[
z
*
2
+
1
];
x
=
b
.
uvs
[
w
*
2
];
D
=
b
.
uvs
[
w
*
2
+
1
];
u
=
b
.
uvs
[
v
*
2
];
C
=
b
.
uvs
[
v
*
2
+
1
];
l
=
b
.
uvs
[
t
*
2
];
B
=
b
.
uvs
[
t
*
2
+
1
];
THREE
.
Loader
.
prototype
.
uv
(
g
,
y
,
E
,
x
,
D
,
u
,
C
,
l
,
B
)}
var
n
,
m
;
for
(
n
=
0
,
m
=
b
.
triangles
.
length
;
n
<
m
;
n
+=
4
){
p
(
b
.
triangles
,
n
)}
for
(
n
=
0
,
m
=
b
.
triangles_uv
.
length
;
n
<
m
;
n
+=
7
){
p
(
b
.
triangles_uv
,
n
);
r
(
b
.
triangles_uv
,
n
+
4
)}
for
(
n
=
0
,
m
=
b
.
triangles_n
.
length
;
n
<
m
;
n
+=
7
){
k
(
b
.
triangles_n
,
n
)}
for
(
n
=
0
,
m
=
b
.
triangles_n_uv
.
length
;
n
<
m
;
n
+=
10
){
k
(
b
.
triangles_n_uv
,
n
);
r
(
b
.
triangles_n_uv
,
n
+
7
)}
for
(
n
=
0
,
m
=
b
.
quads
.
length
;
n
<
m
;
n
+=
5
){
o
(
b
.
quads
,
n
)}
for
(
n
=
0
,
m
=
b
.
quads_uv
.
length
;
n
<
m
;
n
+=
9
){
o
(
b
.
quads_uv
,
n
);
q
(
b
.
quads_uv
,
n
+
5
)}
for
(
n
=
0
,
m
=
b
.
quads_n
.
length
;
n
<
m
;
n
+=
9
){
j
(
b
.
quads_n
,
n
)}
for
(
n
=
0
,
m
=
b
.
quads_n_uv
.
length
;
n
<
m
;
n
+=
13
){
j
(
b
.
quads_n_uv
,
n
);
q
(
b
.
quads_n_uv
,
n
+
9
)}}};
c
.
prototype
=
new
THREE
.
Geometry
();
c
.
prototype
.
constructor
=
c
;
d
(
new
c
(
a
))},
v
:
function
(
b
,
a
,
d
,
c
){
b
.
vertices
.
push
(
new
THREE
.
Vertex
(
new
THREE
.
Vector3
(
a
,
d
,
c
)))},
f3
:
function
(
h
,
e
,
d
,
i
,
f
){
var
g
=
h
.
materials
[
f
];
h
.
faces
.
push
(
new
THREE
.
Face3
(
e
,
d
,
i
,
null
,
g
))},
f4
:
function
(
i
,
f
,
e
,
k
,
j
,
g
){
var
h
=
i
.
materials
[
g
];
i
.
faces
.
push
(
new
THREE
.
Face4
(
f
,
e
,
k
,
j
,
null
,
h
))},
f3n
:
function
(
d
,
l
,
s
,
r
,
q
,
p
,
j
,
i
,
h
){
var
k
=
d
.
materials
[
p
],
g
=
l
[
j
*
3
],
f
=
l
[
j
*
3
+
1
],
e
=
l
[
j
*
3
+
2
],
o
=
l
[
i
*
3
],
n
=
l
[
i
*
3
+
1
],
m
=
l
[
i
*
3
+
2
],
v
=
l
[
h
*
3
],
u
=
l
[
h
*
3
+
1
],
t
=
l
[
h
*
3
+
2
];
d
.
faces
.
push
(
new
THREE
.
Face3
(
s
,
r
,
q
,[
new
THREE
.
Vector3
(
g
,
f
,
e
),
new
THREE
.
Vector3
(
o
,
n
,
m
),
new
THREE
.
Vector3
(
v
,
u
,
t
)],
k
))},
f4n
:
function
(
e
,
q
,
y
,
x
,
w
,
u
,
v
,
o
,
n
,
m
,
k
){
var
p
=
e
.
materials
[
v
],
j
=
q
[
o
*
3
],
h
=
q
[
o
*
3
+
1
],
f
=
q
[
o
*
3
+
2
],
t
=
q
[
n
*
3
],
s
=
q
[
n
*
3
+
1
],
r
=
q
[
n
*
3
+
2
],
B
=
q
[
m
*
3
],
A
=
q
[
m
*
3
+
1
],
z
=
q
[
m
*
3
+
2
],
l
=
q
[
k
*
3
],
i
=
q
[
k
*
3
+
1
],
g
=
q
[
k
*
3
+
2
];
e
.
faces
.
push
(
new
THREE
.
Face4
(
y
,
x
,
w
,
u
,[
new
THREE
.
Vector3
(
j
,
h
,
f
),
new
THREE
.
Vector3
(
t
,
s
,
r
),
new
THREE
.
Vector3
(
B
,
A
,
z
),
new
THREE
.
Vector3
(
l
,
i
,
g
)],
p
))},
uv
:
function
(
j
,
e
,
i
,
c
,
h
,
b
,
g
,
a
,
f
){
var
d
=
[];
d
.
push
(
new
THREE
.
UV
(
e
,
i
));
d
.
push
(
new
THREE
.
UV
(
c
,
h
));
d
.
push
(
new
THREE
.
UV
(
b
,
g
));
if
(
a
&&
f
){
d
.
push
(
new
THREE
.
UV
(
a
,
f
))}
j
.
uvs
.
push
(
d
)},
init_materials
:
function
(
d
,
a
,
c
){
d
.
materials
=
[];
for
(
var
b
=
0
;
b
<
a
.
length
;
++
b
){
d
.
materials
[
b
]
=
[
THREE
.
Loader
.
prototype
.
createMaterial
(
a
[
b
],
c
)]}},
createMaterial
:
function
(
a
,
c
){
function
g
(
j
){
var
i
=
Math
.
log
(
j
)
/
Math
.
LN2
;
return
Math
.
floor
(
i
)
==
i
}
function
f
(
j
){
var
i
=
Math
.
log
(
j
)
/
Math
.
LN2
;
return
Math
.
pow
(
2
,
Math
.
round
(
i
))}
var
d
,
e
,
h
,
b
;
if
(
a
.
map_diffuse
&&
c
){
e
=
document
.
createElement
(
"
canvas
"
);
d
=
new
THREE
.
MeshBitmapMaterial
(
e
);
h
=
new
Image
();
h
.
onload
=
function
(){
if
(
!
g
(
this
.
width
)
||!
g
(
this
.
height
)){
var
i
=
f
(
this
.
width
),
j
=
f
(
this
.
height
);
d
.
bitmap
.
width
=
i
;
d
.
bitmap
.
height
=
j
;
d
.
bitmap
.
getContext
(
"
2d
"
).
drawImage
(
this
,
0
,
0
,
i
,
j
)}
else
{
d
.
bitmap
=
this
}
d
.
loaded
=
1
};
h
.
src
=
c
+
"
/
"
+
a
.
map_diffuse
}
else
{
if
(
a
.
col_diffuse
){
b
=
(
a
.
col_diffuse
[
0
]
*
255
<<
16
)
+
(
a
.
col_diffuse
[
1
]
*
255
<<
8
)
+
a
.
col_diffuse
[
2
]
*
255
;
d
=
new
THREE
.
MeshColorFillMaterial
(
b
,
a
.
transparency
)}
else
{
if
(
a
.
a_dbg_color
){
d
=
new
THREE
.
MeshColorFillMaterial
(
a
.
a_dbg_color
)}
else
{
d
=
new
THREE
.
MeshColorFillMaterial
(
15658734
)}}}
return
d
}};
THREE
.
Light
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
255
<<
24
|
a
)};
THREE
.
AmbientLight
=
function
(
a
){
THREE
.
Light
.
call
(
this
,
a
)};
THREE
.
AmbientLight
.
prototype
=
new
THREE
.
Light
();
THREE
.
AmbientLight
.
prototype
.
constructor
=
THREE
.
AmbientLight
;
THREE
.
DirectionalLight
=
function
(
b
,
a
){
THREE
.
Light
.
call
(
this
,
b
);
this
.
position
=
new
THREE
.
Vector3
(
0
,
1
,
0
);
this
.
intensity
=
a
||
1
};
THREE
.
DirectionalLight
.
prototype
=
new
THREE
.
Light
();
THREE
.
DirectionalLight
.
prototype
.
constructor
=
THREE
.
DirectionalLight
;
THREE
.
PointLight
=
function
(
b
,
a
){
THREE
.
Light
.
call
(
this
,
b
);
this
.
position
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
this
.
intensity
=
a
||
1
};
THREE
.
DirectionalLight
.
prototype
=
new
THREE
.
Light
();
THREE
.
DirectionalLight
.
prototype
.
constructor
=
THREE
.
PointLight
;
THREE
.
Object3D
=
function
(
a
){
this
.
position
=
new
THREE
.
Vector3
();
this
.
rotation
=
new
THREE
.
Vector3
();
this
.
scale
=
new
THREE
.
Vector3
(
1
,
1
,
1
);
this
.
matrix
=
new
THREE
.
Matrix4
();
this
.
matrixTranslation
=
new
THREE
.
Matrix4
();
this
.
matrixRotation
=
new
THREE
.
Matrix4
();
this
.
matrixScale
=
new
THREE
.
Matrix4
();
this
.
screen
=
new
THREE
.
Vector3
();
this
.
autoUpdateMatrix
=
true
;
this
.
updateMatrix
=
function
(){
this
.
matrixPosition
=
THREE
.
Matrix4
.
translationMatrix
(
this
.
position
.
x
,
this
.
position
.
y
,
this
.
position
.
z
);
this
.
matrixRotation
=
THREE
.
Matrix4
.
rotationXMatrix
(
this
.
rotation
.
x
);
this
.
matrixRotation
.
multiplySelf
(
THREE
.
Matrix4
.
rotationYMatrix
(
this
.
rotation
.
y
));
this
.
matrixRotation
.
multiplySelf
(
THREE
.
Matrix4
.
rotationZMatrix
(
this
.
rotation
.
z
));
this
.
matrixScale
=
THREE
.
Matrix4
.
scaleMatrix
(
this
.
scale
.
x
,
this
.
scale
.
y
,
this
.
scale
.
z
);
this
.
matrix
.
copy
(
this
.
matrixPosition
);
this
.
matrix
.
multiplySelf
(
this
.
matrixRotation
);
this
.
matrix
.
multiplySelf
(
this
.
matrixScale
)}};
THREE
.
Particle
=
function
(
a
){
THREE
.
Object3D
.
call
(
this
);
this
.
material
=
a
instanceof
Array
?
a
:[
a
];
this
.
autoUpdateMatrix
=
false
};
THREE
.
Particle
.
prototype
=
new
THREE
.
Object3D
();
THREE
.
Particle
.
prototype
.
constructor
=
THREE
.
Particle
;
THREE
.
Line
=
function
(
b
,
a
){
THREE
.
Object3D
.
call
(
this
);
this
.
geometry
=
b
;
this
.
material
=
a
instanceof
Array
?
a
:[
a
]};
THREE
.
Line
.
prototype
=
new
THREE
.
Object3D
();
THREE
.
Line
.
prototype
.
constructor
=
THREE
.
Line
;
THREE
.
Mesh
=
function
(
b
,
a
,
c
){
THREE
.
Object3D
.
call
(
this
);
this
.
geometry
=
b
;
this
.
material
=
a
instanceof
Array
?
a
:[
a
];
this
.
flipSided
=
false
;
this
.
doubleSided
=
false
;
this
.
overdraw
=
false
;
this
.
materialFaceGroup
=
{};
this
.
sortFacesByMaterial
();
if
(
c
){
this
.
normalizeUVs
()}
this
.
geometry
.
computeBoundingBox
()};
THREE
.
Mesh
.
prototype
=
new
THREE
.
Object3D
();
THREE
.
Mesh
.
prototype
.
constructor
=
THREE
.
Mesh
;
THREE
.
Mesh
.
prototype
.
sortFacesByMaterial
=
function
(){
var
c
,
b
,
e
,
m
,
k
,
h
,
j
,
n
,
d
,
g
=
{};
function
a
(
f
){
var
i
=
[];
for
(
c
=
0
,
b
=
f
.
length
;
c
<
b
;
c
++
){
if
(
f
[
c
]
==
undefined
){
i
.
push
(
"
undefined
"
)}
else
{
i
.
push
(
f
[
c
].
toString
())}}
return
i
.
join
(
"
_
"
)}
for
(
e
=
0
,
m
=
this
.
geometry
.
faces
.
length
;
e
<
m
;
e
++
){
k
=
this
.
geometry
.
faces
[
e
];
h
=
k
.
material
;
n
=
a
(
h
);
if
(
g
[
n
]
==
undefined
){
g
[
n
]
=
{
hash
:
n
,
counter
:
0
}}
d
=
g
[
n
].
hash
+
"
_
"
+
g
[
n
].
counter
;
if
(
this
.
materialFaceGroup
[
d
]
==
undefined
){
this
.
materialFaceGroup
[
d
]
=
{
faces
:[],
material
:
h
,
vertices
:
0
}}
j
=
k
instanceof
THREE
.
Face3
?
3
:
4
;
if
(
this
.
materialFaceGroup
[
d
].
vertices
+
j
>
65535
){
g
[
n
].
counter
+=
1
;
d
=
g
[
n
].
hash
+
"
_
"
+
g
[
n
].
counter
;
if
(
this
.
materialFaceGroup
[
d
]
==
undefined
){
this
.
materialFaceGroup
[
d
]
=
{
faces
:[],
material
:
h
,
vertices
:
0
}}}
this
.
materialFaceGroup
[
d
].
faces
.
push
(
e
);
this
.
materialFaceGroup
[
d
].
vertices
+=
j
}};
THREE
.
Mesh
.
prototype
.
normalizeUVs
=
function
(){
var
e
,
a
,
b
,
d
,
c
;
for
(
e
=
0
,
a
=
this
.
geometry
.
uvs
.
length
;
e
<
a
;
e
++
){
c
=
this
.
geometry
.
uvs
[
e
];
for
(
b
=
0
,
d
=
c
.
length
;
b
<
d
;
b
++
){
if
(
c
[
b
].
u
!=
1
){
c
[
b
].
u
=
c
[
b
].
u
-
Math
.
floor
(
c
[
b
].
u
)}
if
(
c
[
b
].
v
!=
1
){
c
[
b
].
v
=
c
[
b
].
v
-
Math
.
floor
(
c
[
b
].
v
)}}}};
THREE
.
FlatShading
=
0
;
THREE
.
GouraudShading
=
1
;
THREE
.
PhongShading
=
2
;
THREE
.
NormalBlending
=
0
;
THREE
.
AdditiveBlending
=
1
;
THREE
.
SubstractiveBlending
=
2
;
THREE
.
LineBasicMaterial
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
linewidth
=
1
;
if
(
a
){
if
(
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
.
linewidth
!==
undefined
){
this
.
linewidth
=
a
.
linewidth
}}
this
.
toString
=
function
(){
return
"
THREE.LineBasicMaterial (<br/>color:
"
+
this
.
color
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>linewidth:
"
+
this
.
linewidth
+
"
<br/>)
"
}};
THREE
.
MeshBasicMaterial
=
function
(
a
){
this
.
id
=
THREE
.
MeshBasicMaterialCounter
.
value
++
;
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
wireframe
=
false
;
this
.
wireframe_linewidth
=
1
;
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
.
setHex
(
a
.
color
)}
if
(
a
.
map
!==
undefined
){
this
.
map
=
a
.
map
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}
if
(
a
.
wireframe
!==
undefined
){
this
.
wireframe
=
a
.
wireframe
}
if
(
a
.
wireframe_linewidth
!==
undefined
){
this
.
wireframe_linewidth
=
a
.
wireframe_linewidth
}}
this
.
toString
=
function
(){
return
"
THREE.MeshBasicMaterial (<br/>id:
"
+
this
.
id
+
"
<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>wireframe:
"
+
this
.
wireframe
+
"
<br/>wireframe_linewidth:
"
+
this
.
wireframe_linewidth
+
"
<br/>)
"
}};
THREE
.
MeshBasicMaterialCounter
=
{
value
:
0
};
THREE
.
MeshDepthMaterial
=
function
(
a
){
this
.
near
=
1
;
this
.
far
=
1000
;
this
.
opacity
=
1
;
this
.
wireframe
=
false
;
this
.
wireframe_linewidth
=
1
;
if
(
a
){
if
(
a
.
near
!==
undefined
){
this
.
near
=
a
.
near
}
if
(
a
.
far
!==
undefined
){
this
.
far
=
a
.
far
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
wireframe
!==
undefined
){
this
.
wireframe
=
a
.
wireframe
}
if
(
a
.
wireframe_linewidth
!==
undefined
){
this
.
wireframe_linewidth
=
a
.
wireframe_linewidth
}}
this
.
__2near
=
2
*
this
.
near
;
this
.
__farPlusNear
=
this
.
far
+
this
.
near
;
this
.
__farMinusNear
=
this
.
far
-
this
.
near
;
this
.
toString
=
function
(){
return
"
THREE.MeshDepthMaterial
"
}};
THREE
.
MeshLambertMaterial
=
function
(
a
){
this
.
id
=
THREE
.
MeshLambertMaterialCounter
.
value
++
;
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
opacity
=
1
;
this
.
shading
=
THREE
.
GouraudShading
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
wireframe
=
false
;
this
.
wireframe_linewidth
=
1
;
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
.
setHex
(
a
.
color
)}
if
(
a
.
map
!==
undefined
){
this
.
map
=
a
.
map
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
shading
!==
undefined
){
this
.
shading
=
a
.
shading
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}
if
(
a
.
wireframe
!==
undefined
){
this
.
wireframe
=
a
.
wireframe
}
if
(
a
.
wireframe_linewidth
!==
undefined
){
this
.
wireframe_linewidth
=
a
.
wireframe_linewidth
}}
this
.
toString
=
function
(){
return
"
THREE.MeshLambertMaterial (<br/>id:
"
+
this
.
id
+
"
<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>shading:
"
+
this
.
shading
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>wireframe:
"
+
this
.
wireframe
+
"
<br/>wireframe_size:
"
+
this
.
wireframe_linewidth
+
"
<br/> )
"
}};
THREE
.
MeshLambertMaterialCounter
=
{
value
:
0
};
THREE
.
MeshPhongMaterial
=
function
(
a
){
this
.
id
=
THREE
.
MeshPhongMaterialCounter
.
value
++
;
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
ambient
=
new
THREE
.
Color
(
328965
);
this
.
specular
=
new
THREE
.
Color
(
1118481
);
this
.
specular_map
=
null
;
this
.
shininess
=
30
;
this
.
opacity
=
1
;
this
.
shading
=
THREE
.
GouraudShading
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
wireframe
=
false
;
this
.
wireframe_linewidth
=
1
;
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
=
new
THREE
.
Color
(
a
.
color
)}
if
(
a
.
map
!==
undefined
){
this
.
map
=
a
.
map
}
if
(
a
.
ambient
!==
undefined
){
this
.
ambient
=
new
THREE
.
Color
(
a
.
ambient
)}
if
(
a
.
specular
!==
undefined
){
this
.
specular_color
=
new
THREE
.
Color
(
a
.
specular
)}
if
(
a
.
specular_map
!==
undefined
){
this
.
specular_map
=
a
.
specular_map
}
if
(
a
.
shininess
!==
undefined
){
this
.
shininess
=
a
.
shininess
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
shading
!==
undefined
){
this
.
shading
=
a
.
shading
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}
if
(
a
.
wireframe
!==
undefined
){
this
.
wireframe
=
a
.
wireframe
}
if
(
a
.
wireframe_linewidth
!==
undefined
){
this
.
wireframe_linewidth
=
a
.
wireframe_linewidth
}}
this
.
toString
=
function
(){
return
"
THREE.MeshPhongMaterial (<br/>id:
"
+
this
.
id
+
"
<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>ambient:
"
+
this
.
ambient
+
"
<br/>specular:
"
+
this
.
specular
+
"
<br/>specular_map:
"
+
this
.
specular_map
+
"
<br/>shininess:
"
+
this
.
shininess
+
"
<br/>alpha:
"
+
this
.
opacity
+
"
<br/>shading:
"
+
this
.
shading
+
"
<br/>wireframe:
"
+
this
.
wireframe
+
"
<br/>wireframe_linewidth:
"
+
this
.
wireframe_linewidth
+
"
<br/>
"
+
+
"
)
"
}};
THREE
.
MeshPhongMaterialCounter
=
{
value
:
0
};
THREE
.
MeshFaceMaterial
=
function
(){
this
.
toString
=
function
(){
return
"
THREE.MeshFaceMaterial
"
}};
THREE
.
ParticleBasicMaterial
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
offset
=
new
THREE
.
Vector2
();
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
.
setHex
(
a
.
color
)}
if
(
a
.
map
!==
undefined
){
this
.
map
=
a
.
map
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}}
this
.
toString
=
function
(){
return
"
THREE.ParticleBasicMaterial (<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>)
"
}};
THREE
.
ParticleCircleMaterial
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
.
setHex
(
a
.
color
)}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}}
this
.
toString
=
function
(){
return
"
THREE.ParticleCircleMaterial (<br/>color:
"
+
this
.
color
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>)
"
}};
THREE
.
ParticleDOMMaterial
=
function
(
a
){
this
.
domElement
=
a
;
this
.
toString
=
function
(){
return
"
THREE.ParticleDOMMaterial ( domElement:
"
+
this
.
domElement
+
"
)
"
}};
THREE
.
Texture
=
function
(
b
,
a
){
this
.
image
=
b
;
this
.
mapping
=
a
?
a
:
THREE
.
UVMapping
;
this
.
toString
=
function
(){
return
"
THREE.Texture (<br/>image:
"
+
this
.
image
+
"
<br/>mapping:
"
+
this
.
mapping
+
"
<br/>)
"
}};
THREE
.
UVMapping
=
0
;
THREE
.
ReflectionMap
=
1
;
THREE
.
CubeMap
=
2
;
THREE
.
Scene
=
function
(){
this
.
objects
=
[];
this
.
lights
=
[];
this
.
addObject
=
function
(
a
){
this
.
objects
.
push
(
a
)};
this
.
removeObject
=
function
(
a
){
var
b
=
this
.
objects
.
indexOf
(
a
);
if
(
b
!==-
1
){
this
.
objects
.
splice
(
b
,
1
)}};
this
.
addLight
=
function
(
a
){
this
.
lights
.
push
(
a
)};
this
.
removeLight
=
function
(
a
){
var
b
=
this
.
lights
.
indexOf
(
a
);
if
(
b
!==-
1
){
this
.
lights
.
splice
(
b
,
1
)}};
this
.
toString
=
function
(){
return
"
THREE.Scene (
"
+
this
.
objects
+
"
)
"
}};
THREE
.
Projector
=
function
(){
var
e
=
null
,
c
,
p
,
n
=
[],
b
,
f
,
l
=
[],
k
,
m
,
i
=
[],
j
,
h
,
a
=
[],
g
=
new
THREE
.
Vector4
(),
d
=
new
THREE
.
Matrix4
(),
o
=
new
THREE
.
Matrix4
();
this
.
projectScene
=
function
(
J
,
G
){
var
F
,
E
,
D
,
K
,
I
,
B
,
r
,
L
,
q
,
z
,
H
,
u
,
C
,
w
,
A
,
y
,
x
,
t
,
s
;
e
=
[];
p
=
0
,
f
=
0
,
m
=
0
,
h
=
0
;
if
(
G
.
autoUpdateMatrix
){
G
.
updateMatrix
()}
d
.
multiply
(
G
.
projectionMatrix
,
G
.
matrix
);
r
=
J
.
objects
;
for
(
F
=
0
,
E
=
r
.
length
;
F
<
E
;
F
++
){
L
=
r
[
F
];
q
=
L
.
matrix
;
if
(
L
.
autoUpdateMatrix
){
L
.
updateMatrix
()}
if
(
L
instanceof
THREE
.
Mesh
){
o
.
multiply
(
d
,
q
);
z
=
L
.
geometry
.
vertices
;
for
(
D
=
0
,
K
=
z
.
length
;
D
<
K
;
D
++
){
H
=
z
[
D
];
u
=
H
.
positionScreen
;
u
.
copy
(
H
.
position
);
o
.
transform
(
u
);
H
.
__visible
=
u
.
z
>
0
&&
u
.
z
<
1
}
w
=
L
.
geometry
.
faces
;
for
(
I
=
0
,
B
=
w
.
length
;
I
<
B
;
I
++
){
A
=
w
[
I
];
if
(
A
instanceof
THREE
.
Face3
){
y
=
z
[
A
.
a
];
x
=
z
[
A
.
b
];
t
=
z
[
A
.
c
];
if
(
y
.
__visible
&&
x
.
__visible
&&
t
.
__visible
){
if
((
L
.
doubleSided
||
(
L
.
flipSided
!=
(
t
.
positionScreen
.
x
-
y
.
positionScreen
.
x
)
*
(
x
.
positionScreen
.
y
-
y
.
positionScreen
.
y
)
-
(
t
.
positionScreen
.
y
-
y
.
positionScreen
.
y
)
*
(
x
.
positionScreen
.
x
-
y
.
positionScreen
.
x
)
<
0
))){
c
=
n
[
p
]
=
n
[
p
]
||
new
THREE
.
RenderableFace3
();
c
.
v1
.
copy
(
y
.
positionScreen
);
c
.
v2
.
copy
(
x
.
positionScreen
);
c
.
v3
.
copy
(
t
.
positionScreen
);
c
.
normalWorld
.
copy
(
A
.
normal
);
L
.
matrixRotation
.
transform
(
c
.
normalWorld
);
c
.
centroidWorld
.
copy
(
A
.
centroid
);
q
.
transform
(
c
.
centroidWorld
);
c
.
centroidScreen
.
copy
(
c
.
centroidWorld
);
d
.
transform
(
c
.
centroidScreen
);
c
.
z
=
c
.
centroidScreen
.
z
;
c
.
meshMaterial
=
L
.
material
;
c
.
faceMaterial
=
A
.
material
;
c
.
overdraw
=
L
.
overdraw
;
c
.
uvs
=
L
.
geometry
.
uvs
[
I
];
c
.
color
=
A
.
color
;
e
.
push
(
c
);
p
++
}}}
else
{
if
(
A
instanceof
THREE
.
Face4
){
y
=
z
[
A
.
a
];
x
=
z
[
A
.
b
];
t
=
z
[
A
.
c
];
s
=
z
[
A
.
d
];
if
(
y
.
__visible
&&
x
.
__visible
&&
t
.
__visible
&&
s
.
__visible
){
if
((
L
.
doubleSided
||
(
L
.
flipSided
!=
((
s
.
positionScreen
.
x
-
y
.
positionScreen
.
x
)
*
(
x
.
positionScreen
.
y
-
y
.
positionScreen
.
y
)
-
(
s
.
positionScreen
.
y
-
y
.
positionScreen
.
y
)
*
(
x
.
positionScreen
.
x
-
y
.
positionScreen
.
x
)
<
0
||
(
x
.
positionScreen
.
x
-
t
.
positionScreen
.
x
)
*
(
s
.
positionScreen
.
y
-
t
.
positionScreen
.
y
)
-
(
x
.
positionScreen
.
y
-
t
.
positionScreen
.
y
)
*
(
s
.
positionScreen
.
x
-
t
.
positionScreen
.
x
)
<
0
)))){
b
=
l
[
f
]
=
l
[
f
]
||
new
THREE
.
RenderableFace4
();
b
.
v1
.
copy
(
y
.
positionScreen
);
b
.
v2
.
copy
(
x
.
positionScreen
);
b
.
v3
.
copy
(
t
.
positionScreen
);
b
.
v4
.
copy
(
s
.
positionScreen
);
b
.
normalWorld
.
copy
(
A
.
normal
);
L
.
matrixRotation
.
transform
(
b
.
normalWorld
);
b
.
centroidWorld
.
copy
(
A
.
centroid
);
q
.
transform
(
b
.
centroidWorld
);
b
.
centroidScreen
.
copy
(
b
.
centroidWorld
);
d
.
transform
(
b
.
centroidScreen
);
b
.
z
=
b
.
centroidScreen
.
z
;
b
.
meshMaterial
=
L
.
material
;
b
.
faceMaterial
=
A
.
material
;
b
.
overdraw
=
L
.
overdraw
;
b
.
uvs
=
L
.
geometry
.
uvs
[
I
];
b
.
color
=
A
.
color
;
e
.
push
(
b
);
f
++
}}}}}}
else
{
if
(
L
instanceof
THREE
.
Line
){
o
.
multiply
(
d
,
q
);
z
=
L
.
geometry
.
vertices
;
for
(
D
=
0
,
K
=
z
.
length
;
D
<
K
;
D
++
){
H
=
z
[
D
];
u
=
H
.
positionScreen
;
u
.
copy
(
H
.
position
);
o
.
transform
(
u
);
H
.
__visible
=
u
.
z
>
0
&&
u
.
z
<
1
;
if
(
D
>
0
){
C
=
L
.
geometry
.
vertices
[
D
-
1
];
if
(
H
.
__visible
&&
C
.
__visible
){
k
=
i
[
m
]
=
i
[
m
]
||
new
THREE
.
RenderableLine
();
k
.
v1
.
copy
(
H
.
positionScreen
);
k
.
v2
.
copy
(
C
.
positionScreen
);
k
.
z
=
Math
.
max
(
H
.
positionScreen
.
z
,
C
.
positionScreen
.
z
);
k
.
material
=
L
.
material
;
e
.
push
(
k
);
m
++
}}}}
else
{
if
(
L
instanceof
THREE
.
Particle
){
g
.
set
(
L
.
position
.
x
,
L
.
position
.
y
,
L
.
position
.
z
,
1
);
d
.
transform
(
g
);
g
.
z
/=
g
.
w
;
if
(
g
.
z
>
0
&&
g
.
z
<
1
){
j
=
a
[
h
]
=
a
[
h
]
||
new
THREE
.
RenderableParticle
();
j
.
x
=
g
.
x
/
g
.
w
;
j
.
y
=
g
.
y
/
g
.
w
;
j
.
z
=
g
.
z
;
j
.
rotation
=
L
.
rotation
.
z
;
j
.
scale
.
x
=
L
.
scale
.
x
*
Math
.
abs
(
j
.
x
-
(
g
.
x
+
G
.
projectionMatrix
.
n11
)
/
(
g
.
w
+
G
.
projectionMatrix
.
n14
));
j
.
scale
.
y
=
L
.
scale
.
y
*
Math
.
abs
(
j
.
y
-
(
g
.
y
+
G
.
projectionMatrix
.
n22
)
/
(
g
.
w
+
G
.
projectionMatrix
.
n24
));
j
.
material
=
L
.
material
;
e
.
push
(
j
);
h
++
}}}}}
e
.
sort
(
function
(
M
,
v
){
return
v
.
z
-
M
.
z
});
return
e
};
this
.
unprojectVector
=
function
(
q
,
s
){
var
r
=
new
THREE
.
Matrix4
();
r
.
multiply
(
THREE
.
Matrix4
.
makeInvert
(
s
.
matrix
),
THREE
.
Matrix4
.
makeInvert
(
s
.
projectionMatrix
));
r
.
transform
(
q
);
return
q
}};
THREE
.
DOMRenderer
=
function
(){
THREE
.
Renderer
.
call
(
this
);
var
e
=
null
,
g
=
new
THREE
.
Projector
(),
b
=
document
.
createElement
(
"
div
"
),
a
,
c
,
f
,
d
;
this
.
domElement
=
b
;
this
.
setSize
=
function
(
i
,
h
){
a
=
i
;
c
=
h
;
f
=
a
/
2
;
d
=
c
/
2
};
this
.
render
=
function
(
p
,
r
){
var
q
,
h
,
i
,
n
,
o
,
s
,
l
,
k
,
j
;
e
=
g
.
projectScene
(
p
,
r
);
for
(
q
=
0
,
h
=
e
.
length
;
q
<
h
;
q
++
){
o
=
e
[
q
];
if
(
o
instanceof
THREE
.
RenderableParticle
){
k
=
o
.
x
*
f
+
f
;
j
=
o
.
y
*
d
+
d
;
for
(
i
=
0
,
n
=
o
.
material
.
length
;
i
<
n
;
i
++
){
s
=
o
.
material
[
i
];
if
(
s
instanceof
THREE
.
ParticleDOMMaterial
){
l
=
s
.
domElement
;
l
.
style
.
left
=
k
+
"
px
"
;
l
.
style
.
top
=
j
+
"
px
"
}}}}}};
THREE
.
CanvasRenderer
=
function
(){
var
n
=
null
,
x
=
new
THREE
.
Projector
(),
s
=
document
.
createElement
(
"
canvas
"
),
a
,
F
,
v
,
h
,
r
=
s
.
getContext
(
"
2d
"
),
B
=
1
,
i
=
"
#000000
"
,
L
=
"
#000000
"
,
f
=
1
,
w
=
new
THREE
.
Rectangle
(),
I
=
new
THREE
.
Rectangle
(),
m
=
new
THREE
.
Rectangle
(),
D
=
false
,
A
=
new
THREE
.
Color
(
4294967295
),
y
=
new
THREE
.
Color
(
4294967295
),
H
=
new
THREE
.
Color
(
4278190080
),
k
=
Math
.
PI
*
2
,
C
,
G
=
new
THREE
.
Vector2
(),
E
=
new
THREE
.
Vector3
(),
u
=
new
THREE
.
UV
(),
t
=
new
THREE
.
UV
(),
q
=
new
THREE
.
UV
(),
p
=
new
THREE
.
UV
(),
K
=
new
THREE
.
Vector2
(),
J
=
new
THREE
.
Vector2
();
this
.
domElement
=
s
;
this
.
autoClear
=
true
;
this
.
setSize
=
function
(
N
,
M
){
a
=
N
;
F
=
M
;
v
=
a
/
2
;
h
=
F
/
2
;
s
.
width
=
a
;
s
.
height
=
F
;
r
.
lineJoin
=
"
round
"
;
r
.
lineCap
=
"
round
"
;
w
.
set
(
-
v
,
-
h
,
v
,
h
)};
this
.
clear
=
function
(){
if
(
!
I
.
isEmpty
()){
I
.
inflate
(
1
);
I
.
minSelf
(
w
);
r
.
setTransform
(
1
,
0
,
0
,
-
1
,
v
,
h
);
r
.
clearRect
(
I
.
getX
(),
I
.
getY
(),
I
.
getWidth
(),
I
.
getHeight
());
I
.
empty
()}};
this
.
render
=
function
(
ah
,
ae
){
var
ag
,
P
,
R
,
Z
,
af
,
V
,
S
,
Y
,
W
,
T
,
ac
,
aa
,
O
,
M
,
X
,
U
,
ad
,
ab
,
Q
,
N
;
if
(
this
.
autoClear
){
this
.
clear
()}
n
=
x
.
projectScene
(
ah
,
ae
);
r
.
setTransform
(
1
,
0
,
0
,
-
1
,
v
,
h
);
D
=
ah
.
lights
.
length
>
0
;
if
(
D
){
e
(
ah
,
H
)}
for
(
ag
=
0
,
P
=
n
.
length
;
ag
<
P
;
ag
++
){
R
=
n
[
ag
];
m
.
empty
();
if
(
R
instanceof
THREE
.
RenderableParticle
){
W
=
R
.
x
*
v
;
T
=
R
.
y
*
h
;
for
(
Z
=
0
,
af
=
R
.
material
.
length
;
Z
<
af
;
Z
++
){
Y
=
R
.
material
[
Z
];
Y
&&
o
(
W
,
T
,
R
,
Y
,
ah
)}}
else
{
if
(
R
instanceof
THREE
.
RenderableLine
){
W
=
R
.
v1
.
x
*
v
;
T
=
R
.
v1
.
y
*
h
;
ac
=
R
.
v2
.
x
*
v
;
aa
=
R
.
v2
.
y
*
h
;
m
.
addPoint
(
W
,
T
);
m
.
addPoint
(
ac
,
aa
);
if
(
!
w
.
instersects
(
m
)){
continue
}
Z
=
0
;
af
=
R
.
material
.
length
;
while
(
Z
<
af
){
Y
=
R
.
material
[
Z
++
];
Y
&&
z
(
W
,
T
,
ac
,
aa
,
R
,
Y
,
ah
)}}
else
{
if
(
R
instanceof
THREE
.
RenderableFace3
){
R
.
v1
.
x
*=
v
;
R
.
v1
.
y
*=
h
;
R
.
v2
.
x
*=
v
;
R
.
v2
.
y
*=
h
;
R
.
v3
.
x
*=
v
;
R
.
v3
.
y
*=
h
;
if
(
R
.
overdraw
){
b
(
R
.
v1
,
R
.
v2
);
b
(
R
.
v2
,
R
.
v3
);
b
(
R
.
v3
,
R
.
v1
)}
W
=
R
.
v1
.
x
;
T
=
R
.
v1
.
y
;
ac
=
R
.
v2
.
x
;
aa
=
R
.
v2
.
y
;
O
=
R
.
v3
.
x
;
M
=
R
.
v3
.
y
;
m
.
addPoint
(
W
,
T
);
m
.
addPoint
(
ac
,
aa
);
m
.
addPoint
(
O
,
M
);
if
(
!
w
.
instersects
(
m
)){
continue
}
Z
=
0
;
af
=
R
.
meshMaterial
.
length
;
while
(
Z
<
af
){
Y
=
R
.
meshMaterial
[
Z
++
];
if
(
Y
instanceof
THREE
.
MeshFaceMaterial
){
V
=
0
;
S
=
R
.
faceMaterial
.
length
;
while
(
V
<
S
){
Y
=
R
.
faceMaterial
[
V
++
];
Y
&&
l
(
W
,
T
,
ac
,
aa
,
O
,
M
,
R
,
Y
,
ah
)}
continue
}
l
(
W
,
T
,
ac
,
aa
,
O
,
M
,
R
,
Y
,
ah
)}}
else
{
if
(
R
instanceof
THREE
.
RenderableFace4
){
R
.
v1
.
x
*=
v
;
R
.
v1
.
y
*=
h
;
R
.
v2
.
x
*=
v
;
R
.
v2
.
y
*=
h
;
R
.
v3
.
x
*=
v
;
R
.
v3
.
y
*=
h
;
R
.
v4
.
x
*=
v
;
R
.
v4
.
y
*=
h
;
K
.
copy
(
R
.
v2
);
J
.
copy
(
R
.
v4
);
if
(
R
.
overdraw
){
b
(
R
.
v1
,
R
.
v2
);
b
(
R
.
v2
,
R
.
v4
);
b
(
R
.
v4
,
R
.
v1
)}
W
=
R
.
v1
.
x
;
T
=
R
.
v1
.
y
;
ac
=
R
.
v2
.
x
;
aa
=
R
.
v2
.
y
;
X
=
R
.
v4
.
x
;
U
=
R
.
v4
.
y
;
if
(
R
.
overdraw
){
b
(
R
.
v3
,
K
);
b
(
R
.
v3
,
J
)}
O
=
R
.
v3
.
x
;
M
=
R
.
v3
.
y
;
ad
=
K
.
x
;
ab
=
K
.
y
;
Q
=
J
.
x
;
N
=
J
.
y
;
m
.
addPoint
(
W
,
T
);
m
.
addPoint
(
ac
,
aa
);
m
.
addPoint
(
O
,
M
);
m
.
addPoint
(
X
,
U
);
if
(
!
w
.
instersects
(
m
)){
continue
}
Z
=
0
;
af
=
R
.
meshMaterial
.
length
;
while
(
Z
<
af
){
Y
=
R
.
meshMaterial
[
Z
++
];
if
(
Y
instanceof
THREE
.
MeshFaceMaterial
){
V
=
0
;
S
=
R
.
faceMaterial
.
length
;
while
(
V
<
S
){
Y
=
R
.
faceMaterial
[
V
++
];
Y
&&
j
(
W
,
T
,
ac
,
aa
,
O
,
M
,
X
,
U
,
ad
,
ab
,
Q
,
N
,
R
,
Y
,
ah
)}
continue
}
j
(
W
,
T
,
ac
,
aa
,
O
,
M
,
X
,
U
,
ad
,
ab
,
Q
,
N
,
R
,
Y
,
ah
)}}}}}
I
.
addRectangle
(
m
)}
r
.
setTransform
(
1
,
0
,
0
,
1
,
0
,
0
)};
function
e
(
S
,
P
){
var
O
,
R
,
N
,
M
,
Q
=
S
.
lights
;
P
.
setRGBA
(
0
,
0
,
0
,
1
);
for
(
O
=
0
,
R
=
Q
.
length
;
O
<
R
;
O
++
){
N
=
Q
[
O
];
M
=
N
.
color
;
if
(
N
instanceof
THREE
.
AmbientLight
){
P
.
r
+=
M
.
r
;
P
.
g
+=
M
.
g
;
P
.
b
+=
M
.
b
}}}
function
g
(
T
,
R
,
P
){
var
O
,
S
,
N
,
M
,
Q
=
T
.
lights
;
for
(
O
=
0
,
S
=
Q
.
length
;
O
<
S
;
O
++
){
N
=
Q
[
O
];
M
=
N
.
color
;
if
(
N
instanceof
THREE
.
DirectionalLight
){
P
.
r
+=
M
.
r
;
P
.
g
+=
M
.
g
;
P
.
b
+=
M
.
b
}
else
{
if
(
N
instanceof
THREE
.
PointLight
){
P
.
r
+=
M
.
r
;
P
.
g
+=
M
.
g
;
P
.
b
+=
M
.
b
}}}}
function
d
(
T
,
R
,
P
){
var
O
,
S
,
N
,
M
,
Q
;
lights
=
T
.
lights
;
for
(
O
=
0
,
S
=
lights
.
length
;
O
<
S
;
O
++
){
N
=
lights
[
O
];
M
=
N
.
color
;
if
(
N
instanceof
THREE
.
DirectionalLight
){
Q
=
R
.
normalWorld
.
dot
(
N
.
position
)
*
N
.
intensity
;
if
(
Q
>
0
){
P
.
r
+=
M
.
r
*
Q
;
P
.
g
+=
M
.
g
*
Q
;
P
.
b
+=
M
.
b
*
Q
}}
else
{
if
(
N
instanceof
THREE
.
PointLight
){
E
.
sub
(
N
.
position
,
R
.
centroidWorld
);
E
.
normalize
();
Q
=
R
.
normalWorld
.
dot
(
E
)
*
N
.
intensity
;
if
(
Q
>
0
){
P
.
r
+=
M
.
r
*
Q
;
P
.
g
+=
M
.
g
*
Q
;
P
.
b
+=
M
.
b
*
Q
}}}}}
function
o
(
O
,
N
,
R
,
U
,
T
){
var
M
,
Z
,
X
,
W
,
S
,
Q
,
V
,
Y
,
P
;
if
(
B
!=
U
.
opacity
){
r
.
globalAlpha
=
B
=
U
.
opacity
}
if
(
U
instanceof
THREE
.
ParticleBasicMaterial
){
V
=
U
.
bitmap
;
Y
=
V
.
width
/
2
;
P
=
V
.
height
/
2
;
X
=
R
.
scale
.
x
*
v
;
W
=
R
.
scale
.
y
*
h
;
M
=
X
*
Y
;
Z
=
W
*
P
;
S
=
U
.
offset
.
x
*
X
;
Q
=
U
.
offset
.
y
*
W
;
m
.
set
(
O
+
S
-
M
,
N
+
Q
-
Z
,
O
+
S
+
M
,
N
+
Q
+
Z
);
if
(
!
w
.
instersects
(
m
)){
return
}
r
.
save
();
r
.
translate
(
O
,
N
);
r
.
rotate
(
-
R
.
rotation
);
r
.
scale
(
X
,
-
W
);
r
.
translate
(
-
Y
+
U
.
offset
.
x
,
-
P
-
U
.
offset
.
y
);
r
.
drawImage
(
V
,
0
,
0
);
r
.
restore
()}
else
{
if
(
U
instanceof
THREE
.
ParticleCircleMaterial
){
if
(
D
){
y
.
copyRGB
(
H
);
g
(
T
,
R
,
y
);
A
.
copyRGBA
(
U
.
color
);
A
.
multiplySelfRGB
(
y
);
A
.
updateStyleString
()}
else
{
A
.
__styleString
=
U
.
color
.
__styleString
}
M
=
R
.
scale
.
x
*
v
;
Z
=
R
.
scale
.
y
*
h
;
m
.
set
(
O
-
M
,
N
-
Z
,
O
+
M
,
N
+
Z
);
if
(
!
w
.
instersects
(
m
)){
return
}
r
.
save
();
r
.
translate
(
O
,
N
);
r
.
rotate
(
-
R
.
rotation
);
r
.
scale
(
M
,
Z
);
r
.
beginPath
();
r
.
arc
(
0
,
0
,
1
,
0
,
k
,
true
);
r
.
closePath
();
r
.
fillStyle
=
A
.
__styleString
;
r
.
fill
();
r
.
restore
()}}}
function
z
(
M
,
S
,
O
,
N
,
P
,
Q
,
R
){
if
(
B
!=
Q
.
opacity
){
r
.
globalAlpha
=
B
=
Q
.
opacity
}
if
(
Q
instanceof
THREE
.
LineBasicMaterial
){
r
.
beginPath
();
r
.
moveTo
(
M
,
S
);
r
.
lineTo
(
O
,
N
);
r
.
closePath
();
A
.
__styleString
=
Q
.
color
.
__styleString
;
if
(
f
!=
Q
.
linewidth
){
r
.
lineWidth
=
f
=
Q
.
linewidth
}
if
(
i
!=
A
.
__styleString
){
r
.
strokeStyle
=
i
=
A
.
__styleString
}
r
.
stroke
();
m
.
inflate
(
Q
.
linewidth
*
2
)}}
function
l
(
O
,
N
,
M
,
X
,
U
,
T
,
Q
,
S
,
R
){
var
V
,
W
,
P
;
if
(
B
!=
S
.
opacity
){
r
.
globalAlpha
=
B
=
S
.
opacity
}
if
(
S
.
map
){
V
=
S
.
map
.
image
;
W
=
V
.
width
-
1
;
P
=
V
.
height
-
1
;
u
.
copy
(
Q
.
uvs
[
0
]);
t
.
copy
(
Q
.
uvs
[
1
]);
q
.
copy
(
Q
.
uvs
[
2
]);
u
.
u
*=
W
;
u
.
v
*=
P
;
t
.
u
*=
W
;
t
.
v
*=
P
;
q
.
u
*=
W
;
q
.
v
*=
P
;
c
(
V
,
O
,
N
,
M
,
X
,
U
,
T
,
u
.
u
,
u
.
v
,
t
.
u
,
t
.
v
,
q
.
u
,
q
.
v
);
return
}
r
.
beginPath
();
r
.
moveTo
(
O
,
N
);
r
.
lineTo
(
M
,
X
);
r
.
lineTo
(
U
,
T
);
r
.
lineTo
(
O
,
N
);
r
.
closePath
();
if
(
S
instanceof
THREE
.
MeshBasicMaterial
){
A
.
__styleString
=
S
.
color
.
__styleString
}
else
{
if
(
S
instanceof
THREE
.
MeshDepthMaterial
){
C
=
1
-
(
S
.
__2near
/
(
S
.
__farPlusNear
-
Q
.
z
*
S
.
__farMinusNear
));
A
.
setRGBA
(
C
,
C
,
C
,
1
)}
else
{
if
(
S
instanceof
THREE
.
MeshLambertMaterial
){
if
(
D
){
y
.
copyRGB
(
H
);
d
(
R
,
Q
,
y
);
A
.
copyRGBA
(
S
.
color
);
A
.
multiplySelfRGB
(
y
);
A
.
updateStyleString
()}
else
{
A
.
__styleString
=
S
.
color
.
__styleString
}}}}
if
(
S
.
wireframe
){
if
(
f
!=
S
.
wireframe_linewidth
){
r
.
lineWidth
=
f
=
S
.
wireframe_linewidth
}
if
(
i
!=
A
.
__styleString
){
r
.
strokeStyle
=
i
=
A
.
__styleString
}
r
.
stroke
();
m
.
inflate
(
S
.
wireframe_linewidth
*
2
)}
else
{
if
(
L
!=
A
.
__styleString
){
r
.
fillStyle
=
L
=
A
.
__styleString
}
r
.
fill
()}}
function
j
(
S
,
R
,
aa
,
Y
,
N
,
M
,
U
,
T
,
ab
,
Z
,
P
,
O
,
Q
,
W
,
ac
){
var
ad
,
V
,
X
;
if
(
B
!=
W
.
opacity
){
r
.
globalAlpha
=
B
=
W
.
opacity
}
if
(
W
.
map
){
ad
=
W
.
map
.
image
;
V
=
ad
.
width
-
1
;
X
=
ad
.
height
-
1
;
u
.
copy
(
Q
.
uvs
[
0
]);
t
.
copy
(
Q
.
uvs
[
1
]);
q
.
copy
(
Q
.
uvs
[
2
]);
p
.
copy
(
Q
.
uvs
[
3
]);
u
.
u
*=
V
;
u
.
v
*=
X
;
t
.
u
*=
V
;
t
.
v
*=
X
;
q
.
u
*=
V
;
q
.
v
*=
X
;
p
.
u
*=
V
;
p
.
v
*=
X
;
c
(
ad
,
S
,
R
,
aa
,
Y
,
U
,
T
,
u
.
u
,
u
.
v
,
t
.
u
,
t
.
v
,
p
.
u
,
p
.
v
);
c
(
ad
,
ab
,
Z
,
N
,
M
,
P
,
O
,
t
.
u
,
t
.
v
,
q
.
u
,
q
.
v
,
p
.
u
,
p
.
v
);
return
}
r
.
beginPath
();
r
.
moveTo
(
S
,
R
);
r
.
lineTo
(
aa
,
Y
);
r
.
lineTo
(
N
,
M
);
r
.
lineTo
(
U
,
T
);
r
.
lineTo
(
S
,
R
);
r
.
closePath
();
if
(
W
instanceof
THREE
.
MeshBasicMaterial
){
A
.
__styleString
=
W
.
color
.
__styleString
}
else
{
if
(
W
instanceof
THREE
.
MeshDepthMaterial
){
C
=
1
-
(
W
.
__2near
/
(
W
.
__farPlusNear
-
Q
.
z
*
W
.
__farMinusNear
));
A
.
setRGBA
(
C
,
C
,
C
,
1
)}
else
{
if
(
W
instanceof
THREE
.
MeshLambertMaterial
){
if
(
D
){
y
.
copyRGB
(
H
);
d
(
ac
,
Q
,
y
);
A
.
copyRGBA
(
W
.
color
);
A
.
multiplySelfRGB
(
y
);
A
.
updateStyleString
()}
else
{
A
.
__styleString
=
W
.
color
.
__styleString
}}}}
if
(
W
.
wireframe
){
if
(
f
!=
W
.
wireframe_linewidth
){
r
.
lineWidth
=
f
=
W
.
wireframe_linewidth
}
if
(
i
!=
A
.
__styleString
){
r
.
strokeStyle
=
i
=
A
.
__styleString
}
r
.
stroke
();
m
.
inflate
(
W
.
wireframe_linewidth
*
2
)}
else
{
if
(
L
!=
A
.
__styleString
){
r
.
fillStyle
=
L
=
A
.
__styleString
}
r
.
fill
()}}
function
c
(
af
,
Z
,
R
,
X
,
Q
,
V
,
O
,
W
,
P
,
U
,
N
,
T
,
M
){
r
.
beginPath
();
r
.
moveTo
(
Z
,
R
);
r
.
lineTo
(
X
,
Q
);
r
.
lineTo
(
V
,
O
);
r
.
closePath
();
X
-=
Z
;
Q
-=
R
;
V
-=
Z
;
O
-=
R
;
U
-=
W
;
N
-=
P
;
T
-=
W
;
M
-=
P
;
var
S
=
1
/
(
U
*
M
-
T
*
N
),
ae
=
(
M
*
X
-
N
*
V
)
*
S
,
ad
=
(
M
*
Q
-
N
*
O
)
*
S
,
ac
=
(
U
*
V
-
T
*
X
)
*
S
,
ab
=
(
U
*
O
-
T
*
Q
)
*
S
,
aa
=
Z
-
ae
*
W
-
ac
*
P
,
Y
=
R
-
ad
*
W
-
ab
*
P
;
r
.
save
();
r
.
transform
(
ae
,
ad
,
ac
,
ab
,
aa
,
Y
);
r
.
clip
();
r
.
drawImage
(
af
,
0
,
0
);
r
.
restore
()}
function
b
(
N
,
M
){
G
.
sub
(
M
,
N
);
G
.
unit
();
G
.
multiplyScalar
(
0.75
);
M
.
addSelf
(
G
);
N
.
subSelf
(
G
)}};
THREE
.
SVGRenderer
=
function
(){
var
y
=
null
,
r
=
new
THREE
.
Projector
(),
t
=
document
.
createElementNS
(
"
http://www.w3.org/2000/svg
"
,
"
svg
"
),
b
,
o
,
p
,
s
,
A
=
new
THREE
.
Rectangle
(),
w
=
new
THREE
.
Rectangle
(),
i
=
false
,
k
=
new
THREE
.
Color
(
4294967295
),
v
=
new
THREE
.
Color
(
4294967295
),
c
=
new
THREE
.
Color
(
4294967295
),
x
,
g
=
new
THREE
.
Vector3
(),
d
=
[],
l
=
[],
C
,
n
,
f
,
B
=
1
;
this
.
domElement
=
t
;
this
.
autoClear
=
true
;
this
.
setQuality
=
function
(
D
){
switch
(
D
){
case
"
high
"
:
B
=
1
;
break
;
case
"
low
"
:
B
=
0
;
break
}};
this
.
setSize
=
function
(
E
,
D
){
b
=
E
;
o
=
D
;
p
=
b
/
2
;
s
=
o
/
2
;
t
.
setAttribute
(
"
viewBox
"
,(
-
p
)
+
"
"
+
(
-
s
)
+
"
"
+
b
+
"
"
+
o
);
t
.
setAttribute
(
"
width
"
,
b
);
t
.
setAttribute
(
"
height
"
,
o
);
A
.
set
(
-
p
,
-
s
,
p
,
s
)};
this
.
clear
=
function
(){
while
(
t
.
childNodes
.
length
>
0
){
t
.
removeChild
(
t
.
childNodes
[
0
])}};
this
.
render
=
function
(
U
,
R
){
var
T
,
F
,
O
,
S
,
K
,
H
,
G
,
N
,
L
,
I
,
Q
,
P
,
E
,
D
,
M
,
J
;
if
(
this
.
autoClear
){
this
.
clear
()}
y
=
r
.
projectScene
(
U
,
R
);
n
=
0
;
f
=
0
;
i
=
U
.
lights
.
length
>
0
;
if
(
i
){
z
(
U
,
c
)}
for
(
T
=
0
,
F
=
y
.
length
;
T
<
F
;
T
++
){
G
=
y
[
T
];
w
.
empty
();
if
(
G
instanceof
THREE
.
RenderableParticle
){
L
=
G
.
x
*
p
;
I
=
G
.
y
*-
s
;
for
(
O
=
0
,
S
=
G
.
material
.
length
;
O
<
S
;
O
++
){
N
=
G
.
material
[
O
];
N
&&
j
(
L
,
I
,
G
,
N
,
U
)}}
else
{
if
(
G
instanceof
THREE
.
RenderableFace3
){
L
=
G
.
v1
.
x
*
p
;
I
=
G
.
v1
.
y
*-
s
;
Q
=
G
.
v2
.
x
*
p
;
P
=
G
.
v2
.
y
*-
s
;
E
=
G
.
v3
.
x
*
p
;
D
=
G
.
v3
.
y
*-
s
;
w
.
addPoint
(
L
,
I
);
w
.
addPoint
(
Q
,
P
);
w
.
addPoint
(
E
,
D
);
if
(
!
A
.
instersects
(
w
)){
continue
}
O
=
0
;
S
=
G
.
meshMaterial
.
length
;
while
(
O
<
S
){
N
=
G
.
meshMaterial
[
O
++
];
if
(
N
instanceof
THREE
.
MeshFaceMaterial
){
K
=
0
;
H
=
G
.
faceMaterial
.
length
;
while
(
K
<
H
){
N
=
G
.
faceMaterial
[
K
++
];
N
&&
h
(
L
,
I
,
Q
,
P
,
E
,
D
,
G
,
N
,
U
)}
continue
}
N
&&
h
(
L
,
I
,
Q
,
P
,
E
,
D
,
G
,
N
,
U
)}}
else
{
if
(
G
instanceof
THREE
.
RenderableFace4
){
L
=
G
.
v1
.
x
*
p
;
I
=
G
.
v1
.
y
*-
s
;
Q
=
G
.
v2
.
x
*
p
;
P
=
G
.
v2
.
y
*-
s
;
E
=
G
.
v3
.
x
*
p
;
D
=
G
.
v3
.
y
*-
s
;
M
=
G
.
v4
.
x
*
p
;
J
=
G
.
v4
.
y
*-
s
;
w
.
addPoint
(
L
,
I
);
w
.
addPoint
(
Q
,
P
);
w
.
addPoint
(
E
,
D
);
w
.
addPoint
(
M
,
J
);
if
(
!
A
.
instersects
(
w
)){
continue
}
O
=
0
;
S
=
G
.
meshMaterial
.
length
;
while
(
O
<
S
){
N
=
G
.
meshMaterial
[
O
++
];
if
(
N
instanceof
THREE
.
MeshFaceMaterial
){
K
=
0
;
H
=
G
.
faceMaterial
.
length
;
while
(
K
<
H
){
N
=
G
.
faceMaterial
[
K
++
];
N
&&
e
(
L
,
I
,
Q
,
P
,
E
,
D
,
M
,
J
,
G
,
N
,
U
)}
continue
}
N
&&
e
(
L
,
I
,
Q
,
P
,
E
,
D
,
M
,
J
,
G
,
N
,
U
)}}}}}};
function
z
(
H
,
F
){
var
E
,
G
,
D
;
F
.
setRGBA
(
0
,
0
,
0
,
1
);
for
(
E
=
0
,
G
=
H
.
lights
.
length
;
E
<
G
;
E
++
){
D
=
H
.
lights
[
E
];
if
(
D
instanceof
THREE
.
AmbientLight
){
F
.
r
+=
D
.
color
.
r
;
F
.
g
+=
D
.
color
.
g
;
F
.
b
+=
D
.
color
.
b
}}}
function
q
(
I
,
G
,
F
){
var
E
,
H
,
D
;
for
(
E
=
0
,
H
=
I
.
lights
.
length
;
E
<
H
;
E
++
){
D
=
I
.
lights
[
E
];
if
(
D
instanceof
THREE
.
DirectionalLight
){
F
.
r
+=
D
.
color
.
r
;
F
.
g
+=
D
.
color
.
g
;
F
.
b
+=
D
.
color
.
b
}
else
{
if
(
D
instanceof
THREE
.
PointLight
){
F
.
r
+=
D
.
color
.
r
;
F
.
g
+=
D
.
color
.
g
;
F
.
b
+=
D
.
color
.
b
}}}}
function
a
(
J
,
H
,
F
){
var
E
,
I
,
D
,
G
;
for
(
E
=
0
,
I
=
J
.
lights
.
length
;
E
<
I
;
E
++
){
D
=
J
.
lights
[
E
];
if
(
D
instanceof
THREE
.
DirectionalLight
){
G
=
H
.
normalWorld
.
dot
(
D
.
position
)
*
D
.
intensity
;
if
(
G
>
0
){
F
.
r
+=
D
.
color
.
r
*
G
;
F
.
g
+=
D
.
color
.
g
*
G
;
F
.
b
+=
D
.
color
.
b
*
G
}}
else
{
if
(
D
instanceof
THREE
.
PointLight
){
g
.
sub
(
D
.
position
,
H
.
centroidWorld
);
g
.
normalize
();
G
=
H
.
normalWorld
.
dot
(
g
)
*
D
.
intensity
;
if
(
G
>
0
){
F
.
r
+=
D
.
color
.
r
*
G
;
F
.
g
+=
D
.
color
.
g
*
G
;
F
.
b
+=
D
.
color
.
b
*
G
}}}}}
function
j
(
D
,
H
,
E
,
F
,
G
){
C
=
u
(
f
++
);
C
.
setAttribute
(
"
cx
"
,
D
);
C
.
setAttribute
(
"
cy
"
,
H
);
C
.
setAttribute
(
"
r
"
,
E
.
scale
.
x
*
p
);
if
(
F
instanceof
THREE
.
ParticleCircleMaterial
){
if
(
i
){
v
.
copyRGB
(
c
);
q
(
G
,
E
,
v
);
k
.
copyRGBA
(
F
.
color
);
k
.
multiplySelfRGB
(
v
);
k
.
updateStyleString
()}
else
{
k
=
F
.
color
}
C
.
setAttribute
(
"
style
"
,
"
fill:
"
+
k
.
__styleString
)}
t
.
appendChild
(
C
)}
function
h
(
F
,
E
,
D
,
L
,
K
,
J
,
G
,
I
,
H
){
C
=
m
(
n
++
);
C
.
setAttribute
(
"
d
"
,
"
M
"
+
F
+
"
"
+
E
+
"
L
"
+
D
+
"
"
+
L
+
"
L
"
+
K
+
"
,
"
+
J
+
"
z
"
);
if
(
I
instanceof
THREE
.
MeshBasicMaterial
){
k
.
__styleString
=
I
.
color
.
__styleString
}
else
{
if
(
I
instanceof
THREE
.
MeshDepthMaterial
){
x
=
1
-
(
I
.
__2near
/
(
I
.
__farPlusNear
-
G
.
z
*
I
.
__farMinusNear
));
k
.
setRGBA
(
x
,
x
,
x
,
1
)}
else
{
if
(
I
instanceof
THREE
.
MeshLambertMaterial
){
if
(
i
){
v
.
copyRGB
(
c
);
a
(
H
,
G
,
v
);
k
.
copyRGBA
(
I
.
color
);
k
.
multiplySelfRGB
(
v
);
k
.
updateStyleString
()}
else
{
k
.
__styleString
=
I
.
color
.
__styleString
}}}}
if
(
I
.
wireframe
){
C
.
setAttribute
(
"
style
"
,
"
fill: none; stroke:
"
+
k
.
__styleString
+
"
; stroke-width:
"
+
I
.
wireframe_linewidth
+
"
; stroke-opacity:
"
+
I
.
opacity
+
"
; stroke-linecap: round; stroke-linejoin: round
"
)}
else
{
C
.
setAttribute
(
"
style
"
,
"
fill:
"
+
k
.
__styleString
+
"
; fill-opacity:
"
+
I
.
opacity
)}
t
.
appendChild
(
C
)}
function
e
(
H
,
F
,
D
,
N
,
M
,
L
,
G
,
E
,
I
,
K
,
J
){
C
=
m
(
n
++
);
C
.
setAttribute
(
"
d
"
,
"
M
"
+
H
+
"
"
+
F
+
"
L
"
+
D
+
"
"
+
N
+
"
L
"
+
M
+
"
,
"
+
L
+
"
L
"
+
G
+
"
,
"
+
E
+
"
z
"
);
if
(
K
instanceof
THREE
.
MeshBasicMaterial
){
k
.
__styleString
=
K
.
color
.
__styleString
}
else
{
if
(
K
instanceof
THREE
.
MeshLambertMaterial
){
if
(
i
){
v
.
copyRGB
(
c
);
a
(
J
,
I
,
v
);
k
.
copyRGBA
(
K
.
color
);
k
.
multiplySelfRGB
(
v
);
k
.
updateStyleString
()}
else
{
k
.
__styleString
=
K
.
color
.
__styleString
}}}
if
(
K
.
wireframe
){
C
.
setAttribute
(
"
style
"
,
"
fill: none; stroke:
"
+
k
.
__styleString
+
"
; stroke-width:
"
+
K
.
wireframe_linewidth
+
"
; stroke-opacity:
"
+
K
.
opacity
+
"
; stroke-linecap: round; stroke-linejoin: round
"
)}
else
{
C
.
setAttribute
(
"
style
"
,
"
fill:
"
+
k
.
__styleString
+
"
; fill-opacity:
"
+
K
.
opacity
)}
t
.
appendChild
(
C
)}
function
m
(
D
){
if
(
d
[
D
]
==
null
){
d
[
D
]
=
document
.
createElementNS
(
"
http://www.w3.org/2000/svg
"
,
"
path
"
);
if
(
B
==
0
){
d
[
D
].
setAttribute
(
"
shape-rendering
"
,
"
crispEdges
"
)}
return
d
[
D
]}
return
d
[
D
]}
function
u
(
D
){
if
(
l
[
D
]
==
null
){
l
[
D
]
=
document
.
createElementNS
(
"
http://www.w3.org/2000/svg
"
,
"
circle
"
);
if
(
B
==
0
){
l
[
D
].
setAttribute
(
"
shape-rendering
"
,
"
crispEdges
"
)}
return
l
[
D
]}
return
l
[
D
]}};
THREE
.
WebGLRenderer
=
function
(
k
){
var
n
=
document
.
createElement
(
"
canvas
"
),
c
,
f
,
q
=
new
THREE
.
Matrix4
(),
m
,
a
=
0
,
p
=
1
,
j
=
2
,
d
=
3
,
e
=
l
(
k
,
5
);
this
.
domElement
=
n
;
this
.
autoClear
=
true
;
i
();
h
(
e
.
directional
,
e
.
point
);
function
l
(
v
,
w
){
if
(
v
){
var
s
,
u
,
r
,
t
=
pointLights
=
maxDirLights
=
maxPointLights
=
0
;
for
(
s
=
0
,
u
=
v
.
lights
.
length
;
s
<
u
;
s
++
){
r
=
v
.
lights
[
s
];
if
(
r
instanceof
THREE
.
DirectionalLight
){
t
++
}
if
(
r
instanceof
THREE
.
PointLight
){
pointLights
++
}}
if
((
pointLights
+
t
)
<=
w
){
maxDirLights
=
t
;
maxPointLights
=
pointLights
}
else
{
maxDirLights
=
Math
.
ceil
(
w
*
t
/
(
pointLights
+
t
));
maxPointLights
=
w
-
maxDirLights
}
return
{
directional
:
maxDirLights
,
point
:
maxPointLights
}}
return
{
directional
:
1
,
point
:
w
-
1
}}
this
.
setSize
=
function
(
s
,
r
){
n
.
width
=
s
;
n
.
height
=
r
;
c
.
viewport
(
0
,
0
,
n
.
width
,
n
.
height
)};
this
.
clear
=
function
(){
c
.
clear
(
c
.
COLOR_BUFFER_BIT
|
c
.
DEPTH_BUFFER_BIT
)};
this
.
setupLights
=
function
(
y
){
var
v
,
C
,
w
,
t
,
z
,
D
,
u
=
[],
A
=
[],
B
=
[],
s
=
[],
x
=
[];
c
.
uniform1i
(
f
.
enableLighting
,
y
.
lights
.
length
);
for
(
v
=
0
,
C
=
y
.
lights
.
length
;
v
<
C
;
v
++
){
w
=
y
.
lights
[
v
];
if
(
w
instanceof
THREE
.
AmbientLight
){
u
.
push
(
w
)}
else
{
if
(
w
instanceof
THREE
.
DirectionalLight
){
B
.
push
(
w
)}
else
{
if
(
w
instanceof
THREE
.
PointLight
){
A
.
push
(
w
)}}}}
t
=
z
=
D
=
0
;
for
(
v
=
0
,
C
=
u
.
length
;
v
<
C
;
v
++
){
t
+=
u
[
v
].
color
.
r
;
z
+=
u
[
v
].
color
.
g
;
D
+=
u
[
v
].
color
.
b
}
c
.
uniform3f
(
f
.
ambientLightColor
,
t
,
z
,
D
);
s
=
[];
x
=
[];
for
(
v
=
0
,
C
=
B
.
length
;
v
<
C
;
v
++
){
w
=
B
[
v
];
s
.
push
(
w
.
color
.
r
*
w
.
intensity
);
s
.
push
(
w
.
color
.
g
*
w
.
intensity
);
s
.
push
(
w
.
color
.
b
*
w
.
intensity
);
x
.
push
(
w
.
position
.
x
);
x
.
push
(
w
.
position
.
y
);
x
.
push
(
w
.
position
.
z
)}
if
(
B
.
length
){
c
.
uniform1i
(
f
.
directionalLightNumber
,
B
.
length
);
c
.
uniform3fv
(
f
.
directionalLightDirection
,
x
);
c
.
uniform3fv
(
f
.
directionalLightColor
,
s
)}
s
=
[];
x
=
[];
for
(
v
=
0
,
C
=
A
.
length
;
v
<
C
;
v
++
){
w
=
A
[
v
];
s
.
push
(
w
.
color
.
r
*
w
.
intensity
);
s
.
push
(
w
.
color
.
g
*
w
.
intensity
);
s
.
push
(
w
.
color
.
b
*
w
.
intensity
);
x
.
push
(
w
.
position
.
x
);
x
.
push
(
w
.
position
.
y
);
x
.
push
(
w
.
position
.
z
)}
if
(
A
.
length
){
c
.
uniform1i
(
f
.
pointLightNumber
,
A
.
length
);
c
.
uniform3fv
(
f
.
pointLightPosition
,
x
);
c
.
uniform3fv
(
f
.
pointLightColor
,
s
)}};
this
.
createBuffers
=
function
(
K
,
I
){
var
G
,
y
,
A
,
x
,
F
,
J
,
w
,
u
,
t
,
s
,
r
,
v
=
K
.
materialFaceGroup
[
I
],
C
=
[],
E
=
[],
B
=
[],
H
=
[],
D
=
[],
z
=
0
;
for
(
G
=
0
,
y
=
v
.
faces
.
length
;
G
<
y
;
G
++
){
A
=
v
.
faces
[
G
];
x
=
K
.
geometry
.
faces
[
A
];
F
=
x
.
vertexNormals
;
J
=
x
.
normal
;
w
=
K
.
geometry
.
uvs
[
A
];
if
(
x
instanceof
THREE
.
Face3
){
u
=
K
.
geometry
.
vertices
[
x
.
a
].
position
;
t
=
K
.
geometry
.
vertices
[
x
.
b
].
position
;
s
=
K
.
geometry
.
vertices
[
x
.
c
].
position
;
B
.
push
(
u
.
x
,
u
.
y
,
u
.
z
);
B
.
push
(
t
.
x
,
t
.
y
,
t
.
z
);
B
.
push
(
s
.
x
,
s
.
y
,
s
.
z
);
if
(
F
.
length
==
3
){
H
.
push
(
F
[
0
].
x
,
F
[
0
].
y
,
F
[
0
].
z
);
H
.
push
(
F
[
1
].
x
,
F
[
1
].
y
,
F
[
1
].
z
);
H
.
push
(
F
[
2
].
x
,
F
[
2
].
y
,
F
[
2
].
z
)}
else
{
H
.
push
(
J
.
x
,
J
.
y
,
J
.
z
);
H
.
push
(
J
.
x
,
J
.
y
,
J
.
z
);
H
.
push
(
J
.
x
,
J
.
y
,
J
.
z
)}
if
(
w
){
D
.
push
(
w
[
0
].
u
,
w
[
0
].
v
);
D
.
push
(
w
[
1
].
u
,
w
[
1
].
v
);
D
.
push
(
w
[
2
].
u
,
w
[
2
].
v
)}
C
.
push
(
z
,
z
+
1
,
z
+
2
);
E
.
push
(
z
,
z
+
1
);
E
.
push
(
z
,
z
+
2
);
E
.
push
(
z
+
1
,
z
+
2
);
z
+=
3
}
else
{
if
(
x
instanceof
THREE
.
Face4
){
u
=
K
.
geometry
.
vertices
[
x
.
a
].
position
;
t
=
K
.
geometry
.
vertices
[
x
.
b
].
position
;
s
=
K
.
geometry
.
vertices
[
x
.
c
].
position
;
r
=
K
.
geometry
.
vertices
[
x
.
d
].
position
;
B
.
push
(
u
.
x
,
u
.
y
,
u
.
z
);
B
.
push
(
t
.
x
,
t
.
y
,
t
.
z
);
B
.
push
(
s
.
x
,
s
.
y
,
s
.
z
);
B
.
push
(
r
.
x
,
r
.
y
,
r
.
z
);
if
(
F
.
length
==
4
){
H
.
push
(
F
[
0
].
x
,
F
[
0
].
y
,
F
[
0
].
z
);
H
.
push
(
F
[
1
].
x
,
F
[
1
].
y
,
F
[
1
].
z
);
H
.
push
(
F
[
2
].
x
,
F
[
2
].
y
,
F
[
2
].
z
);
H
.
push
(
F
[
3
].
x
,
F
[
3
].
y
,
F
[
3
].
z
)}
else
{
H
.
push
(
J
.
x
,
J
.
y
,
J
.
z
);
H
.
push
(
J
.
x
,
J
.
y
,
J
.
z
);
H
.
push
(
J
.
x
,
J
.
y
,
J
.
z
);
H
.
push
(
J
.
x
,
J
.
y
,
J
.
z
)}
if
(
w
){
D
.
push
(
w
[
0
].
u
,
w
[
0
].
v
);
D
.
push
(
w
[
1
].
u
,
w
[
1
].
v
);
D
.
push
(
w
[
2
].
u
,
w
[
2
].
v
);
D
.
push
(
w
[
3
].
u
,
w
[
3
].
v
)}
C
.
push
(
z
,
z
+
1
,
z
+
2
);
C
.
push
(
z
,
z
+
2
,
z
+
3
);
E
.
push
(
z
,
z
+
1
);
E
.
push
(
z
,
z
+
2
);
E
.
push
(
z
,
z
+
3
);
E
.
push
(
z
+
1
,
z
+
2
);
E
.
push
(
z
+
2
,
z
+
3
);
z
+=
4
}}}
if
(
!
B
.
length
){
return
}
v
.
__webGLVertexBuffer
=
c
.
createBuffer
();
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
v
.
__webGLVertexBuffer
);
c
.
bufferData
(
c
.
ARRAY_BUFFER
,
new
Float32Array
(
B
),
c
.
STATIC_DRAW
);
v
.
__webGLNormalBuffer
=
c
.
createBuffer
();
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
v
.
__webGLNormalBuffer
);
c
.
bufferData
(
c
.
ARRAY_BUFFER
,
new
Float32Array
(
H
),
c
.
STATIC_DRAW
);
v
.
__webGLUVBuffer
=
c
.
createBuffer
();
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
v
.
__webGLUVBuffer
);
c
.
bufferData
(
c
.
ARRAY_BUFFER
,
new
Float32Array
(
D
),
c
.
STATIC_DRAW
);
v
.
__webGLFaceBuffer
=
c
.
createBuffer
();
c
.
bindBuffer
(
c
.
ELEMENT_ARRAY_BUFFER
,
v
.
__webGLFaceBuffer
);
c
.
bufferData
(
c
.
ELEMENT_ARRAY_BUFFER
,
new
Uint16Array
(
C
),
c
.
STATIC_DRAW
);
v
.
__webGLLineBuffer
=
c
.
createBuffer
();
c
.
bindBuffer
(
c
.
ELEMENT_ARRAY_BUFFER
,
v
.
__webGLLineBuffer
);
c
.
bufferData
(
c
.
ELEMENT_ARRAY_BUFFER
,
new
Uint16Array
(
E
),
c
.
STATIC_DRAW
);
v
.
__webGLFaceCount
=
C
.
length
;
v
.
__webGLLineCount
=
E
.
length
};
this
.
renderBuffer
=
function
(
s
,
r
){
if
(
s
instanceof
THREE
.
MeshPhongMaterial
){
mAmbient
=
s
.
ambient
;
mDiffuse
=
s
.
diffuse
;
mSpecular
=
s
.
specular
;
c
.
uniform4f
(
f
.
mAmbient
,
mAmbient
.
r
,
mAmbient
.
g
,
mAmbient
.
b
,
s
.
opacity
);
c
.
uniform4f
(
f
.
mDiffuse
,
mDiffuse
.
r
,
mDiffuse
.
g
,
mDiffuse
.
b
,
s
.
opacity
);
c
.
uniform4f
(
f
.
mSpecular
,
mSpecular
.
r
,
mSpecular
.
g
,
mSpecular
.
b
,
s
.
opacity
);
c
.
uniform1f
(
f
.
mShininess
,
s
.
shininess
);
c
.
uniform1i
(
f
.
material
,
d
)}
else
{
if
(
s
instanceof
THREE
.
MeshColorFillMaterial
){
color
=
s
.
color
;
c
.
uniform4f
(
f
.
mColor
,
color
.
r
*
color
.
a
,
color
.
g
*
color
.
a
,
color
.
b
*
color
.
a
,
color
.
a
);
c
.
uniform1i
(
f
.
material
,
a
)}
else
{
if
(
s
instanceof
THREE
.
MeshColorStrokeMaterial
){
lineWidth
=
s
.
lineWidth
;
color
=
s
.
color
;
c
.
uniform4f
(
f
.
mColor
,
color
.
r
*
color
.
a
,
color
.
g
*
color
.
a
,
color
.
b
*
color
.
a
,
color
.
a
);
c
.
uniform1i
(
f
.
material
,
p
)}
else
{
if
(
s
instanceof
THREE
.
MeshBitmapMaterial
){
if
(
!
s
.
__webGLTexture
&&
s
.
loaded
){
s
.
__webGLTexture
=
c
.
createTexture
();
c
.
bindTexture
(
c
.
TEXTURE_2D
,
s
.
__webGLTexture
);
c
.
texImage2D
(
c
.
TEXTURE_2D
,
0
,
c
.
RGBA
,
c
.
RGBA
,
c
.
UNSIGNED_BYTE
,
s
.
bitmap
);
c
.
texParameteri
(
c
.
TEXTURE_2D
,
c
.
TEXTURE_MAG_FILTER
,
c
.
LINEAR
);
c
.
texParameteri
(
c
.
TEXTURE_2D
,
c
.
TEXTURE_MIN_FILTER
,
c
.
LINEAR_MIPMAP_LINEAR
);
c
.
generateMipmap
(
c
.
TEXTURE_2D
);
c
.
bindTexture
(
c
.
TEXTURE_2D
,
null
)}
c
.
activeTexture
(
c
.
TEXTURE0
);
c
.
bindTexture
(
c
.
TEXTURE_2D
,
s
.
__webGLTexture
);
c
.
uniform1i
(
f
.
tDiffuse
,
0
);
c
.
uniform1i
(
f
.
material
,
j
)}}}}
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
r
.
__webGLVertexBuffer
);
c
.
vertexAttribPointer
(
f
.
position
,
3
,
c
.
FLOAT
,
false
,
0
,
0
);
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
r
.
__webGLNormalBuffer
);
c
.
vertexAttribPointer
(
f
.
normal
,
3
,
c
.
FLOAT
,
false
,
0
,
0
);
if
(
s
instanceof
THREE
.
MeshBitmapMaterial
){
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
r
.
__webGLUVBuffer
);
c
.
enableVertexAttribArray
(
f
.
uv
);
c
.
vertexAttribPointer
(
f
.
uv
,
2
,
c
.
FLOAT
,
false
,
0
,
0
)}
else
{
c
.
disableVertexAttribArray
(
f
.
uv
)}
if
(
s
instanceof
THREE
.
MeshBitmapMaterial
||
s
instanceof
THREE
.
MeshColorFillMaterial
||
s
instanceof
THREE
.
MeshPhongMaterial
){
c
.
bindBuffer
(
c
.
ELEMENT_ARRAY_BUFFER
,
r
.
__webGLFaceBuffer
);
c
.
drawElements
(
c
.
TRIANGLES
,
r
.
__webGLFaceCount
,
c
.
UNSIGNED_SHORT
,
0
)}
else
{
if
(
s
instanceof
THREE
.
MeshColorStrokeMaterial
){
c
.
lineWidth
(
lineWidth
);
c
.
bindBuffer
(
c
.
ELEMENT_ARRAY_BUFFER
,
r
.
__webGLLineBuffer
);
c
.
drawElements
(
c
.
LINES
,
r
.
__webGLLineCount
,
c
.
UNSIGNED_SHORT
,
0
)}}};
this
.
renderMesh
=
function
(
t
,
w
){
var
v
,
s
,
r
,
u
,
z
,
x
,
y
,
A
;
for
(
z
in
t
.
materialFaceGroup
){
A
=
t
.
materialFaceGroup
[
z
];
if
(
!
A
.
__webGLVertexBuffer
){
this
.
createBuffers
(
t
,
z
)}
for
(
r
=
0
,
u
=
t
.
material
.
length
;
r
<
u
;
r
++
){
y
=
t
.
material
[
r
];
if
(
y
instanceof
THREE
.
MeshFaceMaterial
){
for
(
v
=
0
,
s
=
A
.
material
.
length
;
v
<
s
;
v
++
){
x
=
A
.
material
[
v
];
this
.
renderBuffer
(
x
,
A
)}}
else
{
x
=
y
;
this
.
renderBuffer
(
x
,
A
)}}}};
this
.
setupMatrices
=
function
(
r
,
s
){
r
.
autoUpdateMatrix
&&
r
.
updateMatrix
();
q
.
multiply
(
s
.
matrix
,
r
.
matrix
);
f
.
viewMatrixArray
=
new
Float32Array
(
s
.
matrix
.
flatten
());
f
.
modelViewMatrixArray
=
new
Float32Array
(
q
.
flatten
());
f
.
projectionMatrixArray
=
new
Float32Array
(
s
.
projectionMatrix
.
flatten
());
m
=
THREE
.
Matrix4
.
makeInvert3x3
(
q
).
transpose
();
f
.
normalMatrixArray
=
new
Float32Array
(
m
.
m
);
c
.
uniformMatrix4fv
(
f
.
viewMatrix
,
false
,
f
.
viewMatrixArray
);
c
.
uniformMatrix4fv
(
f
.
modelViewMatrix
,
false
,
f
.
modelViewMatrixArray
);
c
.
uniformMatrix4fv
(
f
.
projectionMatrix
,
false
,
f
.
projectionMatrixArray
);
c
.
uniformMatrix3fv
(
f
.
normalMatrix
,
false
,
f
.
normalMatrixArray
);
c
.
uniformMatrix4fv
(
f
.
objMatrix
,
false
,
new
Float32Array
(
r
.
matrix
.
flatten
()))};
this
.
render
=
function
(
u
,
t
){
var
v
,
s
,
r
;
if
(
this
.
autoClear
){
this
.
clear
()}
t
.
autoUpdateMatrix
&&
t
.
updateMatrix
();
c
.
uniform3f
(
f
.
cameraPosition
,
t
.
position
.
x
,
t
.
position
.
y
,
t
.
position
.
z
);
this
.
setupLights
(
u
);
for
(
v
=
0
,
s
=
u
.
objects
.
length
;
v
<
s
;
v
++
){
r
=
u
.
objects
[
v
];
this
.
setupMatrices
(
r
,
t
);
if
(
r
instanceof
THREE
.
Mesh
){
this
.
renderMesh
(
r
,
t
)}
else
{
if
(
r
instanceof
THREE
.
Line
){}
else
{
if
(
r
instanceof
THREE
.
Particle
){}}}}};
this
.
setFaceCulling
=
function
(
s
,
r
){
if
(
s
){
if
(
!
r
||
r
==
"
ccw
"
){
c
.
frontFace
(
c
.
CCW
)}
else
{
c
.
frontFace
(
c
.
CW
)}
if
(
s
==
"
back
"
){
c
.
cullFace
(
c
.
BACK
)}
else
{
if
(
s
==
"
front
"
){
c
.
cullFace
(
c
.
FRONT
)}
else
{
c
.
cullFace
(
c
.
FRONT_AND_BACK
)}}
c
.
enable
(
c
.
CULL_FACE
)}
else
{
c
.
disable
(
c
.
CULL_FACE
)}};
function
i
(){
try
{
c
=
n
.
getContext
(
"
experimental-webgl
"
,{
antialias
:
true
})}
catch
(
r
){}
if
(
!
c
){
alert
(
"
WebGL not supported
"
);
throw
"
cannot create webgl context
"
}
c
.
clearColor
(
0
,
0
,
0
,
1
);
c
.
clearDepth
(
1
);
c
.
enable
(
c
.
DEPTH_TEST
);
c
.
depthFunc
(
c
.
LEQUAL
);
c
.
frontFace
(
c
.
CCW
);
c
.
cullFace
(
c
.
BACK
);
c
.
enable
(
c
.
CULL_FACE
);
c
.
enable
(
c
.
BLEND
);
c
.
blendFunc
(
c
.
ONE
,
c
.
ONE_MINUS_SRC_ALPHA
);
c
.
clearColor
(
0
,
0
,
0
,
0
)}
function
o
(
r
,
s
){
var
t
=
[
"
#ifdef GL_ES
"
,
"
precision highp float;
"
,
"
#endif
"
,
r
?
"
#define MAX_DIR_LIGHTS
"
+
r
:
""
,
s
?
"
#define MAX_POINT_LIGHTS
"
+
s
:
""
,
"
uniform int material;
"
,
"
uniform sampler2D tDiffuse;
"
,
"
uniform vec4 mColor;
"
,
"
uniform vec4 mAmbient;
"
,
"
uniform vec4 mDiffuse;
"
,
"
uniform vec4 mSpecular;
"
,
"
uniform float mShininess;
"
,
"
uniform int pointLightNumber;
"
,
"
uniform int directionalLightNumber;
"
,
r
?
"
uniform mat4 viewMatrix;
"
:
""
,
r
?
"
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
"
:
""
,
"
varying vec3 vNormal;
"
,
"
varying vec2 vUv;
"
,
"
varying vec3 vLightWeighting;
"
,
s
?
"
varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];
"
:
""
,
"
varying vec3 vViewPosition;
"
,
"
void main() {
"
,
"
if ( material == 3 ) {
"
,
"
vec3 normal = normalize( vNormal );
"
,
"
vec3 viewPosition = normalize( vViewPosition );
"
,
s
?
"
vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
s
?
"
vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
s
?
"
for( int i = 0; i < pointLightNumber; i++ ) {
"
:
""
,
s
?
"
vec3 pointVector = normalize( vPointLightVector[ i ] );
"
:
""
,
s
?
"
vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );
"
:
""
,
s
?
"
float pointDotNormalHalf = dot( normal, pointHalfVector );
"
:
""
,
s
?
"
float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );
"
:
""
,
s
?
"
float pointSpecularWeight = 0.0;
"
:
""
,
s
?
"
if ( pointDotNormalHalf >= 0.0 )
"
:
""
,
s
?
"
pointSpecularWeight = pow( pointDotNormalHalf, mShininess );
"
:
""
,
s
?
"
pointDiffuse += mDiffuse * pointDiffuseWeight;
"
:
""
,
s
?
"
pointSpecular += mSpecular * pointSpecularWeight;
"
:
""
,
s
?
"
}
"
:
""
,
r
?
"
vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
r
?
"
vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
r
?
"
for( int i = 0; i < directionalLightNumber; i++ ) {
"
:
""
,
r
?
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
:
""
,
r
?
"
vec3 dirVector = normalize( lDirection.xyz );
"
:
""
,
r
?
"
vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );
"
:
""
,
r
?
"
float dirDotNormalHalf = dot( normal, dirHalfVector );
"
:
""
,
r
?
"
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
"
:
""
,
r
?
"
float dirSpecularWeight = 0.0;
"
:
""
,
r
?
"
if ( dirDotNormalHalf >= 0.0 )
"
:
""
,
r
?
"
dirSpecularWeight = pow( dirDotNormalHalf, mShininess );
"
:
""
,
r
?
"
dirDiffuse += mDiffuse * dirDiffuseWeight;
"
:
""
,
r
?
"
dirSpecular += mSpecular * dirSpecularWeight;
"
:
""
,
r
?
"
}
"
:
""
,
"
vec4 totalLight = mAmbient;
"
,
r
?
"
totalLight += dirDiffuse + dirSpecular;
"
:
""
,
s
?
"
totalLight += pointDiffuse + pointSpecular;
"
:
""
,
"
gl_FragColor = vec4( totalLight.xyz * vLightWeighting, 1.0 );
"
,
"
} else if ( material == 2 ) {
"
,
"
vec4 texelColor = texture2D( tDiffuse, vUv );
"
,
"
gl_FragColor = vec4( texelColor.rgb * vLightWeighting, texelColor.a );
"
,
"
} else if ( material == 1 ) {
"
,
"
gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );
"
,
"
} else {
"
,
"
gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );
"
,
"
}
"
,
"
}
"
];
return
t
.
join
(
"
\n
"
)}
function
g
(
r
,
s
){
var
t
=
[
r
?
"
#define MAX_DIR_LIGHTS
"
+
r
:
""
,
s
?
"
#define MAX_POINT_LIGHTS
"
+
s
:
""
,
"
attribute vec3 position;
"
,
"
attribute vec3 normal;
"
,
"
attribute vec2 uv;
"
,
"
uniform vec3 cameraPosition;
"
,
"
uniform bool enableLighting;
"
,
"
uniform int pointLightNumber;
"
,
"
uniform int directionalLightNumber;
"
,
"
uniform vec3 ambientLightColor;
"
,
r
?
"
uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
"
:
""
,
r
?
"
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
"
:
""
,
s
?
"
uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
"
:
""
,
s
?
"
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
"
:
""
,
"
uniform mat4 objMatrix;
"
,
"
uniform mat4 viewMatrix;
"
,
"
uniform mat4 modelViewMatrix;
"
,
"
uniform mat4 projectionMatrix;
"
,
"
uniform mat3 normalMatrix;
"
,
"
varying vec3 vNormal;
"
,
"
varying vec2 vUv;
"
,
"
varying vec3 vLightWeighting;
"
,
s
?
"
varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];
"
:
""
,
"
varying vec3 vViewPosition;
"
,
"
void main(void) {
"
,
"
vec4 mPosition = objMatrix * vec4( position, 1.0 );
"
,
"
vViewPosition = cameraPosition - mPosition.xyz;
"
,
"
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
"
vec3 transformedNormal = normalize( normalMatrix * normal );
"
,
"
if ( !enableLighting ) {
"
,
"
vLightWeighting = vec3( 1.0, 1.0, 1.0 );
"
,
"
} else {
"
,
"
vLightWeighting = ambientLightColor;
"
,
r
?
"
for( int i = 0; i < directionalLightNumber; i++ ) {
"
:
""
,
r
?
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
:
""
,
r
?
"
float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );
"
:
""
,
r
?
"
vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;
"
:
""
,
r
?
"
}
"
:
""
,
s
?
"
for( int i = 0; i < pointLightNumber; i++ ) {
"
:
""
,
s
?
"
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
"
:
""
,
s
?
"
vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );
"
:
""
,
s
?
"
float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );
"
:
""
,
s
?
"
vLightWeighting += pointLightColor[ i ] * pointLightWeighting;
"
:
""
,
s
?
"
}
"
:
""
,
"
}
"
,
"
vNormal = transformedNormal;
"
,
"
vUv = uv;
"
,
"
gl_Position = projectionMatrix * mvPosition;
"
,
"
}
"
];
return
t
.
join
(
"
\n
"
)}
function
h
(
r
,
s
){
f
=
c
.
createProgram
();
c
.
attachShader
(
f
,
b
(
"
fragment
"
,
o
(
r
,
s
)));
c
.
attachShader
(
f
,
b
(
"
vertex
"
,
g
(
r
,
s
)));
c
.
linkProgram
(
f
);
if
(
!
c
.
getProgramParameter
(
f
,
c
.
LINK_STATUS
)){
alert
(
"
Could not initialise shaders
"
)}
c
.
useProgram
(
f
);
f
.
viewMatrix
=
c
.
getUniformLocation
(
f
,
"
viewMatrix
"
);
f
.
modelViewMatrix
=
c
.
getUniformLocation
(
f
,
"
modelViewMatrix
"
);
f
.
projectionMatrix
=
c
.
getUniformLocation
(
f
,
"
projectionMatrix
"
);
f
.
normalMatrix
=
c
.
getUniformLocation
(
f
,
"
normalMatrix
"
);
f
.
objMatrix
=
c
.
getUniformLocation
(
f
,
"
objMatrix
"
);
f
.
cameraPosition
=
c
.
getUniformLocation
(
f
,
"
cameraPosition
"
);
f
.
enableLighting
=
c
.
getUniformLocation
(
f
,
"
enableLighting
"
);
f
.
ambientLightColor
=
c
.
getUniformLocation
(
f
,
"
ambientLightColor
"
);
if
(
r
){
f
.
directionalLightNumber
=
c
.
getUniformLocation
(
f
,
"
directionalLightNumber
"
);
f
.
directionalLightColor
=
c
.
getUniformLocation
(
f
,
"
directionalLightColor
"
);
f
.
directionalLightDirection
=
c
.
getUniformLocation
(
f
,
"
directionalLightDirection
"
)}
if
(
s
){
f
.
pointLightNumber
=
c
.
getUniformLocation
(
f
,
"
pointLightNumber
"
);
f
.
pointLightColor
=
c
.
getUniformLocation
(
f
,
"
pointLightColor
"
);
f
.
pointLightPosition
=
c
.
getUniformLocation
(
f
,
"
pointLightPosition
"
)}
f
.
material
=
c
.
getUniformLocation
(
f
,
"
material
"
);
f
.
mColor
=
c
.
getUniformLocation
(
f
,
"
mColor
"
);
f
.
mAmbient
=
c
.
getUniformLocation
(
f
,
"
mAmbient
"
);
f
.
mDiffuse
=
c
.
getUniformLocation
(
f
,
"
mDiffuse
"
);
f
.
mSpecular
=
c
.
getUniformLocation
(
f
,
"
mSpecular
"
);
f
.
mShininess
=
c
.
getUniformLocation
(
f
,
"
mShininess
"
);
f
.
tDiffuse
=
c
.
getUniformLocation
(
f
,
"
tDiffuse
"
);
c
.
uniform1i
(
f
.
tDiffuse
,
0
);
f
.
position
=
c
.
getAttribLocation
(
f
,
"
position
"
);
c
.
enableVertexAttribArray
(
f
.
position
);
f
.
normal
=
c
.
getAttribLocation
(
f
,
"
normal
"
);
c
.
enableVertexAttribArray
(
f
.
normal
);
f
.
uv
=
c
.
getAttribLocation
(
f
,
"
uv
"
);
c
.
enableVertexAttribArray
(
f
.
uv
);
f
.
viewMatrixArray
=
new
Float32Array
(
16
);
f
.
modelViewMatrixArray
=
new
Float32Array
(
16
);
f
.
projectionMatrixArray
=
new
Float32Array
(
16
)}
function
b
(
s
,
r
){
var
t
;
if
(
s
==
"
fragment
"
){
t
=
c
.
createShader
(
c
.
FRAGMENT_SHADER
)}
else
{
if
(
s
==
"
vertex
"
){
t
=
c
.
createShader
(
c
.
VERTEX_SHADER
)}}
c
.
shaderSource
(
t
,
r
);
c
.
compileShader
(
t
);
if
(
!
c
.
getShaderParameter
(
t
,
c
.
COMPILE_STATUS
)){
alert
(
c
.
getShaderInfoLog
(
t
));
return
null
}
return
t
}};
THREE
.
RenderableFace3
=
function
(){
this
.
v1
=
new
THREE
.
Vector2
();
this
.
v2
=
new
THREE
.
Vector2
();
this
.
v3
=
new
THREE
.
Vector2
();
this
.
centroidWorld
=
new
THREE
.
Vector3
();
this
.
centroidScreen
=
new
THREE
.
Vector3
();
this
.
normalWorld
=
new
THREE
.
Vector3
();
this
.
z
=
null
;
this
.
color
=
null
;
this
.
material
=
null
};
THREE
.
RenderableFace4
=
function
(){
this
.
v1
=
new
THREE
.
Vector2
();
this
.
v2
=
new
THREE
.
Vector2
();
this
.
v3
=
new
THREE
.
Vector2
();
this
.
v4
=
new
THREE
.
Vector2
();
this
.
centroidWorld
=
new
THREE
.
Vector3
();
this
.
centroidScreen
=
new
THREE
.
Vector3
();
this
.
normalWorld
=
new
THREE
.
Vector3
();
this
.
z
=
null
;
this
.
color
=
null
;
this
.
material
=
null
};
THREE
.
RenderableParticle
=
function
(){
this
.
x
=
null
;
this
.
y
=
null
;
this
.
z
=
null
;
this
.
rotation
=
null
;
this
.
scale
=
new
THREE
.
Vector2
();
this
.
color
=
null
;
this
.
material
=
null
};
THREE
.
RenderableLine
=
function
(){
this
.
v1
=
new
THREE
.
Vector2
();
this
.
v2
=
new
THREE
.
Vector2
();
this
.
z
=
null
;
this
.
color
=
null
;
this
.
material
=
null
};
\ No newline at end of file
var
THREE
=
THREE
||
{};
THREE
.
Color
=
function
(
a
){
this
.
autoUpdate
=
true
;
this
.
setHex
(
a
)};
THREE
.
Color
.
prototype
=
{
setRGBA
:
function
(
f
,
e
,
c
,
d
){
this
.
r
=
f
;
this
.
g
=
e
;
this
.
b
=
c
;
this
.
a
=
d
;
if
(
this
.
autoUpdate
){
this
.
updateHex
();
this
.
updateStyleString
()}},
setHex
:
function
(
a
){
this
.
hex
=
(
~~
a
).
toString
(
16
).
length
<
8
?
255
<<
24
^
a
:
a
;
if
(
this
.
autoUpdate
){
this
.
updateRGBA
();
this
.
updateStyleString
()}},
copyRGB
:
function
(
a
){
this
.
r
=
a
.
r
;
this
.
g
=
a
.
g
;
this
.
b
=
a
.
b
},
copyRGBA
:
function
(
a
){
this
.
r
=
a
.
r
;
this
.
g
=
a
.
g
;
this
.
b
=
a
.
b
;
this
.
a
=
a
.
a
},
multiplySelfRGB
:
function
(
a
){
this
.
r
*=
a
.
r
;
this
.
g
*=
a
.
g
;
this
.
b
*=
a
.
b
},
updateHex
:
function
(){
this
.
hex
=~~
(
this
.
a
*
255
)
<<
24
^~~
(
this
.
r
*
255
)
<<
16
^~~
(
this
.
g
*
255
)
<<
8
^~~
(
this
.
b
*
255
)},
updateRGBA
:
function
(){
this
.
a
=
(
this
.
hex
>>
24
&
255
)
/
255
;
this
.
r
=
(
this
.
hex
>>
16
&
255
)
/
255
;
this
.
g
=
(
this
.
hex
>>
8
&
255
)
/
255
;
this
.
b
=
(
this
.
hex
&
255
)
/
255
},
updateStyleString
:
function
(){
this
.
__styleString
=
"
rgba(
"
+~~
(
this
.
r
*
255
)
+
"
,
"
+~~
(
this
.
g
*
255
)
+
"
,
"
+~~
(
this
.
b
*
255
)
+
"
,
"
+
this
.
a
+
"
)
"
},
toString
:
function
(){
return
"
THREE.Color ( r:
"
+
this
.
r
+
"
, g:
"
+
this
.
g
+
"
, b:
"
+
this
.
b
+
"
, a:
"
+
this
.
a
+
"
, hex:
"
+
this
.
hex
+
"
)
"
}};
THREE
.
Vector2
=
function
(
a
,
b
){
this
.
x
=
a
||
0
;
this
.
y
=
b
||
0
};
THREE
.
Vector2
.
prototype
=
{
set
:
function
(
a
,
b
){
this
.
x
=
a
;
this
.
y
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
x
=
a
.
x
;
this
.
y
=
a
.
y
;
return
this
},
addSelf
:
function
(
a
){
this
.
x
+=
a
.
x
;
this
.
y
+=
a
.
y
;
return
this
},
add
:
function
(
b
,
a
){
this
.
x
=
b
.
x
+
a
.
x
;
this
.
y
=
b
.
y
+
a
.
y
;
return
this
},
subSelf
:
function
(
a
){
this
.
x
-=
a
.
x
;
this
.
y
-=
a
.
y
;
return
this
},
sub
:
function
(
b
,
a
){
this
.
x
=
b
.
x
-
a
.
x
;
this
.
y
=
b
.
y
-
a
.
y
;
return
this
},
multiplyScalar
:
function
(
a
){
this
.
x
*=
a
;
this
.
y
*=
a
;
return
this
},
unit
:
function
(){
this
.
multiplyScalar
(
1
/
this
.
length
());
return
this
},
length
:
function
(){
return
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
)},
lengthSq
:
function
(){
return
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
},
negate
:
function
(){
this
.
x
=-
this
.
x
;
this
.
y
=-
this
.
y
;
return
this
},
clone
:
function
(){
return
new
THREE
.
Vector2
(
this
.
x
,
this
.
y
)},
toString
:
function
(){
return
"
THREE.Vector2 (
"
+
this
.
x
+
"
,
"
+
this
.
y
+
"
)
"
}};
THREE
.
Vector3
=
function
(
a
,
c
,
b
){
this
.
x
=
a
||
0
;
this
.
y
=
c
||
0
;
this
.
z
=
b
||
0
};
THREE
.
Vector3
.
prototype
=
{
set
:
function
(
a
,
c
,
b
){
this
.
x
=
a
;
this
.
y
=
c
;
this
.
z
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
x
=
a
.
x
;
this
.
y
=
a
.
y
;
this
.
z
=
a
.
z
;
return
this
},
add
:
function
(
b
,
a
){
this
.
x
=
b
.
x
+
a
.
x
;
this
.
y
=
b
.
y
+
a
.
y
;
this
.
z
=
b
.
z
+
a
.
z
;
return
this
},
addSelf
:
function
(
a
){
this
.
x
+=
a
.
x
;
this
.
y
+=
a
.
y
;
this
.
z
+=
a
.
z
;
return
this
},
addScalar
:
function
(
a
){
this
.
x
+=
a
;
this
.
y
+=
a
;
this
.
z
+=
a
;
return
this
},
sub
:
function
(
b
,
a
){
this
.
x
=
b
.
x
-
a
.
x
;
this
.
y
=
b
.
y
-
a
.
y
;
this
.
z
=
b
.
z
-
a
.
z
;
return
this
},
subSelf
:
function
(
a
){
this
.
x
-=
a
.
x
;
this
.
y
-=
a
.
y
;
this
.
z
-=
a
.
z
;
return
this
},
cross
:
function
(
b
,
a
){
this
.
x
=
b
.
y
*
a
.
z
-
b
.
z
*
a
.
y
;
this
.
y
=
b
.
z
*
a
.
x
-
b
.
x
*
a
.
z
;
this
.
z
=
b
.
x
*
a
.
y
-
b
.
y
*
a
.
x
;
return
this
},
crossSelf
:
function
(
c
){
var
b
=
this
.
x
,
a
=
this
.
y
,
d
=
this
.
z
;
this
.
x
=
a
*
c
.
z
-
d
*
c
.
y
;
this
.
y
=
d
*
c
.
x
-
b
*
c
.
z
;
this
.
z
=
b
*
c
.
y
-
a
*
c
.
x
;
return
this
},
multiplySelf
:
function
(
a
){
this
.
x
*=
a
.
x
;
this
.
y
*=
a
.
y
;
this
.
z
*=
a
.
z
;
return
this
},
multiplyScalar
:
function
(
a
){
this
.
x
*=
a
;
this
.
y
*=
a
;
this
.
z
*=
a
;
return
this
},
divideScalar
:
function
(
a
){
this
.
x
/=
a
;
this
.
y
/=
a
;
this
.
z
/=
a
;
return
this
},
dot
:
function
(
a
){
return
this
.
x
*
a
.
x
+
this
.
y
*
a
.
y
+
this
.
z
*
a
.
z
},
distanceTo
:
function
(
a
){
return
Math
.
sqrt
(
this
.
distanceToSquared
(
a
))},
distanceToSquared
:
function
(
d
){
var
c
=
this
.
x
-
d
.
x
,
b
=
this
.
y
-
d
.
y
,
a
=
this
.
z
-
d
.
z
;
return
c
*
c
+
b
*
b
+
a
*
a
},
length
:
function
(){
return
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
)},
lengthSq
:
function
(){
return
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
},
negate
:
function
(){
this
.
x
=-
this
.
x
;
this
.
y
=-
this
.
y
;
this
.
z
=-
this
.
z
;
return
this
},
normalize
:
function
(){
if
(
this
.
length
()
>
0
){
this
.
multiplyScalar
(
1
/
this
.
length
())}
else
{
this
.
multiplyScalar
(
0
)}
return
this
},
setLength
:
function
(
a
){
return
this
.
normalize
().
multiplyScalar
(
a
)},
isZero
:
function
(){
var
a
=
0.0001
;
return
(
Math
.
abs
(
this
.
x
)
<
a
)
&&
(
Math
.
abs
(
this
.
y
)
<
a
)
&&
(
Math
.
abs
(
this
.
z
)
<
a
)},
clone
:
function
(){
return
new
THREE
.
Vector3
(
this
.
x
,
this
.
y
,
this
.
z
)},
toString
:
function
(){
return
"
THREE.Vector3 (
"
+
this
.
x
+
"
,
"
+
this
.
y
+
"
,
"
+
this
.
z
+
"
)
"
}};
THREE
.
Vector4
=
function
(
a
,
d
,
c
,
b
){
this
.
x
=
a
||
0
;
this
.
y
=
d
||
0
;
this
.
z
=
c
||
0
;
this
.
w
=
b
||
1
};
THREE
.
Vector4
.
prototype
=
{
set
:
function
(
a
,
d
,
c
,
b
){
this
.
x
=
a
;
this
.
y
=
d
;
this
.
z
=
c
;
this
.
w
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
x
=
a
.
x
;
this
.
y
=
a
.
y
;
this
.
z
=
a
.
z
;
this
.
w
=
a
.
w
;
return
this
},
add
:
function
(
b
,
a
){
this
.
x
=
b
.
x
+
a
.
x
;
this
.
y
=
b
.
y
+
a
.
y
;
this
.
z
=
b
.
z
+
a
.
z
;
this
.
w
=
b
.
w
+
a
.
w
;
return
this
},
addSelf
:
function
(
a
){
this
.
x
+=
a
.
x
;
this
.
y
+=
a
.
y
;
this
.
z
+=
a
.
z
;
this
.
w
+=
a
.
w
;
return
this
},
sub
:
function
(
b
,
a
){
this
.
x
=
b
.
x
-
a
.
x
;
this
.
y
=
b
.
y
-
a
.
y
;
this
.
z
=
b
.
z
-
a
.
z
;
this
.
w
=
b
.
w
-
a
.
w
;
return
this
},
subSelf
:
function
(
a
){
this
.
x
-=
a
.
x
;
this
.
y
-=
a
.
y
;
this
.
z
-=
a
.
z
;
this
.
w
-=
a
.
w
;
return
this
},
clone
:
function
(){
return
new
THREE
.
Vector4
(
this
.
x
,
this
.
y
,
this
.
z
,
this
.
w
)},
toString
:
function
(){
return
"
THREE.Vector4 (
"
+
this
.
x
+
"
,
"
+
this
.
y
+
"
,
"
+
this
.
z
+
"
,
"
+
this
.
w
+
"
)
"
}};
THREE
.
Ray
=
function
(
a
,
b
){
this
.
origin
=
a
||
new
THREE
.
Vector3
();
this
.
direction
=
b
||
new
THREE
.
Vector3
()};
THREE
.
Ray
.
prototype
=
{
intersectScene
:
function
(
f
){
var
c
,
a
,
b
,
e
=
f
.
objects
,
d
=
[];
for
(
c
=
0
,
a
=
e
.
length
;
c
<
a
;
c
++
){
b
=
e
[
c
];
if
(
b
instanceof
THREE
.
Mesh
){
d
=
d
.
concat
(
this
.
intersectObject
(
b
))}}
d
.
sort
(
function
(
h
,
g
){
return
h
.
distance
-
g
.
distance
});
return
d
},
intersectObject
:
function
(
w
){
var
n
,
j
,
i
,
t
,
s
,
q
,
p
,
v
,
k
,
x
,
u
,
r
,
g
=
w
.
geometry
,
h
=
g
.
vertices
,
o
,
e
=
[],
m
;
for
(
n
=
0
,
j
=
g
.
faces
.
length
;
n
<
j
;
n
++
){
i
=
g
.
faces
[
n
];
u
=
this
.
origin
.
clone
();
r
=
this
.
direction
.
clone
();
t
=
w
.
matrix
.
transform
(
h
[
i
.
a
].
position
.
clone
());
s
=
w
.
matrix
.
transform
(
h
[
i
.
b
].
position
.
clone
());
q
=
w
.
matrix
.
transform
(
h
[
i
.
c
].
position
.
clone
());
p
=
i
instanceof
THREE
.
Face4
?
w
.
matrix
.
transform
(
h
[
i
.
d
].
position
.
clone
()):
null
;
v
=
w
.
matrixRotation
.
transform
(
i
.
normal
.
clone
());
k
=
r
.
dot
(
v
);
if
(
k
<
0
){
x
=
v
.
dot
(
new
THREE
.
Vector3
().
sub
(
t
,
u
))
/
k
;
m
=
u
.
addSelf
(
r
.
multiplyScalar
(
x
));
if
(
i
instanceof
THREE
.
Face3
){
if
(
l
(
m
,
t
,
s
,
q
)){
o
=
{
distance
:
this
.
origin
.
distanceTo
(
m
),
point
:
m
,
face
:
i
,
object
:
w
};
e
.
push
(
o
)}}
else
{
if
(
i
instanceof
THREE
.
Face4
){
if
(
l
(
m
,
t
,
s
,
p
)
||
l
(
m
,
s
,
q
,
p
)){
o
=
{
distance
:
this
.
origin
.
distanceTo
(
m
),
point
:
m
,
face
:
i
,
object
:
w
};
e
.
push
(
o
)}}}}}
return
e
;
function
l
(
d
,
G
,
D
,
B
){
var
J
=
B
.
clone
().
subSelf
(
G
),
H
=
D
.
clone
().
subSelf
(
G
),
E
=
d
.
clone
().
subSelf
(
G
),
F
=
J
.
dot
(
J
),
C
=
J
.
dot
(
H
),
A
=
J
.
dot
(
E
),
z
=
H
.
dot
(
H
),
f
=
H
.
dot
(
E
),
y
=
1
/
(
F
*
z
-
C
*
C
),
K
=
(
z
*
A
-
C
*
f
)
*
y
,
I
=
(
F
*
f
-
C
*
A
)
*
y
;
return
(
K
>
0
)
&&
(
I
>
0
)
&&
(
K
+
I
<
1
)}}};
THREE
.
Rectangle
=
function
(){
var
e
,
g
,
h
,
d
,
a
,
c
,
f
=
true
;
function
b
(){
a
=
h
-
e
;
c
=
d
-
g
}
this
.
getX
=
function
(){
return
e
};
this
.
getY
=
function
(){
return
g
};
this
.
getWidth
=
function
(){
return
a
};
this
.
getHeight
=
function
(){
return
c
};
this
.
getLeft
=
function
(){
return
e
};
this
.
getTop
=
function
(){
return
g
};
this
.
getRight
=
function
(){
return
h
};
this
.
getBottom
=
function
(){
return
d
};
this
.
set
=
function
(
l
,
k
,
j
,
i
){
f
=
false
;
e
=
l
;
g
=
k
;
h
=
j
;
d
=
i
;
b
()};
this
.
addPoint
=
function
(
i
,
j
){
if
(
f
){
f
=
false
;
e
=
i
;
g
=
j
;
h
=
i
;
d
=
j
}
else
{
e
=
Math
.
min
(
e
,
i
);
g
=
Math
.
min
(
g
,
j
);
h
=
Math
.
max
(
h
,
i
);
d
=
Math
.
max
(
d
,
j
)}
b
()};
this
.
addRectangle
=
function
(
i
){
if
(
f
){
f
=
false
;
e
=
i
.
getLeft
();
g
=
i
.
getTop
();
h
=
i
.
getRight
();
d
=
i
.
getBottom
()}
else
{
e
=
Math
.
min
(
e
,
i
.
getLeft
());
g
=
Math
.
min
(
g
,
i
.
getTop
());
h
=
Math
.
max
(
h
,
i
.
getRight
());
d
=
Math
.
max
(
d
,
i
.
getBottom
())}
b
()};
this
.
inflate
=
function
(
i
){
e
-=
i
;
g
-=
i
;
h
+=
i
;
d
+=
i
;
b
()};
this
.
minSelf
=
function
(
i
){
e
=
Math
.
max
(
e
,
i
.
getLeft
());
g
=
Math
.
max
(
g
,
i
.
getTop
());
h
=
Math
.
min
(
h
,
i
.
getRight
());
d
=
Math
.
min
(
d
,
i
.
getBottom
());
b
()};
this
.
instersects
=
function
(
i
){
return
Math
.
min
(
h
,
i
.
getRight
())
-
Math
.
max
(
e
,
i
.
getLeft
())
>=
0
&&
Math
.
min
(
d
,
i
.
getBottom
())
-
Math
.
max
(
g
,
i
.
getTop
())
>=
0
};
this
.
empty
=
function
(){
f
=
true
;
e
=
0
;
g
=
0
;
h
=
0
;
d
=
0
;
b
()};
this
.
isEmpty
=
function
(){
return
f
};
this
.
toString
=
function
(){
return
"
THREE.Rectangle ( left:
"
+
e
+
"
, right:
"
+
h
+
"
, top:
"
+
g
+
"
, bottom:
"
+
d
+
"
, width:
"
+
a
+
"
, height:
"
+
c
+
"
)
"
}};
THREE
.
Matrix3
=
function
(){
this
.
m
=
[]};
THREE
.
Matrix3
.
prototype
=
{
transpose
:
function
(){
var
a
;
a
=
this
.
m
[
1
];
this
.
m
[
1
]
=
this
.
m
[
3
];
this
.
m
[
3
]
=
a
;
a
=
this
.
m
[
2
];
this
.
m
[
2
]
=
this
.
m
[
6
];
this
.
m
[
6
]
=
a
;
a
=
this
.
m
[
5
];
this
.
m
[
5
]
=
this
.
m
[
7
];
this
.
m
[
7
]
=
a
;
return
this
}};
THREE
.
Matrix4
=
function
(){
this
.
_x
=
new
THREE
.
Vector3
();
this
.
_y
=
new
THREE
.
Vector3
();
this
.
_z
=
new
THREE
.
Vector3
()};
THREE
.
Matrix4
.
prototype
=
{
n11
:
1
,
n12
:
0
,
n13
:
0
,
n14
:
0
,
n21
:
0
,
n22
:
1
,
n23
:
0
,
n24
:
0
,
n31
:
0
,
n32
:
0
,
n33
:
1
,
n34
:
0
,
n41
:
0
,
n42
:
0
,
n43
:
0
,
n44
:
1
,
identity
:
function
(){
this
.
n11
=
1
;
this
.
n12
=
0
;
this
.
n13
=
0
;
this
.
n14
=
0
;
this
.
n21
=
0
;
this
.
n22
=
1
;
this
.
n23
=
0
;
this
.
n24
=
0
;
this
.
n31
=
0
;
this
.
n32
=
0
;
this
.
n33
=
1
;
this
.
n34
=
0
;
this
.
n41
=
0
;
this
.
n42
=
0
;
this
.
n43
=
0
;
this
.
n44
=
1
},
copy
:
function
(
a
){
this
.
n11
=
a
.
n11
;
this
.
n12
=
a
.
n12
;
this
.
n13
=
a
.
n13
;
this
.
n14
=
a
.
n14
;
this
.
n21
=
a
.
n21
;
this
.
n22
=
a
.
n22
;
this
.
n23
=
a
.
n23
;
this
.
n24
=
a
.
n24
;
this
.
n31
=
a
.
n31
;
this
.
n32
=
a
.
n32
;
this
.
n33
=
a
.
n33
;
this
.
n34
=
a
.
n34
;
this
.
n41
=
a
.
n41
;
this
.
n42
=
a
.
n42
;
this
.
n43
=
a
.
n43
;
this
.
n44
=
a
.
n44
},
lookAt
:
function
(
d
,
c
,
b
){
var
a
=
this
.
_x
,
f
=
this
.
_y
,
e
=
this
.
_z
;
e
.
sub
(
d
,
c
);
e
.
normalize
();
a
.
cross
(
b
,
e
);
a
.
normalize
();
f
.
cross
(
e
,
a
);
f
.
normalize
();
this
.
n11
=
a
.
x
;
this
.
n12
=
a
.
y
;
this
.
n13
=
a
.
z
;
this
.
n14
=-
a
.
dot
(
d
);
this
.
n21
=
f
.
x
;
this
.
n22
=
f
.
y
;
this
.
n23
=
f
.
z
;
this
.
n24
=-
f
.
dot
(
d
);
this
.
n31
=
e
.
x
;
this
.
n32
=
e
.
y
;
this
.
n33
=
e
.
z
;
this
.
n34
=-
e
.
dot
(
d
);
this
.
n41
=
0
;
this
.
n42
=
0
;
this
.
n43
=
0
;
this
.
n44
=
1
},
transform
:
function
(
a
){
var
d
=
a
.
x
,
c
=
a
.
y
,
b
=
a
.
z
,
e
=
a
.
w
?
a
.
w
:
1
;
a
.
x
=
this
.
n11
*
d
+
this
.
n12
*
c
+
this
.
n13
*
b
+
this
.
n14
*
e
;
a
.
y
=
this
.
n21
*
d
+
this
.
n22
*
c
+
this
.
n23
*
b
+
this
.
n24
*
e
;
a
.
z
=
this
.
n31
*
d
+
this
.
n32
*
c
+
this
.
n33
*
b
+
this
.
n34
*
e
;
e
=
this
.
n41
*
d
+
this
.
n42
*
c
+
this
.
n43
*
b
+
this
.
n44
*
e
;
if
(
a
.
w
){
a
.
w
=
e
}
else
{
a
.
x
=
a
.
x
/
e
;
a
.
y
=
a
.
y
/
e
;
a
.
z
=
a
.
z
/
e
}
return
a
},
crossVector
:
function
(
b
){
var
c
=
new
THREE
.
Vector4
();
c
.
x
=
this
.
n11
*
b
.
x
+
this
.
n12
*
b
.
y
+
this
.
n13
*
b
.
z
+
this
.
n14
*
b
.
w
;
c
.
y
=
this
.
n21
*
b
.
x
+
this
.
n22
*
b
.
y
+
this
.
n23
*
b
.
z
+
this
.
n24
*
b
.
w
;
c
.
z
=
this
.
n31
*
b
.
x
+
this
.
n32
*
b
.
y
+
this
.
n33
*
b
.
z
+
this
.
n34
*
b
.
w
;
c
.
w
=
(
b
.
w
)?
this
.
n41
*
b
.
x
+
this
.
n42
*
b
.
y
+
this
.
n43
*
b
.
z
+
this
.
n44
*
b
.
w
:
1
;
return
c
},
multiply
:
function
(
d
,
c
){
this
.
n11
=
d
.
n11
*
c
.
n11
+
d
.
n12
*
c
.
n21
+
d
.
n13
*
c
.
n31
+
d
.
n14
*
c
.
n41
;
this
.
n12
=
d
.
n11
*
c
.
n12
+
d
.
n12
*
c
.
n22
+
d
.
n13
*
c
.
n32
+
d
.
n14
*
c
.
n42
;
this
.
n13
=
d
.
n11
*
c
.
n13
+
d
.
n12
*
c
.
n23
+
d
.
n13
*
c
.
n33
+
d
.
n14
*
c
.
n43
;
this
.
n14
=
d
.
n11
*
c
.
n14
+
d
.
n12
*
c
.
n24
+
d
.
n13
*
c
.
n34
+
d
.
n14
*
c
.
n44
;
this
.
n21
=
d
.
n21
*
c
.
n11
+
d
.
n22
*
c
.
n21
+
d
.
n23
*
c
.
n31
+
d
.
n24
*
c
.
n41
;
this
.
n22
=
d
.
n21
*
c
.
n12
+
d
.
n22
*
c
.
n22
+
d
.
n23
*
c
.
n32
+
d
.
n24
*
c
.
n42
;
this
.
n23
=
d
.
n21
*
c
.
n13
+
d
.
n22
*
c
.
n23
+
d
.
n23
*
c
.
n33
+
d
.
n24
*
c
.
n43
;
this
.
n24
=
d
.
n21
*
c
.
n14
+
d
.
n22
*
c
.
n24
+
d
.
n23
*
c
.
n34
+
d
.
n24
*
c
.
n44
;
this
.
n31
=
d
.
n31
*
c
.
n11
+
d
.
n32
*
c
.
n21
+
d
.
n33
*
c
.
n31
+
d
.
n34
*
c
.
n41
;
this
.
n32
=
d
.
n31
*
c
.
n12
+
d
.
n32
*
c
.
n22
+
d
.
n33
*
c
.
n32
+
d
.
n34
*
c
.
n42
;
this
.
n33
=
d
.
n31
*
c
.
n13
+
d
.
n32
*
c
.
n23
+
d
.
n33
*
c
.
n33
+
d
.
n34
*
c
.
n43
;
this
.
n34
=
d
.
n31
*
c
.
n14
+
d
.
n32
*
c
.
n24
+
d
.
n33
*
c
.
n34
+
d
.
n34
*
c
.
n44
;
this
.
n41
=
d
.
n41
*
c
.
n11
+
d
.
n42
*
c
.
n21
+
d
.
n43
*
c
.
n31
+
d
.
n44
*
c
.
n41
;
this
.
n42
=
d
.
n41
*
c
.
n12
+
d
.
n42
*
c
.
n22
+
d
.
n43
*
c
.
n32
+
d
.
n44
*
c
.
n42
;
this
.
n43
=
d
.
n41
*
c
.
n13
+
d
.
n42
*
c
.
n23
+
d
.
n43
*
c
.
n33
+
d
.
n44
*
c
.
n43
;
this
.
n44
=
d
.
n41
*
c
.
n14
+
d
.
n42
*
c
.
n24
+
d
.
n43
*
c
.
n34
+
d
.
n44
*
c
.
n44
},
multiplySelf
:
function
(
c
){
var
o
=
this
.
n11
,
n
=
this
.
n12
,
k
=
this
.
n13
,
i
=
this
.
n14
,
f
=
this
.
n21
,
e
=
this
.
n22
,
d
=
this
.
n23
,
b
=
this
.
n24
,
a
=
this
.
n31
,
r
=
this
.
n32
,
q
=
this
.
n33
,
p
=
this
.
n34
,
l
=
this
.
n41
,
j
=
this
.
n42
,
h
=
this
.
n43
,
g
=
this
.
n44
;
this
.
n11
=
o
*
c
.
n11
+
n
*
c
.
n21
+
k
*
c
.
n31
+
i
*
c
.
n41
;
this
.
n12
=
o
*
c
.
n12
+
n
*
c
.
n22
+
k
*
c
.
n32
+
i
*
c
.
n42
;
this
.
n13
=
o
*
c
.
n13
+
n
*
c
.
n23
+
k
*
c
.
n33
+
i
*
c
.
n43
;
this
.
n14
=
o
*
c
.
n14
+
n
*
c
.
n24
+
k
*
c
.
n34
+
i
*
c
.
n44
;
this
.
n21
=
f
*
c
.
n11
+
e
*
c
.
n21
+
d
*
c
.
n31
+
b
*
c
.
n41
;
this
.
n22
=
f
*
c
.
n12
+
e
*
c
.
n22
+
d
*
c
.
n32
+
b
*
c
.
n42
;
this
.
n23
=
f
*
c
.
n13
+
e
*
c
.
n23
+
d
*
c
.
n33
+
b
*
c
.
n43
;
this
.
n24
=
f
*
c
.
n14
+
e
*
c
.
n24
+
d
*
c
.
n34
+
b
*
c
.
n44
;
this
.
n31
=
a
*
c
.
n11
+
r
*
c
.
n21
+
q
*
c
.
n31
+
p
*
c
.
n41
;
this
.
n32
=
a
*
c
.
n12
+
r
*
c
.
n22
+
q
*
c
.
n32
+
p
*
c
.
n42
;
this
.
n33
=
a
*
c
.
n13
+
r
*
c
.
n23
+
q
*
c
.
n33
+
p
*
c
.
n43
;
this
.
n34
=
a
*
c
.
n14
+
r
*
c
.
n24
+
q
*
c
.
n34
+
p
*
c
.
n44
;
this
.
n41
=
l
*
c
.
n11
+
j
*
c
.
n21
+
h
*
c
.
n31
+
g
*
c
.
n41
;
this
.
n42
=
l
*
c
.
n12
+
j
*
c
.
n22
+
h
*
c
.
n32
+
g
*
c
.
n42
;
this
.
n43
=
l
*
c
.
n13
+
j
*
c
.
n23
+
h
*
c
.
n33
+
g
*
c
.
n43
;
this
.
n44
=
l
*
c
.
n14
+
j
*
c
.
n24
+
h
*
c
.
n34
+
g
*
c
.
n44
},
multiplyScalar
:
function
(
a
){
this
.
n11
*=
a
;
this
.
n12
*=
a
;
this
.
n13
*=
a
;
this
.
n14
*=
a
;
this
.
n21
*=
a
;
this
.
n22
*=
a
;
this
.
n23
*=
a
;
this
.
n24
*=
a
;
this
.
n31
*=
a
;
this
.
n32
*=
a
;
this
.
n33
*=
a
;
this
.
n34
*=
a
;
this
.
n41
*=
a
;
this
.
n42
*=
a
;
this
.
n43
*=
a
;
this
.
n44
*=
a
},
determinant
:
function
(){
return
(
this
.
n14
*
this
.
n23
*
this
.
n32
*
this
.
n41
-
this
.
n13
*
this
.
n24
*
this
.
n32
*
this
.
n41
-
this
.
n14
*
this
.
n22
*
this
.
n33
*
this
.
n41
+
this
.
n12
*
this
.
n24
*
this
.
n33
*
this
.
n41
+
this
.
n13
*
this
.
n22
*
this
.
n34
*
this
.
n41
-
this
.
n12
*
this
.
n23
*
this
.
n34
*
this
.
n41
-
this
.
n14
*
this
.
n23
*
this
.
n31
*
this
.
n42
+
this
.
n13
*
this
.
n24
*
this
.
n31
*
this
.
n42
+
this
.
n14
*
this
.
n21
*
this
.
n33
*
this
.
n42
-
this
.
n11
*
this
.
n24
*
this
.
n33
*
this
.
n42
-
this
.
n13
*
this
.
n21
*
this
.
n34
*
this
.
n42
+
this
.
n11
*
this
.
n23
*
this
.
n34
*
this
.
n42
+
this
.
n14
*
this
.
n22
*
this
.
n31
*
this
.
n43
-
this
.
n12
*
this
.
n24
*
this
.
n31
*
this
.
n43
-
this
.
n14
*
this
.
n21
*
this
.
n32
*
this
.
n43
+
this
.
n11
*
this
.
n24
*
this
.
n32
*
this
.
n43
+
this
.
n12
*
this
.
n21
*
this
.
n34
*
this
.
n43
-
this
.
n11
*
this
.
n22
*
this
.
n34
*
this
.
n43
-
this
.
n13
*
this
.
n22
*
this
.
n31
*
this
.
n44
+
this
.
n12
*
this
.
n23
*
this
.
n31
*
this
.
n44
+
this
.
n13
*
this
.
n21
*
this
.
n32
*
this
.
n44
-
this
.
n11
*
this
.
n23
*
this
.
n32
*
this
.
n44
-
this
.
n12
*
this
.
n21
*
this
.
n33
*
this
.
n44
+
this
.
n11
*
this
.
n22
*
this
.
n33
*
this
.
n44
)},
transpose
:
function
(){
function
a
(
d
,
e
,
c
){
var
b
=
d
[
e
];
d
[
e
]
=
d
[
c
];
d
[
c
]
=
b
}
a
(
this
,
"
n21
"
,
"
n12
"
);
a
(
this
,
"
n31
"
,
"
n13
"
);
a
(
this
,
"
n32
"
,
"
n23
"
);
a
(
this
,
"
n41
"
,
"
n14
"
);
a
(
this
,
"
n42
"
,
"
n24
"
);
a
(
this
,
"
n43
"
,
"
n34
"
);
return
this
},
clone
:
function
(){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
this
.
n11
;
a
.
n12
=
this
.
n12
;
a
.
n13
=
this
.
n13
;
a
.
n14
=
this
.
n14
;
a
.
n21
=
this
.
n21
;
a
.
n22
=
this
.
n22
;
a
.
n23
=
this
.
n23
;
a
.
n24
=
this
.
n24
;
a
.
n31
=
this
.
n31
;
a
.
n32
=
this
.
n32
;
a
.
n33
=
this
.
n33
;
a
.
n34
=
this
.
n34
;
a
.
n41
=
this
.
n41
;
a
.
n42
=
this
.
n42
;
a
.
n43
=
this
.
n43
;
a
.
n44
=
this
.
n44
;
return
a
},
flatten
:
function
(){
return
[
this
.
n11
,
this
.
n21
,
this
.
n31
,
this
.
n41
,
this
.
n12
,
this
.
n22
,
this
.
n32
,
this
.
n42
,
this
.
n13
,
this
.
n23
,
this
.
n33
,
this
.
n43
,
this
.
n14
,
this
.
n24
,
this
.
n34
,
this
.
n44
]},
toString
:
function
(){
return
"
|
"
+
this
.
n11
+
"
"
+
this
.
n12
+
"
"
+
this
.
n13
+
"
"
+
this
.
n14
+
"
|
\n
|
"
+
this
.
n21
+
"
"
+
this
.
n22
+
"
"
+
this
.
n23
+
"
"
+
this
.
n24
+
"
|
\n
|
"
+
this
.
n31
+
"
"
+
this
.
n32
+
"
"
+
this
.
n33
+
"
"
+
this
.
n34
+
"
|
\n
|
"
+
this
.
n41
+
"
"
+
this
.
n42
+
"
"
+
this
.
n43
+
"
"
+
this
.
n44
+
"
|
"
}};
THREE
.
Matrix4
.
translationMatrix
=
function
(
b
,
d
,
c
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n14
=
b
;
a
.
n24
=
d
;
a
.
n34
=
c
;
return
a
};
THREE
.
Matrix4
.
scaleMatrix
=
function
(
b
,
d
,
c
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
b
;
a
.
n22
=
d
;
a
.
n33
=
c
;
return
a
};
THREE
.
Matrix4
.
rotationXMatrix
=
function
(
b
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n22
=
a
.
n33
=
Math
.
cos
(
b
);
a
.
n32
=
Math
.
sin
(
b
);
a
.
n23
=-
a
.
n32
;
return
a
};
THREE
.
Matrix4
.
rotationYMatrix
=
function
(
b
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
a
.
n33
=
Math
.
cos
(
b
);
a
.
n13
=
Math
.
sin
(
b
);
a
.
n31
=-
a
.
n13
;
return
a
};
THREE
.
Matrix4
.
rotationZMatrix
=
function
(
b
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
a
.
n22
=
Math
.
cos
(
b
);
a
.
n21
=
Math
.
sin
(
b
);
a
.
n12
=-
a
.
n21
;
return
a
};
THREE
.
Matrix4
.
rotationAxisAngleMatrix
=
function
(
b
,
d
){
var
a
=
new
THREE
.
Matrix4
(),
f
=
Math
.
cos
(
d
),
j
=
Math
.
sin
(
d
),
i
=
1
-
f
,
h
=
b
.
x
,
g
=
b
.
y
,
e
=
b
.
z
;
a
.
n11
=
i
*
h
*
h
+
f
;
a
.
n12
=
i
*
h
*
g
-
j
*
e
;
a
.
n13
=
i
*
h
*
e
+
j
*
g
;
a
.
n21
=
i
*
h
*
g
+
j
*
e
;
a
.
n22
=
i
*
g
*
g
+
f
;
a
.
n23
=
i
*
g
*
e
-
j
*
h
;
a
.
n31
=
i
*
h
*
e
-
j
*
g
;
a
.
n32
=
i
*
g
*
e
+
j
*
h
;
a
.
n33
=
i
*
e
*
e
+
f
;
return
a
};
THREE
.
Matrix4
.
makeInvert
=
function
(
b
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
b
.
n23
*
b
.
n34
*
b
.
n42
-
b
.
n24
*
b
.
n33
*
b
.
n42
+
b
.
n24
*
b
.
n32
*
b
.
n43
-
b
.
n22
*
b
.
n34
*
b
.
n43
-
b
.
n23
*
b
.
n32
*
b
.
n44
+
b
.
n22
*
b
.
n33
*
b
.
n44
;
a
.
n12
=
b
.
n14
*
b
.
n33
*
b
.
n42
-
b
.
n13
*
b
.
n34
*
b
.
n42
-
b
.
n14
*
b
.
n32
*
b
.
n43
+
b
.
n12
*
b
.
n34
*
b
.
n43
+
b
.
n13
*
b
.
n32
*
b
.
n44
-
b
.
n12
*
b
.
n33
*
b
.
n44
;
a
.
n13
=
b
.
n13
*
b
.
n24
*
b
.
n42
-
b
.
n14
*
b
.
n23
*
b
.
n42
+
b
.
n14
*
b
.
n22
*
b
.
n43
-
b
.
n12
*
b
.
n24
*
b
.
n43
-
b
.
n13
*
b
.
n22
*
b
.
n44
+
b
.
n12
*
b
.
n23
*
b
.
n44
;
a
.
n14
=
b
.
n14
*
b
.
n23
*
b
.
n32
-
b
.
n13
*
b
.
n24
*
b
.
n32
-
b
.
n14
*
b
.
n22
*
b
.
n33
+
b
.
n12
*
b
.
n24
*
b
.
n33
+
b
.
n13
*
b
.
n22
*
b
.
n34
-
b
.
n12
*
b
.
n23
*
b
.
n34
;
a
.
n21
=
b
.
n24
*
b
.
n33
*
b
.
n41
-
b
.
n23
*
b
.
n34
*
b
.
n41
-
b
.
n24
*
b
.
n31
*
b
.
n43
+
b
.
n21
*
b
.
n34
*
b
.
n43
+
b
.
n23
*
b
.
n31
*
b
.
n44
-
b
.
n21
*
b
.
n33
*
b
.
n44
;
a
.
n22
=
b
.
n13
*
b
.
n34
*
b
.
n41
-
b
.
n14
*
b
.
n33
*
b
.
n41
+
b
.
n14
*
b
.
n31
*
b
.
n43
-
b
.
n11
*
b
.
n34
*
b
.
n43
-
b
.
n13
*
b
.
n31
*
b
.
n44
+
b
.
n11
*
b
.
n33
*
b
.
n44
;
a
.
n23
=
b
.
n14
*
b
.
n23
*
b
.
n41
-
b
.
n13
*
b
.
n24
*
b
.
n41
-
b
.
n14
*
b
.
n21
*
b
.
n43
+
b
.
n11
*
b
.
n24
*
b
.
n43
+
b
.
n13
*
b
.
n21
*
b
.
n44
-
b
.
n11
*
b
.
n23
*
b
.
n44
;
a
.
n24
=
b
.
n13
*
b
.
n24
*
b
.
n31
-
b
.
n14
*
b
.
n23
*
b
.
n31
+
b
.
n14
*
b
.
n21
*
b
.
n33
-
b
.
n11
*
b
.
n24
*
b
.
n33
-
b
.
n13
*
b
.
n21
*
b
.
n34
+
b
.
n11
*
b
.
n23
*
b
.
n34
;
a
.
n31
=
b
.
n22
*
b
.
n34
*
b
.
n41
-
b
.
n24
*
b
.
n32
*
b
.
n41
+
b
.
n24
*
b
.
n31
*
b
.
n42
-
b
.
n21
*
b
.
n34
*
b
.
n42
-
b
.
n22
*
b
.
n31
*
b
.
n44
+
b
.
n21
*
b
.
n32
*
b
.
n44
;
a
.
n32
=
b
.
n14
*
b
.
n32
*
b
.
n41
-
b
.
n12
*
b
.
n34
*
b
.
n41
-
b
.
n14
*
b
.
n31
*
b
.
n42
+
b
.
n11
*
b
.
n34
*
b
.
n42
+
b
.
n12
*
b
.
n31
*
b
.
n44
-
b
.
n11
*
b
.
n32
*
b
.
n44
;
a
.
n33
=
b
.
n13
*
b
.
n24
*
b
.
n41
-
b
.
n14
*
b
.
n22
*
b
.
n41
+
b
.
n14
*
b
.
n21
*
b
.
n42
-
b
.
n11
*
b
.
n24
*
b
.
n42
-
b
.
n12
*
b
.
n21
*
b
.
n44
+
b
.
n11
*
b
.
n22
*
b
.
n44
;
a
.
n34
=
b
.
n14
*
b
.
n22
*
b
.
n31
-
b
.
n12
*
b
.
n24
*
b
.
n31
-
b
.
n14
*
b
.
n21
*
b
.
n32
+
b
.
n11
*
b
.
n24
*
b
.
n32
+
b
.
n12
*
b
.
n21
*
b
.
n34
-
b
.
n11
*
b
.
n22
*
b
.
n34
;
a
.
n41
=
b
.
n23
*
b
.
n32
*
b
.
n41
-
b
.
n22
*
b
.
n33
*
b
.
n41
-
b
.
n23
*
b
.
n31
*
b
.
n42
+
b
.
n21
*
b
.
n33
*
b
.
n42
+
b
.
n22
*
b
.
n31
*
b
.
n43
-
b
.
n21
*
b
.
n32
*
b
.
n43
;
a
.
n42
=
b
.
n12
*
b
.
n33
*
b
.
n41
-
b
.
n13
*
b
.
n32
*
b
.
n41
+
b
.
n13
*
b
.
n31
*
b
.
n42
-
b
.
n11
*
b
.
n33
*
b
.
n42
-
b
.
n12
*
b
.
n31
*
b
.
n43
+
b
.
n11
*
b
.
n32
*
b
.
n43
;
a
.
n43
=
b
.
n13
*
b
.
n22
*
b
.
n41
-
b
.
n12
*
b
.
n23
*
b
.
n41
-
b
.
n13
*
b
.
n21
*
b
.
n42
+
b
.
n11
*
b
.
n23
*
b
.
n42
+
b
.
n12
*
b
.
n21
*
b
.
n43
-
b
.
n11
*
b
.
n22
*
b
.
n43
;
a
.
n44
=
b
.
n12
*
b
.
n23
*
b
.
n31
-
b
.
n13
*
b
.
n22
*
b
.
n31
+
b
.
n13
*
b
.
n21
*
b
.
n32
-
b
.
n11
*
b
.
n23
*
b
.
n32
-
b
.
n12
*
b
.
n21
*
b
.
n33
+
b
.
n11
*
b
.
n22
*
b
.
n33
;
a
.
multiplyScalar
(
1
/
b
.
determinant
());
return
a
};
THREE
.
Matrix4
.
makeInvert3x3
=
function
(
o
){
var
e
=
o
.
flatten
(),
l
=
new
THREE
.
Matrix3
(),
n
=
e
[
10
]
*
e
[
5
]
-
e
[
6
]
*
e
[
9
],
i
=-
e
[
10
]
*
e
[
1
]
+
e
[
2
]
*
e
[
9
],
d
=
e
[
6
]
*
e
[
1
]
-
e
[
2
]
*
e
[
5
],
k
=-
e
[
10
]
*
e
[
4
]
+
e
[
6
]
*
e
[
8
],
g
=
e
[
10
]
*
e
[
0
]
-
e
[
2
]
*
e
[
8
],
c
=-
e
[
6
]
*
e
[
0
]
+
e
[
2
]
*
e
[
4
],
j
=
e
[
9
]
*
e
[
4
]
-
e
[
5
]
*
e
[
8
],
f
=-
e
[
9
]
*
e
[
0
]
+
e
[
1
]
*
e
[
8
],
a
=
e
[
5
]
*
e
[
0
]
-
e
[
1
]
*
e
[
4
],
h
=
e
[
0
]
*
(
n
)
+
e
[
1
]
*
(
k
)
+
e
[
2
]
*
(
j
),
b
;
if
(
h
==
0
){
throw
"
matrix not invertible
"
}
b
=
1
/
h
;
l
.
m
[
0
]
=
b
*
n
;
l
.
m
[
1
]
=
b
*
i
;
l
.
m
[
2
]
=
b
*
d
;
l
.
m
[
3
]
=
b
*
k
;
l
.
m
[
4
]
=
b
*
g
;
l
.
m
[
5
]
=
b
*
c
;
l
.
m
[
6
]
=
b
*
j
;
l
.
m
[
7
]
=
b
*
f
;
l
.
m
[
8
]
=
b
*
a
;
return
l
};
THREE
.
Matrix4
.
makeFrustum
=
function
(
f
,
r
,
e
,
o
,
i
,
h
){
var
g
,
q
,
n
,
p
,
l
,
k
,
j
;
g
=
new
THREE
.
Matrix4
();
q
=
2
*
i
/
(
r
-
f
);
n
=
2
*
i
/
(
o
-
e
);
p
=
(
r
+
f
)
/
(
r
-
f
);
l
=
(
o
+
e
)
/
(
o
-
e
);
k
=-
(
h
+
i
)
/
(
h
-
i
);
j
=-
2
*
h
*
i
/
(
h
-
i
);
g
.
n11
=
q
;
g
.
n12
=
0
;
g
.
n13
=
p
;
g
.
n14
=
0
;
g
.
n21
=
0
;
g
.
n22
=
n
;
g
.
n23
=
l
;
g
.
n24
=
0
;
g
.
n31
=
0
;
g
.
n32
=
0
;
g
.
n33
=
k
;
g
.
n34
=
j
;
g
.
n41
=
0
;
g
.
n42
=
0
;
g
.
n43
=-
1
;
g
.
n44
=
0
;
return
g
};
THREE
.
Matrix4
.
makePerspective
=
function
(
e
,
c
,
g
,
b
){
var
a
,
f
,
h
,
d
;
a
=
g
*
Math
.
tan
(
e
*
Math
.
PI
/
360
);
f
=-
a
;
h
=
f
*
c
;
d
=
a
*
c
;
return
THREE
.
Matrix4
.
makeFrustum
(
h
,
d
,
f
,
a
,
g
,
b
)};
THREE
.
Matrix4
.
makeOrtho
=
function
(
c
,
o
,
k
,
a
,
g
,
f
){
var
d
,
l
,
j
,
i
,
n
,
e
,
b
;
d
=
new
THREE
.
Matrix4
();
n
=
o
-
c
;
e
=
k
-
a
;
b
=
f
-
g
;
l
=
(
o
+
c
)
/
n
;
j
=
(
k
+
a
)
/
e
;
i
=
(
f
+
g
)
/
b
;
d
.
n11
=
2
/
n
;
d
.
n12
=
0
;
d
.
n13
=
0
;
d
.
n14
=-
l
;
d
.
n21
=
0
;
d
.
n22
=
2
/
e
;
d
.
n23
=
0
;
d
.
n24
=-
j
;
d
.
n31
=
0
;
d
.
n32
=
0
;
d
.
n33
=-
2
/
b
;
d
.
n34
=-
i
;
d
.
n41
=
0
;
d
.
n42
=
0
;
d
.
n43
=
0
;
d
.
n44
=
1
;
return
d
};
THREE
.
Vertex
=
function
(
a
,
b
){
this
.
position
=
a
||
new
THREE
.
Vector3
();
this
.
positionWorld
=
new
THREE
.
Vector3
();
this
.
positionScreen
=
new
THREE
.
Vector3
();
this
.
normal
=
b
||
new
THREE
.
Vector3
();
this
.
normalWorld
=
new
THREE
.
Vector3
();
this
.
normalScreen
=
new
THREE
.
Vector3
();
this
.
__visible
=
true
};
THREE
.
Vertex
.
prototype
=
{
toString
:
function
(){
return
"
THREE.Vertex ( position:
"
+
this
.
position
+
"
, normal:
"
+
this
.
normal
+
"
)
"
}};
THREE
.
Face3
=
function
(
e
,
d
,
h
,
g
,
f
){
this
.
a
=
e
;
this
.
b
=
d
;
this
.
c
=
h
;
this
.
centroid
=
new
THREE
.
Vector3
();
this
.
normal
=
g
instanceof
THREE
.
Vector3
?
g
:
new
THREE
.
Vector3
();
this
.
vertexNormals
=
g
instanceof
Array
?
g
:[];
this
.
material
=
f
instanceof
Array
?
f
:[
f
]};
THREE
.
Face3
.
prototype
=
{
toString
:
function
(){
return
"
THREE.Face3 (
"
+
this
.
a
+
"
,
"
+
this
.
b
+
"
,
"
+
this
.
c
+
"
)
"
}};
THREE
.
Face4
=
function
(
f
,
e
,
j
,
i
,
h
,
g
){
this
.
a
=
f
;
this
.
b
=
e
;
this
.
c
=
j
;
this
.
d
=
i
;
this
.
centroid
=
new
THREE
.
Vector3
();
this
.
normal
=
h
instanceof
THREE
.
Vector3
?
h
:
new
THREE
.
Vector3
();
this
.
vertexNormals
=
h
instanceof
Array
?
h
:[];
this
.
material
=
g
instanceof
Array
?
g
:[
g
]};
THREE
.
Face4
.
prototype
=
{
toString
:
function
(){
return
"
THREE.Face4 (
"
+
this
.
a
+
"
,
"
+
this
.
b
+
"
,
"
+
this
.
c
+
"
"
+
this
.
d
+
"
)
"
}};
THREE
.
UV
=
function
(
b
,
a
){
this
.
u
=
b
||
0
;
this
.
v
=
a
||
0
};
THREE
.
UV
.
prototype
=
{
copy
:
function
(
a
){
this
.
u
=
a
.
u
;
this
.
v
=
a
.
v
},
toString
:
function
(){
return
"
THREE.UV (
"
+
this
.
u
+
"
,
"
+
this
.
v
+
"
)
"
}};
THREE
.
Geometry
=
function
(){
this
.
vertices
=
[];
this
.
faces
=
[];
this
.
uvs
=
[]};
THREE
.
Geometry
.
prototype
=
{
computeCentroids
:
function
(){
var
c
,
b
,
a
;
for
(
c
=
0
,
b
=
this
.
faces
.
length
;
c
<
b
;
c
++
){
a
=
this
.
faces
[
c
];
a
.
centroid
.
set
(
0
,
0
,
0
);
if
(
a
instanceof
THREE
.
Face3
){
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
a
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
b
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
c
].
position
);
a
.
centroid
.
divideScalar
(
3
)}
else
{
if
(
a
instanceof
THREE
.
Face4
){
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
a
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
b
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
c
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
d
].
position
);
a
.
centroid
.
divideScalar
(
4
)}}}},
computeNormals
:
function
(
m
){
var
e
,
b
,
o
,
g
,
i
,
j
,
l
,
k
,
d
,
c
,
a
,
h
=
new
THREE
.
Vector3
(),
p
=
new
THREE
.
Vector3
();
for
(
o
=
0
,
g
=
this
.
vertices
.
length
;
o
<
g
;
o
++
){
i
=
this
.
vertices
[
o
];
i
.
normal
.
set
(
0
,
0
,
0
)}
for
(
j
=
0
,
l
=
this
.
faces
.
length
;
j
<
l
;
j
++
){
k
=
this
.
faces
[
j
];
if
(
m
&&
k
.
vertexNormals
.
length
){
h
.
set
(
0
,
0
,
0
);
for
(
e
=
0
,
b
=
k
.
normal
.
length
;
e
<
b
;
e
++
){
h
.
addSelf
(
k
.
vertexNormals
[
e
])}
h
.
divideScalar
(
3
);
if
(
!
h
.
isZero
()){
h
.
normalize
()}
k
.
normal
.
copy
(
h
)}
else
{
d
=
this
.
vertices
[
k
.
a
];
c
=
this
.
vertices
[
k
.
b
];
a
=
this
.
vertices
[
k
.
c
];
h
.
sub
(
a
.
position
,
c
.
position
);
p
.
sub
(
d
.
position
,
c
.
position
);
h
.
crossSelf
(
p
);
if
(
!
h
.
isZero
()){
h
.
normalize
()}
k
.
normal
.
copy
(
h
)}}},
computeBoundingBox
:
function
(){
if
(
this
.
vertices
.
length
>
0
){
this
.
bbox
=
{
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
a
=
1
,
b
=
this
.
vertices
.
length
;
a
<
b
;
a
++
){
vertex
=
this
.
vertices
[
a
];
if
(
vertex
.
position
.
x
<
this
.
bbox
.
x
[
0
]){
this
.
bbox
.
x
[
0
]
=
vertex
.
position
.
x
}
else
{
if
(
vertex
.
position
.
x
>
this
.
bbox
.
x
[
1
]){
this
.
bbox
.
x
[
1
]
=
vertex
.
position
.
x
}}
if
(
vertex
.
position
.
y
<
this
.
bbox
.
y
[
0
]){
this
.
bbox
.
y
[
0
]
=
vertex
.
position
.
y
}
else
{
if
(
vertex
.
position
.
y
>
this
.
bbox
.
y
[
1
]){
this
.
bbox
.
y
[
1
]
=
vertex
.
position
.
y
}}
if
(
vertex
.
position
.
z
<
this
.
bbox
.
z
[
0
]){
this
.
bbox
.
z
[
0
]
=
vertex
.
position
.
z
}
else
{
if
(
vertex
.
position
.
z
>
this
.
bbox
.
z
[
1
]){
this
.
bbox
.
z
[
1
]
=
vertex
.
position
.
z
}}}}},
toString
:
function
(){
return
"
THREE.Geometry ( vertices:
"
+
this
.
vertices
+
"
, faces:
"
+
this
.
faces
+
"
)
"
}};
THREE
.
Camera
=
function
(
c
,
b
,
d
,
a
){
this
.
position
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
this
.
target
=
{
position
:
new
THREE
.
Vector3
(
0
,
0
,
0
)};
this
.
up
=
new
THREE
.
Vector3
(
0
,
1
,
0
);
this
.
matrix
=
new
THREE
.
Matrix4
();
this
.
projectionMatrix
=
THREE
.
Matrix4
.
makePerspective
(
c
,
b
,
d
,
a
);
this
.
autoUpdateMatrix
=
true
;
this
.
updateMatrix
=
function
(){
this
.
matrix
.
lookAt
(
this
.
position
,
this
.
target
.
position
,
this
.
up
)};
this
.
toString
=
function
(){
return
"
THREE.Camera (
"
+
this
.
position
+
"
,
"
+
this
.
target
.
position
+
"
)
"
}};
THREE
.
Loader
=
function
(){};
THREE
.
Loader
.
prototype
=
{
loadAsciiOld
:
function
(
a
,
c
){
var
b
=
document
.
createElement
(
"
script
"
);
b
.
type
=
"
text/javascript
"
;
b
.
onload
=
c
;
b
.
src
=
a
;
document
.
getElementsByTagName
(
"
head
"
)[
0
].
appendChild
(
b
)},
loadAscii
:
function
(
a
,
e
,
b
){
var
c
=
(
new
Date
).
getTime
(),
d
=
new
Worker
(
a
);
d
.
onmessage
=
function
(
f
){
THREE
.
Loader
.
prototype
.
createModel
(
f
.
data
,
e
,
b
)};
d
.
postMessage
(
c
)},
loadBinary
:
function
(
a
,
e
,
b
){
var
c
=
(
new
Date
).
getTime
(),
d
=
new
Worker
(
a
);
d
.
onmessage
=
function
(
h
){
var
g
=
h
.
data
.
materials
,
f
=
h
.
data
.
buffers
;
THREE
.
Loader
.
prototype
.
loadAjaxBuffers
(
f
,
g
,
e
,
b
)};
d
.
onerror
=
function
(
f
){
alert
(
"
worker.onerror:
"
+
f
.
message
+
"
\n
"
+
f
.
data
);
f
.
preventDefault
()};
d
.
postMessage
(
c
)},
loadAjaxBuffers
:
function
(
b
,
a
,
f
,
d
){
var
e
=
new
XMLHttpRequest
(),
c
=
d
+
"
/
"
+
b
;
e
.
onreadystatechange
=
function
(){
if
(
e
.
readyState
==
4
){
if
(
e
.
status
==
200
||
e
.
status
==
0
){
THREE
.
Loader
.
prototype
.
createBinModel
(
e
.
responseText
,
f
,
d
,
a
)}
else
{
alert
(
"
Couldn't load [
"
+
c
+
"
] [
"
+
e
.
status
+
"
]
"
)}}};
e
.
open
(
"
GET
"
,
c
,
true
);
e
.
overrideMimeType
(
"
text/plain; charset=x-user-defined
"
);
e
.
setRequestHeader
(
"
Content-Type
"
,
"
text/plain
"
);
e
.
send
(
null
)},
createBinModel
:
function
(
c
,
e
,
b
,
a
){
var
d
=
function
(
aa
){
var
I
=
this
,
h
=
0
,
x
,
A
=
[],
L
=
[],
V
,
T
,
O
,
U
,
R
,
P
,
D
,
C
,
B
,
y
,
r
,
q
,
p
,
o
,
u
,
t
,
N
,
K
,
J
;
THREE
.
Geometry
.
call
(
this
);
THREE
.
Loader
.
prototype
.
init_materials
(
I
,
a
,
aa
);
x
=
W
(
c
,
h
);
h
+=
x
.
header_bytes
;
V
=
x
.
vertex_index_bytes
,
T
=
x
.
vertex_index_bytes
*
2
,
O
=
x
.
vertex_index_bytes
*
3
,
U
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
,
R
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
,
P
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
2
,
D
=
x
.
vertex_index_bytes
,
C
=
x
.
vertex_index_bytes
*
2
,
B
=
x
.
vertex_index_bytes
*
3
,
y
=
x
.
vertex_index_bytes
*
4
,
r
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
,
q
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
,
p
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
2
,
o
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
3
,
u
=
x
.
uv_index_bytes
,
t
=
x
.
uv_index_bytes
*
2
,
N
=
x
.
uv_index_bytes
,
K
=
x
.
uv_index_bytes
*
2
,
J
=
x
.
uv_index_bytes
*
3
;
h
+=
w
(
h
);
h
+=
H
(
h
);
h
+=
G
(
h
);
h
+=
Q
(
h
);
h
+=
S
(
h
);
h
+=
ab
(
h
);
h
+=
n
(
h
);
h
+=
g
(
h
);
h
+=
k
(
h
);
h
+=
s
(
h
);
h
+=
z
(
h
);
this
.
computeCentroids
();
this
.
computeNormals
();
function
W
(
ad
,
ae
){
var
ac
=
{
signature
:
F
(
ad
,
ae
,
8
),
header_bytes
:
j
(
ad
,
ae
+
8
),
vertex_coordinate_bytes
:
j
(
ad
,
ae
+
9
),
normal_coordinate_bytes
:
j
(
ad
,
ae
+
10
),
uv_coordinate_bytes
:
j
(
ad
,
ae
+
11
),
vertex_index_bytes
:
j
(
ad
,
ae
+
12
),
normal_index_bytes
:
j
(
ad
,
ae
+
13
),
uv_index_bytes
:
j
(
ad
,
ae
+
14
),
material_index_bytes
:
j
(
ad
,
ae
+
15
),
nvertices
:
v
(
ad
,
ae
+
16
),
nnormals
:
v
(
ad
,
ae
+
16
+
4
*
1
),
nuvs
:
v
(
ad
,
ae
+
16
+
4
*
2
),
ntri_flat
:
v
(
ad
,
ae
+
16
+
4
*
3
),
ntri_smooth
:
v
(
ad
,
ae
+
16
+
4
*
4
),
ntri_flat_uv
:
v
(
ad
,
ae
+
16
+
4
*
5
),
ntri_smooth_uv
:
v
(
ad
,
ae
+
16
+
4
*
6
),
nquad_flat
:
v
(
ad
,
ae
+
16
+
4
*
7
),
nquad_smooth
:
v
(
ad
,
ae
+
16
+
4
*
8
),
nquad_flat_uv
:
v
(
ad
,
ae
+
16
+
4
*
9
),
nquad_smooth_uv
:
v
(
ad
,
ae
+
16
+
4
*
10
)};
return
ac
}
function
F
(
ad
,
ae
,
ac
){
return
ad
.
substr
(
ae
,
ac
)}
function
f
(
af
,
ae
){
var
ag
=
j
(
af
,
ae
),
ai
=
j
(
af
,
ae
+
1
),
aj
=
j
(
af
,
ae
+
2
),
ak
=
j
(
af
,
ae
+
3
),
ad
=
1
-
(
2
*
(
ak
>>
7
)),
ah
=
(((
ak
<<
1
)
&
255
)
|
(
aj
>>
7
))
-
127
,
ac
=
((
aj
&
127
)
<<
16
)
|
(
ai
<<
8
)
|
ag
;
if
(
ac
==
0
&&
ah
==-
127
){
return
0
}
return
ad
*
(
1
+
ac
*
Math
.
pow
(
2
,
-
23
))
*
Math
.
pow
(
2
,
ah
)}
function
v
(
ag
,
ah
){
var
af
=
j
(
ag
,
ah
),
ae
=
j
(
ag
,
ah
+
1
),
ad
=
j
(
ag
,
ah
+
2
),
ac
=
j
(
ag
,
ah
+
3
);
return
(
ac
<<
24
)
+
(
ad
<<
16
)
+
(
ae
<<
8
)
+
af
}
function
Z
(
ae
,
af
){
var
ad
=
j
(
ae
,
af
),
ac
=
j
(
ae
,
af
+
1
);
return
(
ac
<<
8
)
+
ad
}
function
i
(
ad
,
ae
){
var
ac
=
j
(
ad
,
ae
);
return
ac
>
127
?
ac
-
256
:
ac
}
function
j
(
ac
,
ad
){
return
ac
.
charCodeAt
(
ad
)
&
255
}
function
w
(
ai
){
var
ae
,
ac
,
ah
,
ag
,
af
=
x
.
vertex_coordinate_bytes
*
3
,
ad
=
ai
+
x
.
nvertices
*
af
;
for
(
ae
=
ai
;
ae
<
ad
;
ae
+=
af
){
ac
=
f
(
c
,
ae
);
ah
=
f
(
c
,
ae
+
x
.
vertex_coordinate_bytes
);
ag
=
f
(
c
,
ae
+
x
.
vertex_coordinate_bytes
*
2
);
THREE
.
Loader
.
prototype
.
v
(
I
,
ac
,
ah
,
ag
)}
return
x
.
nvertices
*
af
}
function
H
(
ai
){
var
ae
,
ac
,
ah
,
ag
,
af
=
x
.
normal_coordinate_bytes
*
3
,
ad
=
ai
+
x
.
nnormals
*
af
;
for
(
ae
=
ai
;
ae
<
ad
;
ae
+=
af
){
ac
=
i
(
c
,
ae
);
ah
=
i
(
c
,
ae
+
x
.
normal_coordinate_bytes
);
ag
=
i
(
c
,
ae
+
x
.
normal_coordinate_bytes
*
2
);
A
.
push
(
ac
/
127
,
ah
/
127
,
ag
/
127
)}
return
x
.
nnormals
*
af
}
function
G
(
ah
){
var
af
,
ae
,
ad
,
ag
=
x
.
uv_coordinate_bytes
*
2
,
ac
=
ah
+
x
.
nuvs
*
ag
;
for
(
af
=
ah
;
af
<
ac
;
af
+=
ag
){
ae
=
f
(
c
,
af
);
ad
=
f
(
c
,
af
+
x
.
uv_coordinate_bytes
);
L
.
push
(
ae
,
ad
)}
return
x
.
nuvs
*
ag
}
function
M
(
af
){
var
ae
,
ad
,
ag
,
ac
;
ae
=
v
(
c
,
af
);
ad
=
v
(
c
,
af
+
V
);
ag
=
v
(
c
,
af
+
T
);
ac
=
Z
(
c
,
af
+
O
);
THREE
.
Loader
.
prototype
.
f3
(
I
,
ae
,
ad
,
ag
,
ac
)}
function
m
(
ah
){
var
ag
,
ae
,
aj
,
ad
,
af
,
ac
,
ai
;
ag
=
v
(
c
,
ah
);
ae
=
v
(
c
,
ah
+
V
);
aj
=
v
(
c
,
ah
+
T
);
ad
=
Z
(
c
,
ah
+
O
);
af
=
v
(
c
,
ah
+
U
);
ac
=
v
(
c
,
ah
+
R
);
ai
=
v
(
c
,
ah
+
P
);
THREE
.
Loader
.
prototype
.
f3n
(
I
,
A
,
ag
,
ae
,
aj
,
ad
,
af
,
ac
,
ai
)}
function
E
(
af
){
var
ae
,
ad
,
ah
,
ag
,
ac
;
ae
=
v
(
c
,
af
);
ad
=
v
(
c
,
af
+
D
);
ah
=
v
(
c
,
af
+
C
);
ag
=
v
(
c
,
af
+
B
);
ac
=
Z
(
c
,
af
+
y
);
THREE
.
Loader
.
prototype
.
f4
(
I
,
ae
,
ad
,
ah
,
ag
,
ac
)}
function
l
(
af
){
var
al
,
ak
,
aj
,
ai
,
ac
,
ah
,
ag
,
ae
,
ad
;
al
=
v
(
c
,
af
);
ak
=
v
(
c
,
af
+
D
);
aj
=
v
(
c
,
af
+
C
);
ai
=
v
(
c
,
af
+
B
);
ac
=
Z
(
c
,
af
+
y
);
ah
=
v
(
c
,
af
+
r
);
ag
=
v
(
c
,
af
+
q
);
ae
=
v
(
c
,
af
+
p
);
ad
=
v
(
c
,
af
+
o
);
THREE
.
Loader
.
prototype
.
f4n
(
I
,
A
,
al
,
ak
,
aj
,
ai
,
ac
,
ah
,
ag
,
ae
,
ad
)}
function
Y
(
ai
){
var
ah
,
ae
,
ac
,
ag
,
af
,
ad
,
al
,
ak
,
aj
;
ah
=
v
(
c
,
ai
);
ae
=
v
(
c
,
ai
+
u
);
ac
=
v
(
c
,
ai
+
t
);
ag
=
L
[
ah
*
2
];
al
=
L
[
ah
*
2
+
1
];
af
=
L
[
ae
*
2
];
ak
=
L
[
ae
*
2
+
1
];
ad
=
L
[
ac
*
2
];
aj
=
L
[
ac
*
2
+
1
];
THREE
.
Loader
.
prototype
.
uv
(
I
,
ag
,
al
,
af
,
ak
,
ad
,
aj
)}
function
X
(
ak
){
var
aj
,
ag
,
ae
,
ad
,
ai
,
ah
,
af
,
ac
,
ao
,
an
,
am
,
al
;
aj
=
v
(
c
,
ak
);
ag
=
v
(
c
,
ak
+
N
);
ae
=
v
(
c
,
ak
+
K
);
ad
=
v
(
c
,
ak
+
J
);
ai
=
L
[
aj
*
2
];
ao
=
L
[
aj
*
2
+
1
];
ah
=
L
[
ag
*
2
];
an
=
L
[
ag
*
2
+
1
];
af
=
L
[
ae
*
2
];
am
=
L
[
ae
*
2
+
1
];
ac
=
L
[
ad
*
2
];
al
=
L
[
ad
*
2
+
1
];
THREE
.
Loader
.
prototype
.
uv
(
I
,
ai
,
ao
,
ah
,
an
,
af
,
am
,
ac
,
al
)}
function
Q
(
af
){
var
ad
,
ae
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
,
ac
=
af
+
x
.
ntri_flat
*
ae
;
for
(
ad
=
af
;
ad
<
ac
;
ad
+=
ae
){
M
(
ad
)}
return
ac
-
af
}
function
ab
(
ag
){
var
ad
,
af
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
,
ae
=
af
+
x
.
uv_index_bytes
*
3
,
ac
=
ag
+
x
.
ntri_flat_uv
*
ae
;
for
(
ad
=
ag
;
ad
<
ac
;
ad
+=
ae
){
M
(
ad
);
Y
(
ad
+
af
)}
return
ac
-
ag
}
function
S
(
af
){
var
ad
,
ae
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
3
,
ac
=
af
+
x
.
ntri_smooth
*
ae
;
for
(
ad
=
af
;
ad
<
ac
;
ad
+=
ae
){
m
(
ad
)}
return
ac
-
af
}
function
n
(
ag
){
var
ad
,
af
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
3
,
ae
=
af
+
x
.
uv_index_bytes
*
3
,
ac
=
ag
+
x
.
ntri_smooth_uv
*
ae
;
for
(
ad
=
ag
;
ad
<
ac
;
ad
+=
ae
){
m
(
ad
);
Y
(
ad
+
af
)}
return
ac
-
ag
}
function
g
(
af
){
var
ad
,
ae
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
,
ac
=
af
+
x
.
nquad_flat
*
ae
;
for
(
ad
=
af
;
ad
<
ac
;
ad
+=
ae
){
E
(
ad
)}
return
ac
-
af
}
function
s
(
ag
){
var
ad
,
af
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
,
ae
=
af
+
x
.
uv_index_bytes
*
4
,
ac
=
ag
+
x
.
nquad_flat_uv
*
ae
;
for
(
ad
=
ag
;
ad
<
ac
;
ad
+=
ae
){
E
(
ad
);
X
(
ad
+
af
)}
return
ac
-
ag
}
function
k
(
af
){
var
ad
,
ae
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
4
,
ac
=
af
+
x
.
nquad_smooth
*
ae
;
for
(
ad
=
af
;
ad
<
ac
;
ad
+=
ae
){
l
(
ad
)}
return
ac
-
af
}
function
z
(
ag
){
var
ad
,
af
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
4
,
ae
=
af
+
x
.
uv_index_bytes
*
4
,
ac
=
ag
+
x
.
nquad_smooth_uv
*
ae
;
for
(
ad
=
ag
;
ad
<
ac
;
ad
+=
ae
){
l
(
ad
);
X
(
ad
+
af
)}
return
ac
-
ag
}};
d
.
prototype
=
new
THREE
.
Geometry
();
d
.
prototype
.
constructor
=
d
;
e
(
new
d
(
b
))},
createModel
:
function
(
b
,
d
,
a
){
var
c
=
function
(
f
){
var
g
=
this
;
THREE
.
Geometry
.
call
(
this
);
THREE
.
Loader
.
prototype
.
init_materials
(
g
,
b
.
materials
,
f
);
e
();
h
();
this
.
computeCentroids
();
this
.
computeNormals
();
function
e
(){
var
m
,
k
,
j
,
o
,
n
;
for
(
m
=
0
,
k
=
b
.
vertices
.
length
;
m
<
k
;
m
+=
3
){
j
=
b
.
vertices
[
m
];
o
=
b
.
vertices
[
m
+
1
];
n
=
b
.
vertices
[
m
+
2
];
THREE
.
Loader
.
prototype
.
v
(
g
,
j
,
o
,
n
)}}
function
h
(){
function
p
(
v
,
u
){
var
t
,
s
,
w
,
l
;
t
=
v
[
u
];
s
=
v
[
u
+
1
];
w
=
v
[
u
+
2
];
l
=
v
[
u
+
3
];
THREE
.
Loader
.
prototype
.
f3
(
g
,
t
,
s
,
w
,
l
)}
function
k
(
l
,
u
){
var
z
,
y
,
x
,
s
,
w
,
v
,
t
;
z
=
l
[
u
];
y
=
l
[
u
+
1
];
x
=
l
[
u
+
2
];
s
=
l
[
u
+
3
];
w
=
l
[
u
+
4
];
v
=
l
[
u
+
5
];
t
=
l
[
u
+
6
];
THREE
.
Loader
.
prototype
.
f3n
(
g
,
b
.
normals
,
z
,
y
,
x
,
s
,
w
,
v
,
t
)}
function
o
(
w
,
u
){
var
t
,
s
,
x
,
v
,
l
;
t
=
w
[
u
];
s
=
w
[
u
+
1
];
x
=
w
[
u
+
2
];
v
=
w
[
u
+
3
];
l
=
w
[
u
+
4
];
THREE
.
Loader
.
prototype
.
f4
(
g
,
t
,
s
,
x
,
v
,
l
)}
function
j
(
l
,
v
){
var
B
,
A
,
z
,
y
,
s
,
x
,
w
,
u
,
t
;
B
=
l
[
v
];
A
=
l
[
v
+
1
];
z
=
l
[
v
+
2
];
y
=
l
[
v
+
3
];
s
=
l
[
v
+
4
];
x
=
l
[
v
+
5
];
w
=
l
[
v
+
6
];
u
=
l
[
v
+
7
];
t
=
l
[
v
+
8
];
THREE
.
Loader
.
prototype
.
f4n
(
g
,
b
.
normals
,
B
,
A
,
z
,
y
,
s
,
x
,
w
,
u
,
t
)}
function
r
(
l
,
y
){
var
x
,
u
,
s
,
w
,
v
,
t
,
B
,
A
,
z
;
x
=
l
[
y
];
u
=
l
[
y
+
1
];
s
=
l
[
y
+
2
];
w
=
b
.
uvs
[
x
*
2
];
B
=
b
.
uvs
[
x
*
2
+
1
];
v
=
b
.
uvs
[
u
*
2
];
A
=
b
.
uvs
[
u
*
2
+
1
];
t
=
b
.
uvs
[
s
*
2
];
z
=
b
.
uvs
[
s
*
2
+
1
];
THREE
.
Loader
.
prototype
.
uv
(
g
,
w
,
B
,
v
,
A
,
t
,
z
)}
function
q
(
s
,
A
){
var
z
,
w
,
v
,
t
,
y
,
x
,
u
,
l
,
E
,
D
,
C
,
B
;
z
=
s
[
A
];
w
=
s
[
A
+
1
];
v
=
s
[
A
+
2
];
t
=
s
[
A
+
3
];
y
=
b
.
uvs
[
z
*
2
];
E
=
b
.
uvs
[
z
*
2
+
1
];
x
=
b
.
uvs
[
w
*
2
];
D
=
b
.
uvs
[
w
*
2
+
1
];
u
=
b
.
uvs
[
v
*
2
];
C
=
b
.
uvs
[
v
*
2
+
1
];
l
=
b
.
uvs
[
t
*
2
];
B
=
b
.
uvs
[
t
*
2
+
1
];
THREE
.
Loader
.
prototype
.
uv
(
g
,
y
,
E
,
x
,
D
,
u
,
C
,
l
,
B
)}
var
n
,
m
;
for
(
n
=
0
,
m
=
b
.
triangles
.
length
;
n
<
m
;
n
+=
4
){
p
(
b
.
triangles
,
n
)}
for
(
n
=
0
,
m
=
b
.
triangles_uv
.
length
;
n
<
m
;
n
+=
7
){
p
(
b
.
triangles_uv
,
n
);
r
(
b
.
triangles_uv
,
n
+
4
)}
for
(
n
=
0
,
m
=
b
.
triangles_n
.
length
;
n
<
m
;
n
+=
7
){
k
(
b
.
triangles_n
,
n
)}
for
(
n
=
0
,
m
=
b
.
triangles_n_uv
.
length
;
n
<
m
;
n
+=
10
){
k
(
b
.
triangles_n_uv
,
n
);
r
(
b
.
triangles_n_uv
,
n
+
7
)}
for
(
n
=
0
,
m
=
b
.
quads
.
length
;
n
<
m
;
n
+=
5
){
o
(
b
.
quads
,
n
)}
for
(
n
=
0
,
m
=
b
.
quads_uv
.
length
;
n
<
m
;
n
+=
9
){
o
(
b
.
quads_uv
,
n
);
q
(
b
.
quads_uv
,
n
+
5
)}
for
(
n
=
0
,
m
=
b
.
quads_n
.
length
;
n
<
m
;
n
+=
9
){
j
(
b
.
quads_n
,
n
)}
for
(
n
=
0
,
m
=
b
.
quads_n_uv
.
length
;
n
<
m
;
n
+=
13
){
j
(
b
.
quads_n_uv
,
n
);
q
(
b
.
quads_n_uv
,
n
+
9
)}}};
c
.
prototype
=
new
THREE
.
Geometry
();
c
.
prototype
.
constructor
=
c
;
d
(
new
c
(
a
))},
v
:
function
(
b
,
a
,
d
,
c
){
b
.
vertices
.
push
(
new
THREE
.
Vertex
(
new
THREE
.
Vector3
(
a
,
d
,
c
)))},
f3
:
function
(
h
,
e
,
d
,
i
,
f
){
var
g
=
h
.
materials
[
f
];
h
.
faces
.
push
(
new
THREE
.
Face3
(
e
,
d
,
i
,
null
,
g
))},
f4
:
function
(
i
,
f
,
e
,
k
,
j
,
g
){
var
h
=
i
.
materials
[
g
];
i
.
faces
.
push
(
new
THREE
.
Face4
(
f
,
e
,
k
,
j
,
null
,
h
))},
f3n
:
function
(
d
,
l
,
s
,
r
,
q
,
p
,
j
,
i
,
h
){
var
k
=
d
.
materials
[
p
],
g
=
l
[
j
*
3
],
f
=
l
[
j
*
3
+
1
],
e
=
l
[
j
*
3
+
2
],
o
=
l
[
i
*
3
],
n
=
l
[
i
*
3
+
1
],
m
=
l
[
i
*
3
+
2
],
v
=
l
[
h
*
3
],
u
=
l
[
h
*
3
+
1
],
t
=
l
[
h
*
3
+
2
];
d
.
faces
.
push
(
new
THREE
.
Face3
(
s
,
r
,
q
,[
new
THREE
.
Vector3
(
g
,
f
,
e
),
new
THREE
.
Vector3
(
o
,
n
,
m
),
new
THREE
.
Vector3
(
v
,
u
,
t
)],
k
))},
f4n
:
function
(
e
,
q
,
y
,
x
,
w
,
u
,
v
,
o
,
n
,
m
,
k
){
var
p
=
e
.
materials
[
v
],
j
=
q
[
o
*
3
],
h
=
q
[
o
*
3
+
1
],
f
=
q
[
o
*
3
+
2
],
t
=
q
[
n
*
3
],
s
=
q
[
n
*
3
+
1
],
r
=
q
[
n
*
3
+
2
],
B
=
q
[
m
*
3
],
A
=
q
[
m
*
3
+
1
],
z
=
q
[
m
*
3
+
2
],
l
=
q
[
k
*
3
],
i
=
q
[
k
*
3
+
1
],
g
=
q
[
k
*
3
+
2
];
e
.
faces
.
push
(
new
THREE
.
Face4
(
y
,
x
,
w
,
u
,[
new
THREE
.
Vector3
(
j
,
h
,
f
),
new
THREE
.
Vector3
(
t
,
s
,
r
),
new
THREE
.
Vector3
(
B
,
A
,
z
),
new
THREE
.
Vector3
(
l
,
i
,
g
)],
p
))},
uv
:
function
(
j
,
e
,
i
,
c
,
h
,
b
,
g
,
a
,
f
){
var
d
=
[];
d
.
push
(
new
THREE
.
UV
(
e
,
i
));
d
.
push
(
new
THREE
.
UV
(
c
,
h
));
d
.
push
(
new
THREE
.
UV
(
b
,
g
));
if
(
a
&&
f
){
d
.
push
(
new
THREE
.
UV
(
a
,
f
))}
j
.
uvs
.
push
(
d
)},
init_materials
:
function
(
d
,
a
,
c
){
d
.
materials
=
[];
for
(
var
b
=
0
;
b
<
a
.
length
;
++
b
){
d
.
materials
[
b
]
=
[
THREE
.
Loader
.
prototype
.
createMaterial
(
a
[
b
],
c
)]}},
createMaterial
:
function
(
a
,
c
){
function
g
(
j
){
var
i
=
Math
.
log
(
j
)
/
Math
.
LN2
;
return
Math
.
floor
(
i
)
==
i
}
function
f
(
j
){
var
i
=
Math
.
log
(
j
)
/
Math
.
LN2
;
return
Math
.
pow
(
2
,
Math
.
round
(
i
))}
var
d
,
e
,
h
,
b
;
if
(
a
.
map_diffuse
&&
c
){
e
=
document
.
createElement
(
"
canvas
"
);
d
=
new
THREE
.
MeshBitmapMaterial
(
e
);
h
=
new
Image
();
h
.
onload
=
function
(){
if
(
!
g
(
this
.
width
)
||!
g
(
this
.
height
)){
var
i
=
f
(
this
.
width
),
j
=
f
(
this
.
height
);
d
.
bitmap
.
width
=
i
;
d
.
bitmap
.
height
=
j
;
d
.
bitmap
.
getContext
(
"
2d
"
).
drawImage
(
this
,
0
,
0
,
i
,
j
)}
else
{
d
.
bitmap
=
this
}
d
.
loaded
=
1
};
h
.
src
=
c
+
"
/
"
+
a
.
map_diffuse
}
else
{
if
(
a
.
col_diffuse
){
b
=
(
a
.
col_diffuse
[
0
]
*
255
<<
16
)
+
(
a
.
col_diffuse
[
1
]
*
255
<<
8
)
+
a
.
col_diffuse
[
2
]
*
255
;
d
=
new
THREE
.
MeshColorFillMaterial
(
b
,
a
.
transparency
)}
else
{
if
(
a
.
a_dbg_color
){
d
=
new
THREE
.
MeshColorFillMaterial
(
a
.
a_dbg_color
)}
else
{
d
=
new
THREE
.
MeshColorFillMaterial
(
15658734
)}}}
return
d
}};
THREE
.
Light
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
255
<<
24
|
a
)};
THREE
.
AmbientLight
=
function
(
a
){
THREE
.
Light
.
call
(
this
,
a
)};
THREE
.
AmbientLight
.
prototype
=
new
THREE
.
Light
();
THREE
.
AmbientLight
.
prototype
.
constructor
=
THREE
.
AmbientLight
;
THREE
.
DirectionalLight
=
function
(
b
,
a
){
THREE
.
Light
.
call
(
this
,
b
);
this
.
position
=
new
THREE
.
Vector3
(
0
,
1
,
0
);
this
.
intensity
=
a
||
1
};
THREE
.
DirectionalLight
.
prototype
=
new
THREE
.
Light
();
THREE
.
DirectionalLight
.
prototype
.
constructor
=
THREE
.
DirectionalLight
;
THREE
.
PointLight
=
function
(
b
,
a
){
THREE
.
Light
.
call
(
this
,
b
);
this
.
position
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
this
.
intensity
=
a
||
1
};
THREE
.
DirectionalLight
.
prototype
=
new
THREE
.
Light
();
THREE
.
DirectionalLight
.
prototype
.
constructor
=
THREE
.
PointLight
;
THREE
.
Object3D
=
function
(
a
){
this
.
position
=
new
THREE
.
Vector3
();
this
.
rotation
=
new
THREE
.
Vector3
();
this
.
scale
=
new
THREE
.
Vector3
(
1
,
1
,
1
);
this
.
matrix
=
new
THREE
.
Matrix4
();
this
.
matrixTranslation
=
new
THREE
.
Matrix4
();
this
.
matrixRotation
=
new
THREE
.
Matrix4
();
this
.
matrixScale
=
new
THREE
.
Matrix4
();
this
.
screen
=
new
THREE
.
Vector3
();
this
.
autoUpdateMatrix
=
true
;
this
.
updateMatrix
=
function
(){
this
.
matrixPosition
=
THREE
.
Matrix4
.
translationMatrix
(
this
.
position
.
x
,
this
.
position
.
y
,
this
.
position
.
z
);
this
.
matrixRotation
=
THREE
.
Matrix4
.
rotationXMatrix
(
this
.
rotation
.
x
);
this
.
matrixRotation
.
multiplySelf
(
THREE
.
Matrix4
.
rotationYMatrix
(
this
.
rotation
.
y
));
this
.
matrixRotation
.
multiplySelf
(
THREE
.
Matrix4
.
rotationZMatrix
(
this
.
rotation
.
z
));
this
.
matrixScale
=
THREE
.
Matrix4
.
scaleMatrix
(
this
.
scale
.
x
,
this
.
scale
.
y
,
this
.
scale
.
z
);
this
.
matrix
.
copy
(
this
.
matrixPosition
);
this
.
matrix
.
multiplySelf
(
this
.
matrixRotation
);
this
.
matrix
.
multiplySelf
(
this
.
matrixScale
)}};
THREE
.
Particle
=
function
(
a
){
THREE
.
Object3D
.
call
(
this
);
this
.
material
=
a
instanceof
Array
?
a
:[
a
];
this
.
autoUpdateMatrix
=
false
};
THREE
.
Particle
.
prototype
=
new
THREE
.
Object3D
();
THREE
.
Particle
.
prototype
.
constructor
=
THREE
.
Particle
;
THREE
.
Line
=
function
(
b
,
a
){
THREE
.
Object3D
.
call
(
this
);
this
.
geometry
=
b
;
this
.
material
=
a
instanceof
Array
?
a
:[
a
]};
THREE
.
Line
.
prototype
=
new
THREE
.
Object3D
();
THREE
.
Line
.
prototype
.
constructor
=
THREE
.
Line
;
THREE
.
Mesh
=
function
(
b
,
a
,
c
){
THREE
.
Object3D
.
call
(
this
);
this
.
geometry
=
b
;
this
.
material
=
a
instanceof
Array
?
a
:[
a
];
this
.
flipSided
=
false
;
this
.
doubleSided
=
false
;
this
.
overdraw
=
false
;
this
.
materialFaceGroup
=
{};
this
.
sortFacesByMaterial
();
if
(
c
){
this
.
normalizeUVs
()}
this
.
geometry
.
computeBoundingBox
()};
THREE
.
Mesh
.
prototype
=
new
THREE
.
Object3D
();
THREE
.
Mesh
.
prototype
.
constructor
=
THREE
.
Mesh
;
THREE
.
Mesh
.
prototype
.
sortFacesByMaterial
=
function
(){
var
c
,
b
,
e
,
m
,
k
,
h
,
j
,
n
,
d
,
g
=
{};
function
a
(
f
){
var
i
=
[];
for
(
c
=
0
,
b
=
f
.
length
;
c
<
b
;
c
++
){
if
(
f
[
c
]
==
undefined
){
i
.
push
(
"
undefined
"
)}
else
{
i
.
push
(
f
[
c
].
toString
())}}
return
i
.
join
(
"
_
"
)}
for
(
e
=
0
,
m
=
this
.
geometry
.
faces
.
length
;
e
<
m
;
e
++
){
k
=
this
.
geometry
.
faces
[
e
];
h
=
k
.
material
;
n
=
a
(
h
);
if
(
g
[
n
]
==
undefined
){
g
[
n
]
=
{
hash
:
n
,
counter
:
0
}}
d
=
g
[
n
].
hash
+
"
_
"
+
g
[
n
].
counter
;
if
(
this
.
materialFaceGroup
[
d
]
==
undefined
){
this
.
materialFaceGroup
[
d
]
=
{
faces
:[],
material
:
h
,
vertices
:
0
}}
j
=
k
instanceof
THREE
.
Face3
?
3
:
4
;
if
(
this
.
materialFaceGroup
[
d
].
vertices
+
j
>
65535
){
g
[
n
].
counter
+=
1
;
d
=
g
[
n
].
hash
+
"
_
"
+
g
[
n
].
counter
;
if
(
this
.
materialFaceGroup
[
d
]
==
undefined
){
this
.
materialFaceGroup
[
d
]
=
{
faces
:[],
material
:
h
,
vertices
:
0
}}}
this
.
materialFaceGroup
[
d
].
faces
.
push
(
e
);
this
.
materialFaceGroup
[
d
].
vertices
+=
j
}};
THREE
.
Mesh
.
prototype
.
normalizeUVs
=
function
(){
var
e
,
a
,
b
,
d
,
c
;
for
(
e
=
0
,
a
=
this
.
geometry
.
uvs
.
length
;
e
<
a
;
e
++
){
c
=
this
.
geometry
.
uvs
[
e
];
for
(
b
=
0
,
d
=
c
.
length
;
b
<
d
;
b
++
){
if
(
c
[
b
].
u
!=
1
){
c
[
b
].
u
=
c
[
b
].
u
-
Math
.
floor
(
c
[
b
].
u
)}
if
(
c
[
b
].
v
!=
1
){
c
[
b
].
v
=
c
[
b
].
v
-
Math
.
floor
(
c
[
b
].
v
)}}}};
THREE
.
FlatShading
=
0
;
THREE
.
GouraudShading
=
1
;
THREE
.
PhongShading
=
2
;
THREE
.
NormalBlending
=
0
;
THREE
.
AdditiveBlending
=
1
;
THREE
.
SubstractiveBlending
=
2
;
THREE
.
LineBasicMaterial
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
linewidth
=
1
;
if
(
a
){
if
(
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
.
linewidth
!==
undefined
){
this
.
linewidth
=
a
.
linewidth
}}
this
.
toString
=
function
(){
return
"
THREE.LineBasicMaterial (<br/>color:
"
+
this
.
color
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>linewidth:
"
+
this
.
linewidth
+
"
<br/>)
"
}};
THREE
.
MeshBasicMaterial
=
function
(
a
){
this
.
id
=
THREE
.
MeshBasicMaterialCounter
.
value
++
;
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
wireframe
=
false
;
this
.
wireframe_linewidth
=
1
;
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
.
setHex
(
a
.
color
)}
if
(
a
.
map
!==
undefined
){
this
.
map
=
a
.
map
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}
if
(
a
.
wireframe
!==
undefined
){
this
.
wireframe
=
a
.
wireframe
}
if
(
a
.
wireframe_linewidth
!==
undefined
){
this
.
wireframe_linewidth
=
a
.
wireframe_linewidth
}}
this
.
toString
=
function
(){
return
"
THREE.MeshBasicMaterial (<br/>id:
"
+
this
.
id
+
"
<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>wireframe:
"
+
this
.
wireframe
+
"
<br/>wireframe_linewidth:
"
+
this
.
wireframe_linewidth
+
"
<br/>)
"
}};
THREE
.
MeshBasicMaterialCounter
=
{
value
:
0
};
THREE
.
MeshDepthMaterial
=
function
(
a
){
this
.
near
=
1
;
this
.
far
=
1000
;
this
.
opacity
=
1
;
this
.
wireframe
=
false
;
this
.
wireframe_linewidth
=
1
;
if
(
a
){
if
(
a
.
near
!==
undefined
){
this
.
near
=
a
.
near
}
if
(
a
.
far
!==
undefined
){
this
.
far
=
a
.
far
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
wireframe
!==
undefined
){
this
.
wireframe
=
a
.
wireframe
}
if
(
a
.
wireframe_linewidth
!==
undefined
){
this
.
wireframe_linewidth
=
a
.
wireframe_linewidth
}}
this
.
__2near
=
2
*
this
.
near
;
this
.
__farPlusNear
=
this
.
far
+
this
.
near
;
this
.
__farMinusNear
=
this
.
far
-
this
.
near
;
this
.
toString
=
function
(){
return
"
THREE.MeshDepthMaterial
"
}};
THREE
.
MeshLambertMaterial
=
function
(
a
){
this
.
id
=
THREE
.
MeshLambertMaterialCounter
.
value
++
;
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
opacity
=
1
;
this
.
shading
=
THREE
.
GouraudShading
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
wireframe
=
false
;
this
.
wireframe_linewidth
=
1
;
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
.
setHex
(
a
.
color
)}
if
(
a
.
map
!==
undefined
){
this
.
map
=
a
.
map
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
shading
!==
undefined
){
this
.
shading
=
a
.
shading
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}
if
(
a
.
wireframe
!==
undefined
){
this
.
wireframe
=
a
.
wireframe
}
if
(
a
.
wireframe_linewidth
!==
undefined
){
this
.
wireframe_linewidth
=
a
.
wireframe_linewidth
}}
this
.
toString
=
function
(){
return
"
THREE.MeshLambertMaterial (<br/>id:
"
+
this
.
id
+
"
<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>shading:
"
+
this
.
shading
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>wireframe:
"
+
this
.
wireframe
+
"
<br/>wireframe_size:
"
+
this
.
wireframe_linewidth
+
"
<br/> )
"
}};
THREE
.
MeshLambertMaterialCounter
=
{
value
:
0
};
THREE
.
MeshPhongMaterial
=
function
(
a
){
this
.
id
=
THREE
.
MeshPhongMaterialCounter
.
value
++
;
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
ambient
=
new
THREE
.
Color
(
328965
);
this
.
specular
=
new
THREE
.
Color
(
1118481
);
this
.
specular_map
=
null
;
this
.
shininess
=
30
;
this
.
opacity
=
1
;
this
.
shading
=
THREE
.
GouraudShading
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
wireframe
=
false
;
this
.
wireframe_linewidth
=
1
;
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
=
new
THREE
.
Color
(
a
.
color
)}
if
(
a
.
map
!==
undefined
){
this
.
map
=
a
.
map
}
if
(
a
.
ambient
!==
undefined
){
this
.
ambient
=
new
THREE
.
Color
(
a
.
ambient
)}
if
(
a
.
specular
!==
undefined
){
this
.
specular_color
=
new
THREE
.
Color
(
a
.
specular
)}
if
(
a
.
specular_map
!==
undefined
){
this
.
specular_map
=
a
.
specular_map
}
if
(
a
.
shininess
!==
undefined
){
this
.
shininess
=
a
.
shininess
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
shading
!==
undefined
){
this
.
shading
=
a
.
shading
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}
if
(
a
.
wireframe
!==
undefined
){
this
.
wireframe
=
a
.
wireframe
}
if
(
a
.
wireframe_linewidth
!==
undefined
){
this
.
wireframe_linewidth
=
a
.
wireframe_linewidth
}}
this
.
toString
=
function
(){
return
"
THREE.MeshPhongMaterial (<br/>id:
"
+
this
.
id
+
"
<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>ambient:
"
+
this
.
ambient
+
"
<br/>specular:
"
+
this
.
specular
+
"
<br/>specular_map:
"
+
this
.
specular_map
+
"
<br/>shininess:
"
+
this
.
shininess
+
"
<br/>alpha:
"
+
this
.
opacity
+
"
<br/>shading:
"
+
this
.
shading
+
"
<br/>wireframe:
"
+
this
.
wireframe
+
"
<br/>wireframe_linewidth:
"
+
this
.
wireframe_linewidth
+
"
<br/>
"
+
+
"
)
"
}};
THREE
.
MeshPhongMaterialCounter
=
{
value
:
0
};
THREE
.
MeshFaceMaterial
=
function
(){
this
.
toString
=
function
(){
return
"
THREE.MeshFaceMaterial
"
}};
THREE
.
ParticleBasicMaterial
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
offset
=
new
THREE
.
Vector2
();
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
.
setHex
(
a
.
color
)}
if
(
a
.
map
!==
undefined
){
this
.
map
=
a
.
map
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}}
this
.
toString
=
function
(){
return
"
THREE.ParticleBasicMaterial (<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>)
"
}};
THREE
.
ParticleCircleMaterial
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
.
setHex
(
a
.
color
)}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}}
this
.
toString
=
function
(){
return
"
THREE.ParticleCircleMaterial (<br/>color:
"
+
this
.
color
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>)
"
}};
THREE
.
ParticleDOMMaterial
=
function
(
a
){
this
.
domElement
=
a
;
this
.
toString
=
function
(){
return
"
THREE.ParticleDOMMaterial ( domElement:
"
+
this
.
domElement
+
"
)
"
}};
THREE
.
Texture
=
function
(
b
,
a
){
this
.
image
=
b
;
this
.
mapping
=
a
?
a
:
THREE
.
UVMapping
;
this
.
toString
=
function
(){
return
"
THREE.Texture (<br/>image:
"
+
this
.
image
+
"
<br/>mapping:
"
+
this
.
mapping
+
"
<br/>)
"
}};
THREE
.
UVMapping
=
0
;
THREE
.
ReflectionMap
=
1
;
THREE
.
CubeMap
=
2
;
THREE
.
Scene
=
function
(){
this
.
objects
=
[];
this
.
lights
=
[];
this
.
addObject
=
function
(
a
){
this
.
objects
.
push
(
a
)};
this
.
removeObject
=
function
(
a
){
var
b
=
this
.
objects
.
indexOf
(
a
);
if
(
b
!==-
1
){
this
.
objects
.
splice
(
b
,
1
)}};
this
.
addLight
=
function
(
a
){
this
.
lights
.
push
(
a
)};
this
.
removeLight
=
function
(
a
){
var
b
=
this
.
lights
.
indexOf
(
a
);
if
(
b
!==-
1
){
this
.
lights
.
splice
(
b
,
1
)}};
this
.
toString
=
function
(){
return
"
THREE.Scene (
"
+
this
.
objects
+
"
)
"
}};
THREE
.
Projector
=
function
(){
var
e
=
null
,
c
,
p
,
n
=
[],
b
,
f
,
l
=
[],
k
,
m
,
i
=
[],
j
,
h
,
a
=
[],
g
=
new
THREE
.
Vector4
(),
d
=
new
THREE
.
Matrix4
(),
o
=
new
THREE
.
Matrix4
();
this
.
projectScene
=
function
(
J
,
G
){
var
F
,
E
,
D
,
K
,
I
,
B
,
r
,
L
,
q
,
z
,
H
,
u
,
C
,
w
,
A
,
y
,
x
,
t
,
s
;
e
=
[];
p
=
0
,
f
=
0
,
m
=
0
,
h
=
0
;
if
(
G
.
autoUpdateMatrix
){
G
.
updateMatrix
()}
d
.
multiply
(
G
.
projectionMatrix
,
G
.
matrix
);
r
=
J
.
objects
;
for
(
F
=
0
,
E
=
r
.
length
;
F
<
E
;
F
++
){
L
=
r
[
F
];
q
=
L
.
matrix
;
if
(
L
.
autoUpdateMatrix
){
L
.
updateMatrix
()}
if
(
L
instanceof
THREE
.
Mesh
){
o
.
multiply
(
d
,
q
);
z
=
L
.
geometry
.
vertices
;
for
(
D
=
0
,
K
=
z
.
length
;
D
<
K
;
D
++
){
H
=
z
[
D
];
u
=
H
.
positionScreen
;
u
.
copy
(
H
.
position
);
o
.
transform
(
u
);
H
.
__visible
=
u
.
z
>
0
&&
u
.
z
<
1
}
w
=
L
.
geometry
.
faces
;
for
(
I
=
0
,
B
=
w
.
length
;
I
<
B
;
I
++
){
A
=
w
[
I
];
if
(
A
instanceof
THREE
.
Face3
){
y
=
z
[
A
.
a
];
x
=
z
[
A
.
b
];
t
=
z
[
A
.
c
];
if
(
y
.
__visible
&&
x
.
__visible
&&
t
.
__visible
){
if
((
L
.
doubleSided
||
(
L
.
flipSided
!=
(
t
.
positionScreen
.
x
-
y
.
positionScreen
.
x
)
*
(
x
.
positionScreen
.
y
-
y
.
positionScreen
.
y
)
-
(
t
.
positionScreen
.
y
-
y
.
positionScreen
.
y
)
*
(
x
.
positionScreen
.
x
-
y
.
positionScreen
.
x
)
<
0
))){
c
=
n
[
p
]
=
n
[
p
]
||
new
THREE
.
RenderableFace3
();
c
.
v1
.
copy
(
y
.
positionScreen
);
c
.
v2
.
copy
(
x
.
positionScreen
);
c
.
v3
.
copy
(
t
.
positionScreen
);
c
.
normalWorld
.
copy
(
A
.
normal
);
L
.
matrixRotation
.
transform
(
c
.
normalWorld
);
c
.
centroidWorld
.
copy
(
A
.
centroid
);
q
.
transform
(
c
.
centroidWorld
);
c
.
centroidScreen
.
copy
(
c
.
centroidWorld
);
d
.
transform
(
c
.
centroidScreen
);
c
.
z
=
c
.
centroidScreen
.
z
;
c
.
meshMaterial
=
L
.
material
;
c
.
faceMaterial
=
A
.
material
;
c
.
overdraw
=
L
.
overdraw
;
c
.
uvs
=
L
.
geometry
.
uvs
[
I
];
c
.
color
=
A
.
color
;
e
.
push
(
c
);
p
++
}}}
else
{
if
(
A
instanceof
THREE
.
Face4
){
y
=
z
[
A
.
a
];
x
=
z
[
A
.
b
];
t
=
z
[
A
.
c
];
s
=
z
[
A
.
d
];
if
(
y
.
__visible
&&
x
.
__visible
&&
t
.
__visible
&&
s
.
__visible
){
if
((
L
.
doubleSided
||
(
L
.
flipSided
!=
((
s
.
positionScreen
.
x
-
y
.
positionScreen
.
x
)
*
(
x
.
positionScreen
.
y
-
y
.
positionScreen
.
y
)
-
(
s
.
positionScreen
.
y
-
y
.
positionScreen
.
y
)
*
(
x
.
positionScreen
.
x
-
y
.
positionScreen
.
x
)
<
0
||
(
x
.
positionScreen
.
x
-
t
.
positionScreen
.
x
)
*
(
s
.
positionScreen
.
y
-
t
.
positionScreen
.
y
)
-
(
x
.
positionScreen
.
y
-
t
.
positionScreen
.
y
)
*
(
s
.
positionScreen
.
x
-
t
.
positionScreen
.
x
)
<
0
)))){
b
=
l
[
f
]
=
l
[
f
]
||
new
THREE
.
RenderableFace4
();
b
.
v1
.
copy
(
y
.
positionScreen
);
b
.
v2
.
copy
(
x
.
positionScreen
);
b
.
v3
.
copy
(
t
.
positionScreen
);
b
.
v4
.
copy
(
s
.
positionScreen
);
b
.
normalWorld
.
copy
(
A
.
normal
);
L
.
matrixRotation
.
transform
(
b
.
normalWorld
);
b
.
centroidWorld
.
copy
(
A
.
centroid
);
q
.
transform
(
b
.
centroidWorld
);
b
.
centroidScreen
.
copy
(
b
.
centroidWorld
);
d
.
transform
(
b
.
centroidScreen
);
b
.
z
=
b
.
centroidScreen
.
z
;
b
.
meshMaterial
=
L
.
material
;
b
.
faceMaterial
=
A
.
material
;
b
.
overdraw
=
L
.
overdraw
;
b
.
uvs
=
L
.
geometry
.
uvs
[
I
];
b
.
color
=
A
.
color
;
e
.
push
(
b
);
f
++
}}}}}}
else
{
if
(
L
instanceof
THREE
.
Line
){
o
.
multiply
(
d
,
q
);
z
=
L
.
geometry
.
vertices
;
for
(
D
=
0
,
K
=
z
.
length
;
D
<
K
;
D
++
){
H
=
z
[
D
];
u
=
H
.
positionScreen
;
u
.
copy
(
H
.
position
);
o
.
transform
(
u
);
H
.
__visible
=
u
.
z
>
0
&&
u
.
z
<
1
;
if
(
D
>
0
){
C
=
L
.
geometry
.
vertices
[
D
-
1
];
if
(
H
.
__visible
&&
C
.
__visible
){
k
=
i
[
m
]
=
i
[
m
]
||
new
THREE
.
RenderableLine
();
k
.
v1
.
copy
(
H
.
positionScreen
);
k
.
v2
.
copy
(
C
.
positionScreen
);
k
.
z
=
Math
.
max
(
H
.
positionScreen
.
z
,
C
.
positionScreen
.
z
);
k
.
material
=
L
.
material
;
e
.
push
(
k
);
m
++
}}}}
else
{
if
(
L
instanceof
THREE
.
Particle
){
g
.
set
(
L
.
position
.
x
,
L
.
position
.
y
,
L
.
position
.
z
,
1
);
d
.
transform
(
g
);
g
.
z
/=
g
.
w
;
if
(
g
.
z
>
0
&&
g
.
z
<
1
){
j
=
a
[
h
]
=
a
[
h
]
||
new
THREE
.
RenderableParticle
();
j
.
x
=
g
.
x
/
g
.
w
;
j
.
y
=
g
.
y
/
g
.
w
;
j
.
z
=
g
.
z
;
j
.
rotation
=
L
.
rotation
.
z
;
j
.
scale
.
x
=
L
.
scale
.
x
*
Math
.
abs
(
j
.
x
-
(
g
.
x
+
G
.
projectionMatrix
.
n11
)
/
(
g
.
w
+
G
.
projectionMatrix
.
n14
));
j
.
scale
.
y
=
L
.
scale
.
y
*
Math
.
abs
(
j
.
y
-
(
g
.
y
+
G
.
projectionMatrix
.
n22
)
/
(
g
.
w
+
G
.
projectionMatrix
.
n24
));
j
.
material
=
L
.
material
;
e
.
push
(
j
);
h
++
}}}}}
e
.
sort
(
function
(
M
,
v
){
return
v
.
z
-
M
.
z
});
return
e
};
this
.
unprojectVector
=
function
(
q
,
s
){
var
r
=
new
THREE
.
Matrix4
();
r
.
multiply
(
THREE
.
Matrix4
.
makeInvert
(
s
.
matrix
),
THREE
.
Matrix4
.
makeInvert
(
s
.
projectionMatrix
));
r
.
transform
(
q
);
return
q
}};
THREE
.
DOMRenderer
=
function
(){
THREE
.
Renderer
.
call
(
this
);
var
e
=
null
,
g
=
new
THREE
.
Projector
(),
b
=
document
.
createElement
(
"
div
"
),
a
,
c
,
f
,
d
;
this
.
domElement
=
b
;
this
.
setSize
=
function
(
i
,
h
){
a
=
i
;
c
=
h
;
f
=
a
/
2
;
d
=
c
/
2
};
this
.
render
=
function
(
p
,
r
){
var
q
,
h
,
i
,
n
,
o
,
s
,
l
,
k
,
j
;
e
=
g
.
projectScene
(
p
,
r
);
for
(
q
=
0
,
h
=
e
.
length
;
q
<
h
;
q
++
){
o
=
e
[
q
];
if
(
o
instanceof
THREE
.
RenderableParticle
){
k
=
o
.
x
*
f
+
f
;
j
=
o
.
y
*
d
+
d
;
for
(
i
=
0
,
n
=
o
.
material
.
length
;
i
<
n
;
i
++
){
s
=
o
.
material
[
i
];
if
(
s
instanceof
THREE
.
ParticleDOMMaterial
){
l
=
s
.
domElement
;
l
.
style
.
left
=
k
+
"
px
"
;
l
.
style
.
top
=
j
+
"
px
"
}}}}}};
THREE
.
CanvasRenderer
=
function
(){
var
n
=
null
,
x
=
new
THREE
.
Projector
(),
s
=
document
.
createElement
(
"
canvas
"
),
a
,
F
,
v
,
h
,
r
=
s
.
getContext
(
"
2d
"
),
B
=
1
,
i
=
"
#000000
"
,
L
=
"
#000000
"
,
f
=
1
,
w
=
new
THREE
.
Rectangle
(),
I
=
new
THREE
.
Rectangle
(),
m
=
new
THREE
.
Rectangle
(),
D
=
false
,
A
=
new
THREE
.
Color
(
4294967295
),
y
=
new
THREE
.
Color
(
4294967295
),
H
=
new
THREE
.
Color
(
4278190080
),
k
=
Math
.
PI
*
2
,
C
,
G
=
new
THREE
.
Vector2
(),
E
=
new
THREE
.
Vector3
(),
u
=
new
THREE
.
UV
(),
t
=
new
THREE
.
UV
(),
q
=
new
THREE
.
UV
(),
p
=
new
THREE
.
UV
(),
K
=
new
THREE
.
Vector2
(),
J
=
new
THREE
.
Vector2
();
this
.
domElement
=
s
;
this
.
autoClear
=
true
;
this
.
setSize
=
function
(
N
,
M
){
a
=
N
;
F
=
M
;
v
=
a
/
2
;
h
=
F
/
2
;
s
.
width
=
a
;
s
.
height
=
F
;
r
.
lineJoin
=
"
round
"
;
r
.
lineCap
=
"
round
"
;
w
.
set
(
-
v
,
-
h
,
v
,
h
)};
this
.
clear
=
function
(){
if
(
!
I
.
isEmpty
()){
I
.
inflate
(
1
);
I
.
minSelf
(
w
);
r
.
setTransform
(
1
,
0
,
0
,
-
1
,
v
,
h
);
r
.
clearRect
(
I
.
getX
(),
I
.
getY
(),
I
.
getWidth
(),
I
.
getHeight
());
I
.
empty
()}};
this
.
render
=
function
(
ah
,
ae
){
var
ag
,
P
,
R
,
Z
,
af
,
V
,
S
,
Y
,
W
,
T
,
ac
,
aa
,
O
,
M
,
X
,
U
,
ad
,
ab
,
Q
,
N
;
if
(
this
.
autoClear
){
this
.
clear
()}
n
=
x
.
projectScene
(
ah
,
ae
);
r
.
setTransform
(
1
,
0
,
0
,
-
1
,
v
,
h
);
D
=
ah
.
lights
.
length
>
0
;
if
(
D
){
e
(
ah
,
H
)}
for
(
ag
=
0
,
P
=
n
.
length
;
ag
<
P
;
ag
++
){
R
=
n
[
ag
];
m
.
empty
();
if
(
R
instanceof
THREE
.
RenderableParticle
){
W
=
R
.
x
*
v
;
T
=
R
.
y
*
h
;
for
(
Z
=
0
,
af
=
R
.
material
.
length
;
Z
<
af
;
Z
++
){
Y
=
R
.
material
[
Z
];
Y
&&
o
(
W
,
T
,
R
,
Y
,
ah
)}}
else
{
if
(
R
instanceof
THREE
.
RenderableLine
){
W
=
R
.
v1
.
x
*
v
;
T
=
R
.
v1
.
y
*
h
;
ac
=
R
.
v2
.
x
*
v
;
aa
=
R
.
v2
.
y
*
h
;
m
.
addPoint
(
W
,
T
);
m
.
addPoint
(
ac
,
aa
);
if
(
!
w
.
instersects
(
m
)){
continue
}
Z
=
0
;
af
=
R
.
material
.
length
;
while
(
Z
<
af
){
Y
=
R
.
material
[
Z
++
];
Y
&&
z
(
W
,
T
,
ac
,
aa
,
R
,
Y
,
ah
)}}
else
{
if
(
R
instanceof
THREE
.
RenderableFace3
){
R
.
v1
.
x
*=
v
;
R
.
v1
.
y
*=
h
;
R
.
v2
.
x
*=
v
;
R
.
v2
.
y
*=
h
;
R
.
v3
.
x
*=
v
;
R
.
v3
.
y
*=
h
;
if
(
R
.
overdraw
){
b
(
R
.
v1
,
R
.
v2
);
b
(
R
.
v2
,
R
.
v3
);
b
(
R
.
v3
,
R
.
v1
)}
W
=
R
.
v1
.
x
;
T
=
R
.
v1
.
y
;
ac
=
R
.
v2
.
x
;
aa
=
R
.
v2
.
y
;
O
=
R
.
v3
.
x
;
M
=
R
.
v3
.
y
;
m
.
addPoint
(
W
,
T
);
m
.
addPoint
(
ac
,
aa
);
m
.
addPoint
(
O
,
M
);
if
(
!
w
.
instersects
(
m
)){
continue
}
Z
=
0
;
af
=
R
.
meshMaterial
.
length
;
while
(
Z
<
af
){
Y
=
R
.
meshMaterial
[
Z
++
];
if
(
Y
instanceof
THREE
.
MeshFaceMaterial
){
V
=
0
;
S
=
R
.
faceMaterial
.
length
;
while
(
V
<
S
){
Y
=
R
.
faceMaterial
[
V
++
];
Y
&&
l
(
W
,
T
,
ac
,
aa
,
O
,
M
,
R
,
Y
,
ah
)}
continue
}
l
(
W
,
T
,
ac
,
aa
,
O
,
M
,
R
,
Y
,
ah
)}}
else
{
if
(
R
instanceof
THREE
.
RenderableFace4
){
R
.
v1
.
x
*=
v
;
R
.
v1
.
y
*=
h
;
R
.
v2
.
x
*=
v
;
R
.
v2
.
y
*=
h
;
R
.
v3
.
x
*=
v
;
R
.
v3
.
y
*=
h
;
R
.
v4
.
x
*=
v
;
R
.
v4
.
y
*=
h
;
K
.
copy
(
R
.
v2
);
J
.
copy
(
R
.
v4
);
if
(
R
.
overdraw
){
b
(
R
.
v1
,
R
.
v2
);
b
(
R
.
v2
,
R
.
v4
);
b
(
R
.
v4
,
R
.
v1
)}
W
=
R
.
v1
.
x
;
T
=
R
.
v1
.
y
;
ac
=
R
.
v2
.
x
;
aa
=
R
.
v2
.
y
;
X
=
R
.
v4
.
x
;
U
=
R
.
v4
.
y
;
if
(
R
.
overdraw
){
b
(
R
.
v3
,
K
);
b
(
R
.
v3
,
J
)}
O
=
R
.
v3
.
x
;
M
=
R
.
v3
.
y
;
ad
=
K
.
x
;
ab
=
K
.
y
;
Q
=
J
.
x
;
N
=
J
.
y
;
m
.
addPoint
(
W
,
T
);
m
.
addPoint
(
ac
,
aa
);
m
.
addPoint
(
O
,
M
);
m
.
addPoint
(
X
,
U
);
if
(
!
w
.
instersects
(
m
)){
continue
}
Z
=
0
;
af
=
R
.
meshMaterial
.
length
;
while
(
Z
<
af
){
Y
=
R
.
meshMaterial
[
Z
++
];
if
(
Y
instanceof
THREE
.
MeshFaceMaterial
){
V
=
0
;
S
=
R
.
faceMaterial
.
length
;
while
(
V
<
S
){
Y
=
R
.
faceMaterial
[
V
++
];
Y
&&
j
(
W
,
T
,
ac
,
aa
,
O
,
M
,
X
,
U
,
ad
,
ab
,
Q
,
N
,
R
,
Y
,
ah
)}
continue
}
j
(
W
,
T
,
ac
,
aa
,
O
,
M
,
X
,
U
,
ad
,
ab
,
Q
,
N
,
R
,
Y
,
ah
)}}}}}
I
.
addRectangle
(
m
)}
r
.
setTransform
(
1
,
0
,
0
,
1
,
0
,
0
)};
function
e
(
S
,
P
){
var
O
,
R
,
N
,
M
,
Q
=
S
.
lights
;
P
.
setRGBA
(
0
,
0
,
0
,
1
);
for
(
O
=
0
,
R
=
Q
.
length
;
O
<
R
;
O
++
){
N
=
Q
[
O
];
M
=
N
.
color
;
if
(
N
instanceof
THREE
.
AmbientLight
){
P
.
r
+=
M
.
r
;
P
.
g
+=
M
.
g
;
P
.
b
+=
M
.
b
}}}
function
g
(
T
,
R
,
P
){
var
O
,
S
,
N
,
M
,
Q
=
T
.
lights
;
for
(
O
=
0
,
S
=
Q
.
length
;
O
<
S
;
O
++
){
N
=
Q
[
O
];
M
=
N
.
color
;
if
(
N
instanceof
THREE
.
DirectionalLight
){
P
.
r
+=
M
.
r
;
P
.
g
+=
M
.
g
;
P
.
b
+=
M
.
b
}
else
{
if
(
N
instanceof
THREE
.
PointLight
){
P
.
r
+=
M
.
r
;
P
.
g
+=
M
.
g
;
P
.
b
+=
M
.
b
}}}}
function
d
(
T
,
R
,
P
){
var
O
,
S
,
N
,
M
,
Q
;
lights
=
T
.
lights
;
for
(
O
=
0
,
S
=
lights
.
length
;
O
<
S
;
O
++
){
N
=
lights
[
O
];
M
=
N
.
color
;
if
(
N
instanceof
THREE
.
DirectionalLight
){
Q
=
R
.
normalWorld
.
dot
(
N
.
position
)
*
N
.
intensity
;
if
(
Q
>
0
){
P
.
r
+=
M
.
r
*
Q
;
P
.
g
+=
M
.
g
*
Q
;
P
.
b
+=
M
.
b
*
Q
}}
else
{
if
(
N
instanceof
THREE
.
PointLight
){
E
.
sub
(
N
.
position
,
R
.
centroidWorld
);
E
.
normalize
();
Q
=
R
.
normalWorld
.
dot
(
E
)
*
N
.
intensity
;
if
(
Q
>
0
){
P
.
r
+=
M
.
r
*
Q
;
P
.
g
+=
M
.
g
*
Q
;
P
.
b
+=
M
.
b
*
Q
}}}}}
function
o
(
O
,
N
,
R
,
U
,
T
){
var
M
,
Z
,
X
,
W
,
S
,
Q
,
V
,
Y
,
P
;
if
(
B
!=
U
.
opacity
){
r
.
globalAlpha
=
B
=
U
.
opacity
}
if
(
U
instanceof
THREE
.
ParticleBasicMaterial
){
V
=
U
.
bitmap
;
Y
=
V
.
width
/
2
;
P
=
V
.
height
/
2
;
X
=
R
.
scale
.
x
*
v
;
W
=
R
.
scale
.
y
*
h
;
M
=
X
*
Y
;
Z
=
W
*
P
;
S
=
U
.
offset
.
x
*
X
;
Q
=
U
.
offset
.
y
*
W
;
m
.
set
(
O
+
S
-
M
,
N
+
Q
-
Z
,
O
+
S
+
M
,
N
+
Q
+
Z
);
if
(
!
w
.
instersects
(
m
)){
return
}
r
.
save
();
r
.
translate
(
O
,
N
);
r
.
rotate
(
-
R
.
rotation
);
r
.
scale
(
X
,
-
W
);
r
.
translate
(
-
Y
+
U
.
offset
.
x
,
-
P
-
U
.
offset
.
y
);
r
.
drawImage
(
V
,
0
,
0
);
r
.
restore
()}
else
{
if
(
U
instanceof
THREE
.
ParticleCircleMaterial
){
if
(
D
){
y
.
copyRGB
(
H
);
g
(
T
,
R
,
y
);
A
.
copyRGBA
(
U
.
color
);
A
.
multiplySelfRGB
(
y
);
A
.
updateStyleString
()}
else
{
A
.
__styleString
=
U
.
color
.
__styleString
}
M
=
R
.
scale
.
x
*
v
;
Z
=
R
.
scale
.
y
*
h
;
m
.
set
(
O
-
M
,
N
-
Z
,
O
+
M
,
N
+
Z
);
if
(
!
w
.
instersects
(
m
)){
return
}
r
.
save
();
r
.
translate
(
O
,
N
);
r
.
rotate
(
-
R
.
rotation
);
r
.
scale
(
M
,
Z
);
r
.
beginPath
();
r
.
arc
(
0
,
0
,
1
,
0
,
k
,
true
);
r
.
closePath
();
r
.
fillStyle
=
A
.
__styleString
;
r
.
fill
();
r
.
restore
()}}}
function
z
(
M
,
S
,
O
,
N
,
P
,
Q
,
R
){
if
(
B
!=
Q
.
opacity
){
r
.
globalAlpha
=
B
=
Q
.
opacity
}
if
(
Q
instanceof
THREE
.
LineBasicMaterial
){
r
.
beginPath
();
r
.
moveTo
(
M
,
S
);
r
.
lineTo
(
O
,
N
);
r
.
closePath
();
A
.
__styleString
=
Q
.
color
.
__styleString
;
if
(
f
!=
Q
.
linewidth
){
r
.
lineWidth
=
f
=
Q
.
linewidth
}
if
(
i
!=
A
.
__styleString
){
r
.
strokeStyle
=
i
=
A
.
__styleString
}
r
.
stroke
();
m
.
inflate
(
Q
.
linewidth
*
2
)}}
function
l
(
O
,
N
,
M
,
X
,
U
,
T
,
Q
,
S
,
R
){
var
V
,
W
,
P
;
if
(
B
!=
S
.
opacity
){
r
.
globalAlpha
=
B
=
S
.
opacity
}
if
(
S
.
map
){
V
=
S
.
map
.
image
;
W
=
V
.
width
-
1
;
P
=
V
.
height
-
1
;
u
.
copy
(
Q
.
uvs
[
0
]);
t
.
copy
(
Q
.
uvs
[
1
]);
q
.
copy
(
Q
.
uvs
[
2
]);
u
.
u
*=
W
;
u
.
v
*=
P
;
t
.
u
*=
W
;
t
.
v
*=
P
;
q
.
u
*=
W
;
q
.
v
*=
P
;
c
(
V
,
O
,
N
,
M
,
X
,
U
,
T
,
u
.
u
,
u
.
v
,
t
.
u
,
t
.
v
,
q
.
u
,
q
.
v
);
return
}
r
.
beginPath
();
r
.
moveTo
(
O
,
N
);
r
.
lineTo
(
M
,
X
);
r
.
lineTo
(
U
,
T
);
r
.
lineTo
(
O
,
N
);
r
.
closePath
();
if
(
S
instanceof
THREE
.
MeshBasicMaterial
){
A
.
__styleString
=
S
.
color
.
__styleString
}
else
{
if
(
S
instanceof
THREE
.
MeshDepthMaterial
){
C
=
1
-
(
S
.
__2near
/
(
S
.
__farPlusNear
-
Q
.
z
*
S
.
__farMinusNear
));
A
.
setRGBA
(
C
,
C
,
C
,
1
)}
else
{
if
(
S
instanceof
THREE
.
MeshLambertMaterial
){
if
(
D
){
y
.
copyRGB
(
H
);
d
(
R
,
Q
,
y
);
A
.
copyRGBA
(
S
.
color
);
A
.
multiplySelfRGB
(
y
);
A
.
updateStyleString
()}
else
{
A
.
__styleString
=
S
.
color
.
__styleString
}}}}
if
(
S
.
wireframe
){
if
(
f
!=
S
.
wireframe_linewidth
){
r
.
lineWidth
=
f
=
S
.
wireframe_linewidth
}
if
(
i
!=
A
.
__styleString
){
r
.
strokeStyle
=
i
=
A
.
__styleString
}
r
.
stroke
();
m
.
inflate
(
S
.
wireframe_linewidth
*
2
)}
else
{
if
(
L
!=
A
.
__styleString
){
r
.
fillStyle
=
L
=
A
.
__styleString
}
r
.
fill
()}}
function
j
(
S
,
R
,
aa
,
Y
,
N
,
M
,
U
,
T
,
ab
,
Z
,
P
,
O
,
Q
,
W
,
ac
){
var
ad
,
V
,
X
;
if
(
B
!=
W
.
opacity
){
r
.
globalAlpha
=
B
=
W
.
opacity
}
if
(
W
.
map
){
ad
=
W
.
map
.
image
;
V
=
ad
.
width
-
1
;
X
=
ad
.
height
-
1
;
u
.
copy
(
Q
.
uvs
[
0
]);
t
.
copy
(
Q
.
uvs
[
1
]);
q
.
copy
(
Q
.
uvs
[
2
]);
p
.
copy
(
Q
.
uvs
[
3
]);
u
.
u
*=
V
;
u
.
v
*=
X
;
t
.
u
*=
V
;
t
.
v
*=
X
;
q
.
u
*=
V
;
q
.
v
*=
X
;
p
.
u
*=
V
;
p
.
v
*=
X
;
c
(
ad
,
S
,
R
,
aa
,
Y
,
U
,
T
,
u
.
u
,
u
.
v
,
t
.
u
,
t
.
v
,
p
.
u
,
p
.
v
);
c
(
ad
,
ab
,
Z
,
N
,
M
,
P
,
O
,
t
.
u
,
t
.
v
,
q
.
u
,
q
.
v
,
p
.
u
,
p
.
v
);
return
}
r
.
beginPath
();
r
.
moveTo
(
S
,
R
);
r
.
lineTo
(
aa
,
Y
);
r
.
lineTo
(
N
,
M
);
r
.
lineTo
(
U
,
T
);
r
.
lineTo
(
S
,
R
);
r
.
closePath
();
if
(
W
instanceof
THREE
.
MeshBasicMaterial
){
A
.
__styleString
=
W
.
color
.
__styleString
}
else
{
if
(
W
instanceof
THREE
.
MeshDepthMaterial
){
C
=
1
-
(
W
.
__2near
/
(
W
.
__farPlusNear
-
Q
.
z
*
W
.
__farMinusNear
));
A
.
setRGBA
(
C
,
C
,
C
,
1
)}
else
{
if
(
W
instanceof
THREE
.
MeshLambertMaterial
){
if
(
D
){
y
.
copyRGB
(
H
);
d
(
ac
,
Q
,
y
);
A
.
copyRGBA
(
W
.
color
);
A
.
multiplySelfRGB
(
y
);
A
.
updateStyleString
()}
else
{
A
.
__styleString
=
W
.
color
.
__styleString
}}}}
if
(
W
.
wireframe
){
if
(
f
!=
W
.
wireframe_linewidth
){
r
.
lineWidth
=
f
=
W
.
wireframe_linewidth
}
if
(
i
!=
A
.
__styleString
){
r
.
strokeStyle
=
i
=
A
.
__styleString
}
r
.
stroke
();
m
.
inflate
(
W
.
wireframe_linewidth
*
2
)}
else
{
if
(
L
!=
A
.
__styleString
){
r
.
fillStyle
=
L
=
A
.
__styleString
}
r
.
fill
()}}
function
c
(
af
,
Z
,
R
,
X
,
Q
,
V
,
O
,
W
,
P
,
U
,
N
,
T
,
M
){
r
.
beginPath
();
r
.
moveTo
(
Z
,
R
);
r
.
lineTo
(
X
,
Q
);
r
.
lineTo
(
V
,
O
);
r
.
lineTo
(
Z
,
R
);
r
.
closePath
();
X
-=
Z
;
Q
-=
R
;
V
-=
Z
;
O
-=
R
;
U
-=
W
;
N
-=
P
;
T
-=
W
;
M
-=
P
;
var
S
=
1
/
(
U
*
M
-
T
*
N
),
ae
=
(
M
*
X
-
N
*
V
)
*
S
,
ad
=
(
M
*
Q
-
N
*
O
)
*
S
,
ac
=
(
U
*
V
-
T
*
X
)
*
S
,
ab
=
(
U
*
O
-
T
*
Q
)
*
S
,
aa
=
Z
-
ae
*
W
-
ac
*
P
,
Y
=
R
-
ad
*
W
-
ab
*
P
;
r
.
save
();
r
.
transform
(
ae
,
ad
,
ac
,
ab
,
aa
,
Y
);
r
.
clip
();
r
.
drawImage
(
af
,
0
,
0
);
r
.
restore
()}
function
b
(
N
,
M
){
G
.
sub
(
M
,
N
);
G
.
unit
();
G
.
multiplyScalar
(
0.75
);
M
.
addSelf
(
G
);
N
.
subSelf
(
G
)}};
THREE
.
SVGRenderer
=
function
(){
var
y
=
null
,
r
=
new
THREE
.
Projector
(),
t
=
document
.
createElementNS
(
"
http://www.w3.org/2000/svg
"
,
"
svg
"
),
b
,
o
,
p
,
s
,
A
=
new
THREE
.
Rectangle
(),
w
=
new
THREE
.
Rectangle
(),
i
=
false
,
k
=
new
THREE
.
Color
(
4294967295
),
v
=
new
THREE
.
Color
(
4294967295
),
c
=
new
THREE
.
Color
(
4294967295
),
x
,
g
=
new
THREE
.
Vector3
(),
d
=
[],
l
=
[],
C
,
n
,
f
,
B
=
1
;
this
.
domElement
=
t
;
this
.
autoClear
=
true
;
this
.
setQuality
=
function
(
D
){
switch
(
D
){
case
"
high
"
:
B
=
1
;
break
;
case
"
low
"
:
B
=
0
;
break
}};
this
.
setSize
=
function
(
E
,
D
){
b
=
E
;
o
=
D
;
p
=
b
/
2
;
s
=
o
/
2
;
t
.
setAttribute
(
"
viewBox
"
,(
-
p
)
+
"
"
+
(
-
s
)
+
"
"
+
b
+
"
"
+
o
);
t
.
setAttribute
(
"
width
"
,
b
);
t
.
setAttribute
(
"
height
"
,
o
);
A
.
set
(
-
p
,
-
s
,
p
,
s
)};
this
.
clear
=
function
(){
while
(
t
.
childNodes
.
length
>
0
){
t
.
removeChild
(
t
.
childNodes
[
0
])}};
this
.
render
=
function
(
U
,
R
){
var
T
,
F
,
O
,
S
,
K
,
H
,
G
,
N
,
L
,
I
,
Q
,
P
,
E
,
D
,
M
,
J
;
if
(
this
.
autoClear
){
this
.
clear
()}
y
=
r
.
projectScene
(
U
,
R
);
n
=
0
;
f
=
0
;
i
=
U
.
lights
.
length
>
0
;
if
(
i
){
z
(
U
,
c
)}
for
(
T
=
0
,
F
=
y
.
length
;
T
<
F
;
T
++
){
G
=
y
[
T
];
w
.
empty
();
if
(
G
instanceof
THREE
.
RenderableParticle
){
L
=
G
.
x
*
p
;
I
=
G
.
y
*-
s
;
for
(
O
=
0
,
S
=
G
.
material
.
length
;
O
<
S
;
O
++
){
N
=
G
.
material
[
O
];
N
&&
j
(
L
,
I
,
G
,
N
,
U
)}}
else
{
if
(
G
instanceof
THREE
.
RenderableFace3
){
L
=
G
.
v1
.
x
*
p
;
I
=
G
.
v1
.
y
*-
s
;
Q
=
G
.
v2
.
x
*
p
;
P
=
G
.
v2
.
y
*-
s
;
E
=
G
.
v3
.
x
*
p
;
D
=
G
.
v3
.
y
*-
s
;
w
.
addPoint
(
L
,
I
);
w
.
addPoint
(
Q
,
P
);
w
.
addPoint
(
E
,
D
);
if
(
!
A
.
instersects
(
w
)){
continue
}
O
=
0
;
S
=
G
.
meshMaterial
.
length
;
while
(
O
<
S
){
N
=
G
.
meshMaterial
[
O
++
];
if
(
N
instanceof
THREE
.
MeshFaceMaterial
){
K
=
0
;
H
=
G
.
faceMaterial
.
length
;
while
(
K
<
H
){
N
=
G
.
faceMaterial
[
K
++
];
N
&&
h
(
L
,
I
,
Q
,
P
,
E
,
D
,
G
,
N
,
U
)}
continue
}
N
&&
h
(
L
,
I
,
Q
,
P
,
E
,
D
,
G
,
N
,
U
)}}
else
{
if
(
G
instanceof
THREE
.
RenderableFace4
){
L
=
G
.
v1
.
x
*
p
;
I
=
G
.
v1
.
y
*-
s
;
Q
=
G
.
v2
.
x
*
p
;
P
=
G
.
v2
.
y
*-
s
;
E
=
G
.
v3
.
x
*
p
;
D
=
G
.
v3
.
y
*-
s
;
M
=
G
.
v4
.
x
*
p
;
J
=
G
.
v4
.
y
*-
s
;
w
.
addPoint
(
L
,
I
);
w
.
addPoint
(
Q
,
P
);
w
.
addPoint
(
E
,
D
);
w
.
addPoint
(
M
,
J
);
if
(
!
A
.
instersects
(
w
)){
continue
}
O
=
0
;
S
=
G
.
meshMaterial
.
length
;
while
(
O
<
S
){
N
=
G
.
meshMaterial
[
O
++
];
if
(
N
instanceof
THREE
.
MeshFaceMaterial
){
K
=
0
;
H
=
G
.
faceMaterial
.
length
;
while
(
K
<
H
){
N
=
G
.
faceMaterial
[
K
++
];
N
&&
e
(
L
,
I
,
Q
,
P
,
E
,
D
,
M
,
J
,
G
,
N
,
U
)}
continue
}
N
&&
e
(
L
,
I
,
Q
,
P
,
E
,
D
,
M
,
J
,
G
,
N
,
U
)}}}}}};
function
z
(
H
,
F
){
var
E
,
G
,
D
;
F
.
setRGBA
(
0
,
0
,
0
,
1
);
for
(
E
=
0
,
G
=
H
.
lights
.
length
;
E
<
G
;
E
++
){
D
=
H
.
lights
[
E
];
if
(
D
instanceof
THREE
.
AmbientLight
){
F
.
r
+=
D
.
color
.
r
;
F
.
g
+=
D
.
color
.
g
;
F
.
b
+=
D
.
color
.
b
}}}
function
q
(
I
,
G
,
F
){
var
E
,
H
,
D
;
for
(
E
=
0
,
H
=
I
.
lights
.
length
;
E
<
H
;
E
++
){
D
=
I
.
lights
[
E
];
if
(
D
instanceof
THREE
.
DirectionalLight
){
F
.
r
+=
D
.
color
.
r
;
F
.
g
+=
D
.
color
.
g
;
F
.
b
+=
D
.
color
.
b
}
else
{
if
(
D
instanceof
THREE
.
PointLight
){
F
.
r
+=
D
.
color
.
r
;
F
.
g
+=
D
.
color
.
g
;
F
.
b
+=
D
.
color
.
b
}}}}
function
a
(
J
,
H
,
F
){
var
E
,
I
,
D
,
G
;
for
(
E
=
0
,
I
=
J
.
lights
.
length
;
E
<
I
;
E
++
){
D
=
J
.
lights
[
E
];
if
(
D
instanceof
THREE
.
DirectionalLight
){
G
=
H
.
normalWorld
.
dot
(
D
.
position
)
*
D
.
intensity
;
if
(
G
>
0
){
F
.
r
+=
D
.
color
.
r
*
G
;
F
.
g
+=
D
.
color
.
g
*
G
;
F
.
b
+=
D
.
color
.
b
*
G
}}
else
{
if
(
D
instanceof
THREE
.
PointLight
){
g
.
sub
(
D
.
position
,
H
.
centroidWorld
);
g
.
normalize
();
G
=
H
.
normalWorld
.
dot
(
g
)
*
D
.
intensity
;
if
(
G
>
0
){
F
.
r
+=
D
.
color
.
r
*
G
;
F
.
g
+=
D
.
color
.
g
*
G
;
F
.
b
+=
D
.
color
.
b
*
G
}}}}}
function
j
(
D
,
H
,
E
,
F
,
G
){
C
=
u
(
f
++
);
C
.
setAttribute
(
"
cx
"
,
D
);
C
.
setAttribute
(
"
cy
"
,
H
);
C
.
setAttribute
(
"
r
"
,
E
.
scale
.
x
*
p
);
if
(
F
instanceof
THREE
.
ParticleCircleMaterial
){
if
(
i
){
v
.
copyRGB
(
c
);
q
(
G
,
E
,
v
);
k
.
copyRGBA
(
F
.
color
);
k
.
multiplySelfRGB
(
v
);
k
.
updateStyleString
()}
else
{
k
=
F
.
color
}
C
.
setAttribute
(
"
style
"
,
"
fill:
"
+
k
.
__styleString
)}
t
.
appendChild
(
C
)}
function
h
(
F
,
E
,
D
,
L
,
K
,
J
,
G
,
I
,
H
){
C
=
m
(
n
++
);
C
.
setAttribute
(
"
d
"
,
"
M
"
+
F
+
"
"
+
E
+
"
L
"
+
D
+
"
"
+
L
+
"
L
"
+
K
+
"
,
"
+
J
+
"
z
"
);
if
(
I
instanceof
THREE
.
MeshBasicMaterial
){
k
.
__styleString
=
I
.
color
.
__styleString
}
else
{
if
(
I
instanceof
THREE
.
MeshDepthMaterial
){
x
=
1
-
(
I
.
__2near
/
(
I
.
__farPlusNear
-
G
.
z
*
I
.
__farMinusNear
));
k
.
setRGBA
(
x
,
x
,
x
,
1
)}
else
{
if
(
I
instanceof
THREE
.
MeshLambertMaterial
){
if
(
i
){
v
.
copyRGB
(
c
);
a
(
H
,
G
,
v
);
k
.
copyRGBA
(
I
.
color
);
k
.
multiplySelfRGB
(
v
);
k
.
updateStyleString
()}
else
{
k
.
__styleString
=
I
.
color
.
__styleString
}}}}
if
(
I
.
wireframe
){
C
.
setAttribute
(
"
style
"
,
"
fill: none; stroke:
"
+
k
.
__styleString
+
"
; stroke-width:
"
+
I
.
wireframe_linewidth
+
"
; stroke-opacity:
"
+
I
.
opacity
+
"
; stroke-linecap: round; stroke-linejoin: round
"
)}
else
{
C
.
setAttribute
(
"
style
"
,
"
fill:
"
+
k
.
__styleString
+
"
; fill-opacity:
"
+
I
.
opacity
)}
t
.
appendChild
(
C
)}
function
e
(
H
,
F
,
D
,
N
,
M
,
L
,
G
,
E
,
I
,
K
,
J
){
C
=
m
(
n
++
);
C
.
setAttribute
(
"
d
"
,
"
M
"
+
H
+
"
"
+
F
+
"
L
"
+
D
+
"
"
+
N
+
"
L
"
+
M
+
"
,
"
+
L
+
"
L
"
+
G
+
"
,
"
+
E
+
"
z
"
);
if
(
K
instanceof
THREE
.
MeshBasicMaterial
){
k
.
__styleString
=
K
.
color
.
__styleString
}
else
{
if
(
K
instanceof
THREE
.
MeshLambertMaterial
){
if
(
i
){
v
.
copyRGB
(
c
);
a
(
J
,
I
,
v
);
k
.
copyRGBA
(
K
.
color
);
k
.
multiplySelfRGB
(
v
);
k
.
updateStyleString
()}
else
{
k
.
__styleString
=
K
.
color
.
__styleString
}}}
if
(
K
.
wireframe
){
C
.
setAttribute
(
"
style
"
,
"
fill: none; stroke:
"
+
k
.
__styleString
+
"
; stroke-width:
"
+
K
.
wireframe_linewidth
+
"
; stroke-opacity:
"
+
K
.
opacity
+
"
; stroke-linecap: round; stroke-linejoin: round
"
)}
else
{
C
.
setAttribute
(
"
style
"
,
"
fill:
"
+
k
.
__styleString
+
"
; fill-opacity:
"
+
K
.
opacity
)}
t
.
appendChild
(
C
)}
function
m
(
D
){
if
(
d
[
D
]
==
null
){
d
[
D
]
=
document
.
createElementNS
(
"
http://www.w3.org/2000/svg
"
,
"
path
"
);
if
(
B
==
0
){
d
[
D
].
setAttribute
(
"
shape-rendering
"
,
"
crispEdges
"
)}
return
d
[
D
]}
return
d
[
D
]}
function
u
(
D
){
if
(
l
[
D
]
==
null
){
l
[
D
]
=
document
.
createElementNS
(
"
http://www.w3.org/2000/svg
"
,
"
circle
"
);
if
(
B
==
0
){
l
[
D
].
setAttribute
(
"
shape-rendering
"
,
"
crispEdges
"
)}
return
l
[
D
]}
return
l
[
D
]}};
THREE
.
WebGLRenderer
=
function
(
k
){
var
n
=
document
.
createElement
(
"
canvas
"
),
c
,
f
,
q
=
new
THREE
.
Matrix4
(),
m
,
a
=
0
,
p
=
1
,
j
=
2
,
d
=
3
,
e
=
l
(
k
,
5
);
this
.
domElement
=
n
;
this
.
autoClear
=
true
;
i
();
h
(
e
.
directional
,
e
.
point
);
function
l
(
v
,
w
){
if
(
v
){
var
s
,
u
,
r
,
t
=
pointLights
=
maxDirLights
=
maxPointLights
=
0
;
for
(
s
=
0
,
u
=
v
.
lights
.
length
;
s
<
u
;
s
++
){
r
=
v
.
lights
[
s
];
if
(
r
instanceof
THREE
.
DirectionalLight
){
t
++
}
if
(
r
instanceof
THREE
.
PointLight
){
pointLights
++
}}
if
((
pointLights
+
t
)
<=
w
){
maxDirLights
=
t
;
maxPointLights
=
pointLights
}
else
{
maxDirLights
=
Math
.
ceil
(
w
*
t
/
(
pointLights
+
t
));
maxPointLights
=
w
-
maxDirLights
}
return
{
directional
:
maxDirLights
,
point
:
maxPointLights
}}
return
{
directional
:
1
,
point
:
w
-
1
}}
this
.
setSize
=
function
(
s
,
r
){
n
.
width
=
s
;
n
.
height
=
r
;
c
.
viewport
(
0
,
0
,
n
.
width
,
n
.
height
)};
this
.
clear
=
function
(){
c
.
clear
(
c
.
COLOR_BUFFER_BIT
|
c
.
DEPTH_BUFFER_BIT
)};
this
.
setupLights
=
function
(
y
){
var
v
,
C
,
w
,
t
,
z
,
D
,
u
=
[],
A
=
[],
B
=
[],
s
=
[],
x
=
[];
c
.
uniform1i
(
f
.
enableLighting
,
y
.
lights
.
length
);
for
(
v
=
0
,
C
=
y
.
lights
.
length
;
v
<
C
;
v
++
){
w
=
y
.
lights
[
v
];
if
(
w
instanceof
THREE
.
AmbientLight
){
u
.
push
(
w
)}
else
{
if
(
w
instanceof
THREE
.
DirectionalLight
){
B
.
push
(
w
)}
else
{
if
(
w
instanceof
THREE
.
PointLight
){
A
.
push
(
w
)}}}}
t
=
z
=
D
=
0
;
for
(
v
=
0
,
C
=
u
.
length
;
v
<
C
;
v
++
){
t
+=
u
[
v
].
color
.
r
;
z
+=
u
[
v
].
color
.
g
;
D
+=
u
[
v
].
color
.
b
}
c
.
uniform3f
(
f
.
ambientLightColor
,
t
,
z
,
D
);
s
=
[];
x
=
[];
for
(
v
=
0
,
C
=
B
.
length
;
v
<
C
;
v
++
){
w
=
B
[
v
];
s
.
push
(
w
.
color
.
r
*
w
.
intensity
);
s
.
push
(
w
.
color
.
g
*
w
.
intensity
);
s
.
push
(
w
.
color
.
b
*
w
.
intensity
);
x
.
push
(
w
.
position
.
x
);
x
.
push
(
w
.
position
.
y
);
x
.
push
(
w
.
position
.
z
)}
if
(
B
.
length
){
c
.
uniform1i
(
f
.
directionalLightNumber
,
B
.
length
);
c
.
uniform3fv
(
f
.
directionalLightDirection
,
x
);
c
.
uniform3fv
(
f
.
directionalLightColor
,
s
)}
s
=
[];
x
=
[];
for
(
v
=
0
,
C
=
A
.
length
;
v
<
C
;
v
++
){
w
=
A
[
v
];
s
.
push
(
w
.
color
.
r
*
w
.
intensity
);
s
.
push
(
w
.
color
.
g
*
w
.
intensity
);
s
.
push
(
w
.
color
.
b
*
w
.
intensity
);
x
.
push
(
w
.
position
.
x
);
x
.
push
(
w
.
position
.
y
);
x
.
push
(
w
.
position
.
z
)}
if
(
A
.
length
){
c
.
uniform1i
(
f
.
pointLightNumber
,
A
.
length
);
c
.
uniform3fv
(
f
.
pointLightPosition
,
x
);
c
.
uniform3fv
(
f
.
pointLightColor
,
s
)}};
this
.
createBuffers
=
function
(
K
,
I
){
var
G
,
y
,
A
,
x
,
F
,
J
,
w
,
u
,
t
,
s
,
r
,
v
=
K
.
materialFaceGroup
[
I
],
C
=
[],
E
=
[],
B
=
[],
H
=
[],
D
=
[],
z
=
0
;
for
(
G
=
0
,
y
=
v
.
faces
.
length
;
G
<
y
;
G
++
){
A
=
v
.
faces
[
G
];
x
=
K
.
geometry
.
faces
[
A
];
F
=
x
.
vertexNormals
;
J
=
x
.
normal
;
w
=
K
.
geometry
.
uvs
[
A
];
if
(
x
instanceof
THREE
.
Face3
){
u
=
K
.
geometry
.
vertices
[
x
.
a
].
position
;
t
=
K
.
geometry
.
vertices
[
x
.
b
].
position
;
s
=
K
.
geometry
.
vertices
[
x
.
c
].
position
;
B
.
push
(
u
.
x
,
u
.
y
,
u
.
z
);
B
.
push
(
t
.
x
,
t
.
y
,
t
.
z
);
B
.
push
(
s
.
x
,
s
.
y
,
s
.
z
);
if
(
F
.
length
==
3
){
H
.
push
(
F
[
0
].
x
,
F
[
0
].
y
,
F
[
0
].
z
);
H
.
push
(
F
[
1
].
x
,
F
[
1
].
y
,
F
[
1
].
z
);
H
.
push
(
F
[
2
].
x
,
F
[
2
].
y
,
F
[
2
].
z
)}
else
{
H
.
push
(
J
.
x
,
J
.
y
,
J
.
z
);
H
.
push
(
J
.
x
,
J
.
y
,
J
.
z
);
H
.
push
(
J
.
x
,
J
.
y
,
J
.
z
)}
if
(
w
){
D
.
push
(
w
[
0
].
u
,
w
[
0
].
v
);
D
.
push
(
w
[
1
].
u
,
w
[
1
].
v
);
D
.
push
(
w
[
2
].
u
,
w
[
2
].
v
)}
C
.
push
(
z
,
z
+
1
,
z
+
2
);
E
.
push
(
z
,
z
+
1
);
E
.
push
(
z
,
z
+
2
);
E
.
push
(
z
+
1
,
z
+
2
);
z
+=
3
}
else
{
if
(
x
instanceof
THREE
.
Face4
){
u
=
K
.
geometry
.
vertices
[
x
.
a
].
position
;
t
=
K
.
geometry
.
vertices
[
x
.
b
].
position
;
s
=
K
.
geometry
.
vertices
[
x
.
c
].
position
;
r
=
K
.
geometry
.
vertices
[
x
.
d
].
position
;
B
.
push
(
u
.
x
,
u
.
y
,
u
.
z
);
B
.
push
(
t
.
x
,
t
.
y
,
t
.
z
);
B
.
push
(
s
.
x
,
s
.
y
,
s
.
z
);
B
.
push
(
r
.
x
,
r
.
y
,
r
.
z
);
if
(
F
.
length
==
4
){
H
.
push
(
F
[
0
].
x
,
F
[
0
].
y
,
F
[
0
].
z
);
H
.
push
(
F
[
1
].
x
,
F
[
1
].
y
,
F
[
1
].
z
);
H
.
push
(
F
[
2
].
x
,
F
[
2
].
y
,
F
[
2
].
z
);
H
.
push
(
F
[
3
].
x
,
F
[
3
].
y
,
F
[
3
].
z
)}
else
{
H
.
push
(
J
.
x
,
J
.
y
,
J
.
z
);
H
.
push
(
J
.
x
,
J
.
y
,
J
.
z
);
H
.
push
(
J
.
x
,
J
.
y
,
J
.
z
);
H
.
push
(
J
.
x
,
J
.
y
,
J
.
z
)}
if
(
w
){
D
.
push
(
w
[
0
].
u
,
w
[
0
].
v
);
D
.
push
(
w
[
1
].
u
,
w
[
1
].
v
);
D
.
push
(
w
[
2
].
u
,
w
[
2
].
v
);
D
.
push
(
w
[
3
].
u
,
w
[
3
].
v
)}
C
.
push
(
z
,
z
+
1
,
z
+
2
);
C
.
push
(
z
,
z
+
2
,
z
+
3
);
E
.
push
(
z
,
z
+
1
);
E
.
push
(
z
,
z
+
2
);
E
.
push
(
z
,
z
+
3
);
E
.
push
(
z
+
1
,
z
+
2
);
E
.
push
(
z
+
2
,
z
+
3
);
z
+=
4
}}}
if
(
!
B
.
length
){
return
}
v
.
__webGLVertexBuffer
=
c
.
createBuffer
();
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
v
.
__webGLVertexBuffer
);
c
.
bufferData
(
c
.
ARRAY_BUFFER
,
new
Float32Array
(
B
),
c
.
STATIC_DRAW
);
v
.
__webGLNormalBuffer
=
c
.
createBuffer
();
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
v
.
__webGLNormalBuffer
);
c
.
bufferData
(
c
.
ARRAY_BUFFER
,
new
Float32Array
(
H
),
c
.
STATIC_DRAW
);
v
.
__webGLUVBuffer
=
c
.
createBuffer
();
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
v
.
__webGLUVBuffer
);
c
.
bufferData
(
c
.
ARRAY_BUFFER
,
new
Float32Array
(
D
),
c
.
STATIC_DRAW
);
v
.
__webGLFaceBuffer
=
c
.
createBuffer
();
c
.
bindBuffer
(
c
.
ELEMENT_ARRAY_BUFFER
,
v
.
__webGLFaceBuffer
);
c
.
bufferData
(
c
.
ELEMENT_ARRAY_BUFFER
,
new
Uint16Array
(
C
),
c
.
STATIC_DRAW
);
v
.
__webGLLineBuffer
=
c
.
createBuffer
();
c
.
bindBuffer
(
c
.
ELEMENT_ARRAY_BUFFER
,
v
.
__webGLLineBuffer
);
c
.
bufferData
(
c
.
ELEMENT_ARRAY_BUFFER
,
new
Uint16Array
(
E
),
c
.
STATIC_DRAW
);
v
.
__webGLFaceCount
=
C
.
length
;
v
.
__webGLLineCount
=
E
.
length
};
this
.
renderBuffer
=
function
(
s
,
r
){
if
(
s
instanceof
THREE
.
MeshPhongMaterial
){
mAmbient
=
s
.
ambient
;
mDiffuse
=
s
.
diffuse
;
mSpecular
=
s
.
specular
;
c
.
uniform4f
(
f
.
mAmbient
,
mAmbient
.
r
,
mAmbient
.
g
,
mAmbient
.
b
,
s
.
opacity
);
c
.
uniform4f
(
f
.
mDiffuse
,
mDiffuse
.
r
,
mDiffuse
.
g
,
mDiffuse
.
b
,
s
.
opacity
);
c
.
uniform4f
(
f
.
mSpecular
,
mSpecular
.
r
,
mSpecular
.
g
,
mSpecular
.
b
,
s
.
opacity
);
c
.
uniform1f
(
f
.
mShininess
,
s
.
shininess
);
c
.
uniform1i
(
f
.
material
,
d
)}
else
{
if
(
s
instanceof
THREE
.
MeshColorFillMaterial
){
color
=
s
.
color
;
c
.
uniform4f
(
f
.
mColor
,
color
.
r
*
color
.
a
,
color
.
g
*
color
.
a
,
color
.
b
*
color
.
a
,
color
.
a
);
c
.
uniform1i
(
f
.
material
,
a
)}
else
{
if
(
s
instanceof
THREE
.
MeshColorStrokeMaterial
){
lineWidth
=
s
.
lineWidth
;
color
=
s
.
color
;
c
.
uniform4f
(
f
.
mColor
,
color
.
r
*
color
.
a
,
color
.
g
*
color
.
a
,
color
.
b
*
color
.
a
,
color
.
a
);
c
.
uniform1i
(
f
.
material
,
p
)}
else
{
if
(
s
instanceof
THREE
.
MeshBitmapMaterial
){
if
(
!
s
.
__webGLTexture
&&
s
.
loaded
){
s
.
__webGLTexture
=
c
.
createTexture
();
c
.
bindTexture
(
c
.
TEXTURE_2D
,
s
.
__webGLTexture
);
c
.
texImage2D
(
c
.
TEXTURE_2D
,
0
,
c
.
RGBA
,
c
.
RGBA
,
c
.
UNSIGNED_BYTE
,
s
.
bitmap
);
c
.
texParameteri
(
c
.
TEXTURE_2D
,
c
.
TEXTURE_MAG_FILTER
,
c
.
LINEAR
);
c
.
texParameteri
(
c
.
TEXTURE_2D
,
c
.
TEXTURE_MIN_FILTER
,
c
.
LINEAR_MIPMAP_LINEAR
);
c
.
generateMipmap
(
c
.
TEXTURE_2D
);
c
.
bindTexture
(
c
.
TEXTURE_2D
,
null
)}
c
.
activeTexture
(
c
.
TEXTURE0
);
c
.
bindTexture
(
c
.
TEXTURE_2D
,
s
.
__webGLTexture
);
c
.
uniform1i
(
f
.
tDiffuse
,
0
);
c
.
uniform1i
(
f
.
material
,
j
)}}}}
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
r
.
__webGLVertexBuffer
);
c
.
vertexAttribPointer
(
f
.
position
,
3
,
c
.
FLOAT
,
false
,
0
,
0
);
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
r
.
__webGLNormalBuffer
);
c
.
vertexAttribPointer
(
f
.
normal
,
3
,
c
.
FLOAT
,
false
,
0
,
0
);
if
(
s
instanceof
THREE
.
MeshBitmapMaterial
){
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
r
.
__webGLUVBuffer
);
c
.
enableVertexAttribArray
(
f
.
uv
);
c
.
vertexAttribPointer
(
f
.
uv
,
2
,
c
.
FLOAT
,
false
,
0
,
0
)}
else
{
c
.
disableVertexAttribArray
(
f
.
uv
)}
if
(
s
instanceof
THREE
.
MeshBitmapMaterial
||
s
instanceof
THREE
.
MeshColorFillMaterial
||
s
instanceof
THREE
.
MeshPhongMaterial
){
c
.
bindBuffer
(
c
.
ELEMENT_ARRAY_BUFFER
,
r
.
__webGLFaceBuffer
);
c
.
drawElements
(
c
.
TRIANGLES
,
r
.
__webGLFaceCount
,
c
.
UNSIGNED_SHORT
,
0
)}
else
{
if
(
s
instanceof
THREE
.
MeshColorStrokeMaterial
){
c
.
lineWidth
(
lineWidth
);
c
.
bindBuffer
(
c
.
ELEMENT_ARRAY_BUFFER
,
r
.
__webGLLineBuffer
);
c
.
drawElements
(
c
.
LINES
,
r
.
__webGLLineCount
,
c
.
UNSIGNED_SHORT
,
0
)}}};
this
.
renderMesh
=
function
(
t
,
w
){
var
v
,
s
,
r
,
u
,
z
,
x
,
y
,
A
;
for
(
z
in
t
.
materialFaceGroup
){
A
=
t
.
materialFaceGroup
[
z
];
if
(
!
A
.
__webGLVertexBuffer
){
this
.
createBuffers
(
t
,
z
)}
for
(
r
=
0
,
u
=
t
.
material
.
length
;
r
<
u
;
r
++
){
y
=
t
.
material
[
r
];
if
(
y
instanceof
THREE
.
MeshFaceMaterial
){
for
(
v
=
0
,
s
=
A
.
material
.
length
;
v
<
s
;
v
++
){
x
=
A
.
material
[
v
];
this
.
renderBuffer
(
x
,
A
)}}
else
{
x
=
y
;
this
.
renderBuffer
(
x
,
A
)}}}};
this
.
setupMatrices
=
function
(
r
,
s
){
r
.
autoUpdateMatrix
&&
r
.
updateMatrix
();
q
.
multiply
(
s
.
matrix
,
r
.
matrix
);
f
.
viewMatrixArray
=
new
Float32Array
(
s
.
matrix
.
flatten
());
f
.
modelViewMatrixArray
=
new
Float32Array
(
q
.
flatten
());
f
.
projectionMatrixArray
=
new
Float32Array
(
s
.
projectionMatrix
.
flatten
());
m
=
THREE
.
Matrix4
.
makeInvert3x3
(
q
).
transpose
();
f
.
normalMatrixArray
=
new
Float32Array
(
m
.
m
);
c
.
uniformMatrix4fv
(
f
.
viewMatrix
,
false
,
f
.
viewMatrixArray
);
c
.
uniformMatrix4fv
(
f
.
modelViewMatrix
,
false
,
f
.
modelViewMatrixArray
);
c
.
uniformMatrix4fv
(
f
.
projectionMatrix
,
false
,
f
.
projectionMatrixArray
);
c
.
uniformMatrix3fv
(
f
.
normalMatrix
,
false
,
f
.
normalMatrixArray
);
c
.
uniformMatrix4fv
(
f
.
objMatrix
,
false
,
new
Float32Array
(
r
.
matrix
.
flatten
()))};
this
.
render
=
function
(
u
,
t
){
var
v
,
s
,
r
;
if
(
this
.
autoClear
){
this
.
clear
()}
t
.
autoUpdateMatrix
&&
t
.
updateMatrix
();
c
.
uniform3f
(
f
.
cameraPosition
,
t
.
position
.
x
,
t
.
position
.
y
,
t
.
position
.
z
);
this
.
setupLights
(
u
);
for
(
v
=
0
,
s
=
u
.
objects
.
length
;
v
<
s
;
v
++
){
r
=
u
.
objects
[
v
];
this
.
setupMatrices
(
r
,
t
);
if
(
r
instanceof
THREE
.
Mesh
){
this
.
renderMesh
(
r
,
t
)}
else
{
if
(
r
instanceof
THREE
.
Line
){}
else
{
if
(
r
instanceof
THREE
.
Particle
){}}}}};
this
.
setFaceCulling
=
function
(
s
,
r
){
if
(
s
){
if
(
!
r
||
r
==
"
ccw
"
){
c
.
frontFace
(
c
.
CCW
)}
else
{
c
.
frontFace
(
c
.
CW
)}
if
(
s
==
"
back
"
){
c
.
cullFace
(
c
.
BACK
)}
else
{
if
(
s
==
"
front
"
){
c
.
cullFace
(
c
.
FRONT
)}
else
{
c
.
cullFace
(
c
.
FRONT_AND_BACK
)}}
c
.
enable
(
c
.
CULL_FACE
)}
else
{
c
.
disable
(
c
.
CULL_FACE
)}};
function
i
(){
try
{
c
=
n
.
getContext
(
"
experimental-webgl
"
,{
antialias
:
true
})}
catch
(
r
){}
if
(
!
c
){
alert
(
"
WebGL not supported
"
);
throw
"
cannot create webgl context
"
}
c
.
clearColor
(
0
,
0
,
0
,
1
);
c
.
clearDepth
(
1
);
c
.
enable
(
c
.
DEPTH_TEST
);
c
.
depthFunc
(
c
.
LEQUAL
);
c
.
frontFace
(
c
.
CCW
);
c
.
cullFace
(
c
.
BACK
);
c
.
enable
(
c
.
CULL_FACE
);
c
.
enable
(
c
.
BLEND
);
c
.
blendFunc
(
c
.
ONE
,
c
.
ONE_MINUS_SRC_ALPHA
);
c
.
clearColor
(
0
,
0
,
0
,
0
)}
function
o
(
r
,
s
){
var
t
=
[
"
#ifdef GL_ES
"
,
"
precision highp float;
"
,
"
#endif
"
,
r
?
"
#define MAX_DIR_LIGHTS
"
+
r
:
""
,
s
?
"
#define MAX_POINT_LIGHTS
"
+
s
:
""
,
"
uniform int material;
"
,
"
uniform sampler2D tDiffuse;
"
,
"
uniform vec4 mColor;
"
,
"
uniform vec4 mAmbient;
"
,
"
uniform vec4 mDiffuse;
"
,
"
uniform vec4 mSpecular;
"
,
"
uniform float mShininess;
"
,
"
uniform int pointLightNumber;
"
,
"
uniform int directionalLightNumber;
"
,
r
?
"
uniform mat4 viewMatrix;
"
:
""
,
r
?
"
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
"
:
""
,
"
varying vec3 vNormal;
"
,
"
varying vec2 vUv;
"
,
"
varying vec3 vLightWeighting;
"
,
s
?
"
varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];
"
:
""
,
"
varying vec3 vViewPosition;
"
,
"
void main() {
"
,
"
if ( material == 3 ) {
"
,
"
vec3 normal = normalize( vNormal );
"
,
"
vec3 viewPosition = normalize( vViewPosition );
"
,
s
?
"
vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
s
?
"
vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
s
?
"
for( int i = 0; i < pointLightNumber; i++ ) {
"
:
""
,
s
?
"
vec3 pointVector = normalize( vPointLightVector[ i ] );
"
:
""
,
s
?
"
vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );
"
:
""
,
s
?
"
float pointDotNormalHalf = dot( normal, pointHalfVector );
"
:
""
,
s
?
"
float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );
"
:
""
,
s
?
"
float pointSpecularWeight = 0.0;
"
:
""
,
s
?
"
if ( pointDotNormalHalf >= 0.0 )
"
:
""
,
s
?
"
pointSpecularWeight = pow( pointDotNormalHalf, mShininess );
"
:
""
,
s
?
"
pointDiffuse += mDiffuse * pointDiffuseWeight;
"
:
""
,
s
?
"
pointSpecular += mSpecular * pointSpecularWeight;
"
:
""
,
s
?
"
}
"
:
""
,
r
?
"
vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
r
?
"
vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
r
?
"
for( int i = 0; i < directionalLightNumber; i++ ) {
"
:
""
,
r
?
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
:
""
,
r
?
"
vec3 dirVector = normalize( lDirection.xyz );
"
:
""
,
r
?
"
vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );
"
:
""
,
r
?
"
float dirDotNormalHalf = dot( normal, dirHalfVector );
"
:
""
,
r
?
"
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
"
:
""
,
r
?
"
float dirSpecularWeight = 0.0;
"
:
""
,
r
?
"
if ( dirDotNormalHalf >= 0.0 )
"
:
""
,
r
?
"
dirSpecularWeight = pow( dirDotNormalHalf, mShininess );
"
:
""
,
r
?
"
dirDiffuse += mDiffuse * dirDiffuseWeight;
"
:
""
,
r
?
"
dirSpecular += mSpecular * dirSpecularWeight;
"
:
""
,
r
?
"
}
"
:
""
,
"
vec4 totalLight = mAmbient;
"
,
r
?
"
totalLight += dirDiffuse + dirSpecular;
"
:
""
,
s
?
"
totalLight += pointDiffuse + pointSpecular;
"
:
""
,
"
gl_FragColor = vec4( totalLight.xyz * vLightWeighting, 1.0 );
"
,
"
} else if ( material == 2 ) {
"
,
"
vec4 texelColor = texture2D( tDiffuse, vUv );
"
,
"
gl_FragColor = vec4( texelColor.rgb * vLightWeighting, texelColor.a );
"
,
"
} else if ( material == 1 ) {
"
,
"
gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );
"
,
"
} else {
"
,
"
gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );
"
,
"
}
"
,
"
}
"
];
return
t
.
join
(
"
\n
"
)}
function
g
(
r
,
s
){
var
t
=
[
r
?
"
#define MAX_DIR_LIGHTS
"
+
r
:
""
,
s
?
"
#define MAX_POINT_LIGHTS
"
+
s
:
""
,
"
attribute vec3 position;
"
,
"
attribute vec3 normal;
"
,
"
attribute vec2 uv;
"
,
"
uniform vec3 cameraPosition;
"
,
"
uniform bool enableLighting;
"
,
"
uniform int pointLightNumber;
"
,
"
uniform int directionalLightNumber;
"
,
"
uniform vec3 ambientLightColor;
"
,
r
?
"
uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
"
:
""
,
r
?
"
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
"
:
""
,
s
?
"
uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
"
:
""
,
s
?
"
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
"
:
""
,
"
uniform mat4 objMatrix;
"
,
"
uniform mat4 viewMatrix;
"
,
"
uniform mat4 modelViewMatrix;
"
,
"
uniform mat4 projectionMatrix;
"
,
"
uniform mat3 normalMatrix;
"
,
"
varying vec3 vNormal;
"
,
"
varying vec2 vUv;
"
,
"
varying vec3 vLightWeighting;
"
,
s
?
"
varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];
"
:
""
,
"
varying vec3 vViewPosition;
"
,
"
void main(void) {
"
,
"
vec4 mPosition = objMatrix * vec4( position, 1.0 );
"
,
"
vViewPosition = cameraPosition - mPosition.xyz;
"
,
"
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
"
vec3 transformedNormal = normalize( normalMatrix * normal );
"
,
"
if ( !enableLighting ) {
"
,
"
vLightWeighting = vec3( 1.0, 1.0, 1.0 );
"
,
"
} else {
"
,
"
vLightWeighting = ambientLightColor;
"
,
r
?
"
for( int i = 0; i < directionalLightNumber; i++ ) {
"
:
""
,
r
?
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
:
""
,
r
?
"
float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );
"
:
""
,
r
?
"
vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;
"
:
""
,
r
?
"
}
"
:
""
,
s
?
"
for( int i = 0; i < pointLightNumber; i++ ) {
"
:
""
,
s
?
"
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
"
:
""
,
s
?
"
vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );
"
:
""
,
s
?
"
float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );
"
:
""
,
s
?
"
vLightWeighting += pointLightColor[ i ] * pointLightWeighting;
"
:
""
,
s
?
"
}
"
:
""
,
"
}
"
,
"
vNormal = transformedNormal;
"
,
"
vUv = uv;
"
,
"
gl_Position = projectionMatrix * mvPosition;
"
,
"
}
"
];
return
t
.
join
(
"
\n
"
)}
function
h
(
r
,
s
){
f
=
c
.
createProgram
();
c
.
attachShader
(
f
,
b
(
"
fragment
"
,
o
(
r
,
s
)));
c
.
attachShader
(
f
,
b
(
"
vertex
"
,
g
(
r
,
s
)));
c
.
linkProgram
(
f
);
if
(
!
c
.
getProgramParameter
(
f
,
c
.
LINK_STATUS
)){
alert
(
"
Could not initialise shaders
"
)}
c
.
useProgram
(
f
);
f
.
viewMatrix
=
c
.
getUniformLocation
(
f
,
"
viewMatrix
"
);
f
.
modelViewMatrix
=
c
.
getUniformLocation
(
f
,
"
modelViewMatrix
"
);
f
.
projectionMatrix
=
c
.
getUniformLocation
(
f
,
"
projectionMatrix
"
);
f
.
normalMatrix
=
c
.
getUniformLocation
(
f
,
"
normalMatrix
"
);
f
.
objMatrix
=
c
.
getUniformLocation
(
f
,
"
objMatrix
"
);
f
.
cameraPosition
=
c
.
getUniformLocation
(
f
,
"
cameraPosition
"
);
f
.
enableLighting
=
c
.
getUniformLocation
(
f
,
"
enableLighting
"
);
f
.
ambientLightColor
=
c
.
getUniformLocation
(
f
,
"
ambientLightColor
"
);
if
(
r
){
f
.
directionalLightNumber
=
c
.
getUniformLocation
(
f
,
"
directionalLightNumber
"
);
f
.
directionalLightColor
=
c
.
getUniformLocation
(
f
,
"
directionalLightColor
"
);
f
.
directionalLightDirection
=
c
.
getUniformLocation
(
f
,
"
directionalLightDirection
"
)}
if
(
s
){
f
.
pointLightNumber
=
c
.
getUniformLocation
(
f
,
"
pointLightNumber
"
);
f
.
pointLightColor
=
c
.
getUniformLocation
(
f
,
"
pointLightColor
"
);
f
.
pointLightPosition
=
c
.
getUniformLocation
(
f
,
"
pointLightPosition
"
)}
f
.
material
=
c
.
getUniformLocation
(
f
,
"
material
"
);
f
.
mColor
=
c
.
getUniformLocation
(
f
,
"
mColor
"
);
f
.
mAmbient
=
c
.
getUniformLocation
(
f
,
"
mAmbient
"
);
f
.
mDiffuse
=
c
.
getUniformLocation
(
f
,
"
mDiffuse
"
);
f
.
mSpecular
=
c
.
getUniformLocation
(
f
,
"
mSpecular
"
);
f
.
mShininess
=
c
.
getUniformLocation
(
f
,
"
mShininess
"
);
f
.
tDiffuse
=
c
.
getUniformLocation
(
f
,
"
tDiffuse
"
);
c
.
uniform1i
(
f
.
tDiffuse
,
0
);
f
.
position
=
c
.
getAttribLocation
(
f
,
"
position
"
);
c
.
enableVertexAttribArray
(
f
.
position
);
f
.
normal
=
c
.
getAttribLocation
(
f
,
"
normal
"
);
c
.
enableVertexAttribArray
(
f
.
normal
);
f
.
uv
=
c
.
getAttribLocation
(
f
,
"
uv
"
);
c
.
enableVertexAttribArray
(
f
.
uv
);
f
.
viewMatrixArray
=
new
Float32Array
(
16
);
f
.
modelViewMatrixArray
=
new
Float32Array
(
16
);
f
.
projectionMatrixArray
=
new
Float32Array
(
16
)}
function
b
(
s
,
r
){
var
t
;
if
(
s
==
"
fragment
"
){
t
=
c
.
createShader
(
c
.
FRAGMENT_SHADER
)}
else
{
if
(
s
==
"
vertex
"
){
t
=
c
.
createShader
(
c
.
VERTEX_SHADER
)}}
c
.
shaderSource
(
t
,
r
);
c
.
compileShader
(
t
);
if
(
!
c
.
getShaderParameter
(
t
,
c
.
COMPILE_STATUS
)){
alert
(
c
.
getShaderInfoLog
(
t
));
return
null
}
return
t
}};
THREE
.
RenderableFace3
=
function
(){
this
.
v1
=
new
THREE
.
Vector2
();
this
.
v2
=
new
THREE
.
Vector2
();
this
.
v3
=
new
THREE
.
Vector2
();
this
.
centroidWorld
=
new
THREE
.
Vector3
();
this
.
centroidScreen
=
new
THREE
.
Vector3
();
this
.
normalWorld
=
new
THREE
.
Vector3
();
this
.
z
=
null
;
this
.
color
=
null
;
this
.
material
=
null
};
THREE
.
RenderableFace4
=
function
(){
this
.
v1
=
new
THREE
.
Vector2
();
this
.
v2
=
new
THREE
.
Vector2
();
this
.
v3
=
new
THREE
.
Vector2
();
this
.
v4
=
new
THREE
.
Vector2
();
this
.
centroidWorld
=
new
THREE
.
Vector3
();
this
.
centroidScreen
=
new
THREE
.
Vector3
();
this
.
normalWorld
=
new
THREE
.
Vector3
();
this
.
z
=
null
;
this
.
color
=
null
;
this
.
material
=
null
};
THREE
.
RenderableParticle
=
function
(){
this
.
x
=
null
;
this
.
y
=
null
;
this
.
z
=
null
;
this
.
rotation
=
null
;
this
.
scale
=
new
THREE
.
Vector2
();
this
.
color
=
null
;
this
.
material
=
null
};
THREE
.
RenderableLine
=
function
(){
this
.
v1
=
new
THREE
.
Vector2
();
this
.
v2
=
new
THREE
.
Vector2
();
this
.
z
=
null
;
this
.
color
=
null
;
this
.
material
=
null
};
\ No newline at end of file
build/ThreeDebug.js
浏览文件 @
aebe8986
// ThreeDebug.js r28 - http://github.com/mrdoob/three.js
var
THREE
=
THREE
||
{};
THREE
.
Color
=
function
(
a
){
this
.
autoUpdate
=
true
;
this
.
setHex
(
a
)};
THREE
.
Color
.
prototype
=
{
setRGBA
:
function
(
f
,
e
,
c
,
d
){
this
.
r
=
f
;
this
.
g
=
e
;
this
.
b
=
c
;
this
.
a
=
d
;
if
(
this
.
autoUpdate
){
this
.
updateHex
();
this
.
updateStyleString
()}},
setHex
:
function
(
a
){
this
.
hex
=
(
~~
a
).
toString
(
16
).
length
<
8
?
255
<<
24
^
a
:
a
;
if
(
this
.
autoUpdate
){
this
.
updateRGBA
();
this
.
updateStyleString
()}},
copyRGB
:
function
(
a
){
this
.
r
=
a
.
r
;
this
.
g
=
a
.
g
;
this
.
b
=
a
.
b
},
copyRGBA
:
function
(
a
){
this
.
r
=
a
.
r
;
this
.
g
=
a
.
g
;
this
.
b
=
a
.
b
;
this
.
a
=
a
.
a
},
multiplySelfRGB
:
function
(
a
){
this
.
r
*=
a
.
r
;
this
.
g
*=
a
.
g
;
this
.
b
*=
a
.
b
},
updateHex
:
function
(){
this
.
hex
=~~
(
this
.
a
*
255
)
<<
24
^~~
(
this
.
r
*
255
)
<<
16
^~~
(
this
.
g
*
255
)
<<
8
^~~
(
this
.
b
*
255
)},
updateRGBA
:
function
(){
this
.
a
=
(
this
.
hex
>>
24
&
255
)
/
255
;
this
.
r
=
(
this
.
hex
>>
16
&
255
)
/
255
;
this
.
g
=
(
this
.
hex
>>
8
&
255
)
/
255
;
this
.
b
=
(
this
.
hex
&
255
)
/
255
},
updateStyleString
:
function
(){
this
.
__styleString
=
"
rgba(
"
+~~
(
this
.
r
*
255
)
+
"
,
"
+~~
(
this
.
g
*
255
)
+
"
,
"
+~~
(
this
.
b
*
255
)
+
"
,
"
+
this
.
a
+
"
)
"
},
toString
:
function
(){
return
"
THREE.Color ( r:
"
+
this
.
r
+
"
, g:
"
+
this
.
g
+
"
, b:
"
+
this
.
b
+
"
, a:
"
+
this
.
a
+
"
, hex:
"
+
this
.
hex
+
"
)
"
}};
THREE
.
Vector2
=
function
(
a
,
b
){
this
.
x
=
a
||
0
;
this
.
y
=
b
||
0
};
THREE
.
Vector2
.
prototype
=
{
set
:
function
(
a
,
b
){
this
.
x
=
a
;
this
.
y
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
x
=
a
.
x
;
this
.
y
=
a
.
y
;
return
this
},
addSelf
:
function
(
a
){
this
.
x
+=
a
.
x
;
this
.
y
+=
a
.
y
;
return
this
},
add
:
function
(
b
,
a
){
this
.
x
=
b
.
x
+
a
.
x
;
this
.
y
=
b
.
y
+
a
.
y
;
return
this
},
subSelf
:
function
(
a
){
this
.
x
-=
a
.
x
;
this
.
y
-=
a
.
y
;
return
this
},
sub
:
function
(
b
,
a
){
this
.
x
=
b
.
x
-
a
.
x
;
this
.
y
=
b
.
y
-
a
.
y
;
return
this
},
multiplyScalar
:
function
(
a
){
this
.
x
*=
a
;
this
.
y
*=
a
;
return
this
},
unit
:
function
(){
this
.
multiplyScalar
(
1
/
this
.
length
());
return
this
},
length
:
function
(){
return
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
)},
lengthSq
:
function
(){
return
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
},
negate
:
function
(){
this
.
x
=-
this
.
x
;
this
.
y
=-
this
.
y
;
return
this
},
clone
:
function
(){
return
new
THREE
.
Vector2
(
this
.
x
,
this
.
y
)},
toString
:
function
(){
return
"
THREE.Vector2 (
"
+
this
.
x
+
"
,
"
+
this
.
y
+
"
)
"
}};
THREE
.
Vector3
=
function
(
a
,
c
,
b
){
this
.
x
=
a
||
0
;
this
.
y
=
c
||
0
;
this
.
z
=
b
||
0
};
THREE
.
Vector3
.
prototype
=
{
set
:
function
(
a
,
c
,
b
){
this
.
x
=
a
;
this
.
y
=
c
;
this
.
z
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
x
=
a
.
x
;
this
.
y
=
a
.
y
;
this
.
z
=
a
.
z
;
return
this
},
add
:
function
(
b
,
a
){
this
.
x
=
b
.
x
+
a
.
x
;
this
.
y
=
b
.
y
+
a
.
y
;
this
.
z
=
b
.
z
+
a
.
z
;
return
this
},
addSelf
:
function
(
a
){
this
.
x
+=
a
.
x
;
this
.
y
+=
a
.
y
;
this
.
z
+=
a
.
z
;
return
this
},
addScalar
:
function
(
a
){
this
.
x
+=
a
;
this
.
y
+=
a
;
this
.
z
+=
a
;
return
this
},
sub
:
function
(
b
,
a
){
this
.
x
=
b
.
x
-
a
.
x
;
this
.
y
=
b
.
y
-
a
.
y
;
this
.
z
=
b
.
z
-
a
.
z
;
return
this
},
subSelf
:
function
(
a
){
this
.
x
-=
a
.
x
;
this
.
y
-=
a
.
y
;
this
.
z
-=
a
.
z
;
return
this
},
cross
:
function
(
b
,
a
){
this
.
x
=
b
.
y
*
a
.
z
-
b
.
z
*
a
.
y
;
this
.
y
=
b
.
z
*
a
.
x
-
b
.
x
*
a
.
z
;
this
.
z
=
b
.
x
*
a
.
y
-
b
.
y
*
a
.
x
;
return
this
},
crossSelf
:
function
(
c
){
var
b
=
this
.
x
,
a
=
this
.
y
,
d
=
this
.
z
;
this
.
x
=
a
*
c
.
z
-
d
*
c
.
y
;
this
.
y
=
d
*
c
.
x
-
b
*
c
.
z
;
this
.
z
=
b
*
c
.
y
-
a
*
c
.
x
;
return
this
},
multiplySelf
:
function
(
a
){
this
.
x
*=
a
.
x
;
this
.
y
*=
a
.
y
;
this
.
z
*=
a
.
z
;
return
this
},
multiplyScalar
:
function
(
a
){
this
.
x
*=
a
;
this
.
y
*=
a
;
this
.
z
*=
a
;
return
this
},
divideScalar
:
function
(
a
){
this
.
x
/=
a
;
this
.
y
/=
a
;
this
.
z
/=
a
;
return
this
},
dot
:
function
(
a
){
return
this
.
x
*
a
.
x
+
this
.
y
*
a
.
y
+
this
.
z
*
a
.
z
},
distanceTo
:
function
(
a
){
return
Math
.
sqrt
(
this
.
distanceToSquared
(
a
))},
distanceToSquared
:
function
(
d
){
var
c
=
this
.
x
-
d
.
x
,
b
=
this
.
y
-
d
.
y
,
a
=
this
.
z
-
d
.
z
;
return
c
*
c
+
b
*
b
+
a
*
a
},
length
:
function
(){
return
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
)},
lengthSq
:
function
(){
return
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
},
negate
:
function
(){
this
.
x
=-
this
.
x
;
this
.
y
=-
this
.
y
;
this
.
z
=-
this
.
z
;
return
this
},
normalize
:
function
(){
if
(
this
.
length
()
>
0
){
this
.
multiplyScalar
(
1
/
this
.
length
())}
else
{
this
.
multiplyScalar
(
0
)}
return
this
},
setLength
:
function
(
a
){
return
this
.
normalize
().
multiplyScalar
(
a
)},
isZero
:
function
(){
var
a
=
0.0001
;
return
(
Math
.
abs
(
this
.
x
)
<
a
)
&&
(
Math
.
abs
(
this
.
y
)
<
a
)
&&
(
Math
.
abs
(
this
.
z
)
<
a
)},
clone
:
function
(){
return
new
THREE
.
Vector3
(
this
.
x
,
this
.
y
,
this
.
z
)},
toString
:
function
(){
return
"
THREE.Vector3 (
"
+
this
.
x
+
"
,
"
+
this
.
y
+
"
,
"
+
this
.
z
+
"
)
"
}};
THREE
.
Vector4
=
function
(
a
,
d
,
c
,
b
){
this
.
x
=
a
||
0
;
this
.
y
=
d
||
0
;
this
.
z
=
c
||
0
;
this
.
w
=
b
||
1
};
THREE
.
Vector4
.
prototype
=
{
set
:
function
(
a
,
d
,
c
,
b
){
this
.
x
=
a
;
this
.
y
=
d
;
this
.
z
=
c
;
this
.
w
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
x
=
a
.
x
;
this
.
y
=
a
.
y
;
this
.
z
=
a
.
z
;
this
.
w
=
a
.
w
;
return
this
},
add
:
function
(
b
,
a
){
this
.
x
=
b
.
x
+
a
.
x
;
this
.
y
=
b
.
y
+
a
.
y
;
this
.
z
=
b
.
z
+
a
.
z
;
this
.
w
=
b
.
w
+
a
.
w
;
return
this
},
addSelf
:
function
(
a
){
this
.
x
+=
a
.
x
;
this
.
y
+=
a
.
y
;
this
.
z
+=
a
.
z
;
this
.
w
+=
a
.
w
;
return
this
},
sub
:
function
(
b
,
a
){
this
.
x
=
b
.
x
-
a
.
x
;
this
.
y
=
b
.
y
-
a
.
y
;
this
.
z
=
b
.
z
-
a
.
z
;
this
.
w
=
b
.
w
-
a
.
w
;
return
this
},
subSelf
:
function
(
a
){
this
.
x
-=
a
.
x
;
this
.
y
-=
a
.
y
;
this
.
z
-=
a
.
z
;
this
.
w
-=
a
.
w
;
return
this
},
clone
:
function
(){
return
new
THREE
.
Vector4
(
this
.
x
,
this
.
y
,
this
.
z
,
this
.
w
)},
toString
:
function
(){
return
"
THREE.Vector4 (
"
+
this
.
x
+
"
,
"
+
this
.
y
+
"
,
"
+
this
.
z
+
"
,
"
+
this
.
w
+
"
)
"
}};
THREE
.
Ray
=
function
(
a
,
b
){
this
.
origin
=
a
||
new
THREE
.
Vector3
();
this
.
direction
=
b
||
new
THREE
.
Vector3
()};
THREE
.
Ray
.
prototype
=
{
intersectScene
:
function
(
f
){
var
c
,
a
,
b
,
e
=
f
.
objects
,
d
=
[];
for
(
c
=
0
,
a
=
e
.
length
;
c
<
a
;
c
++
){
b
=
e
[
c
];
if
(
b
instanceof
THREE
.
Mesh
){
d
=
d
.
concat
(
this
.
intersectObject
(
b
))}}
d
.
sort
(
function
(
h
,
g
){
return
h
.
distance
-
g
.
distance
});
return
d
},
intersectObject
:
function
(
w
){
var
n
,
j
,
i
,
t
,
s
,
q
,
p
,
v
,
k
,
x
,
u
,
r
,
g
=
w
.
geometry
,
h
=
g
.
vertices
,
o
,
e
=
[],
m
;
for
(
n
=
0
,
j
=
g
.
faces
.
length
;
n
<
j
;
n
++
){
i
=
g
.
faces
[
n
];
u
=
this
.
origin
.
clone
();
r
=
this
.
direction
.
clone
();
t
=
w
.
matrix
.
transform
(
h
[
i
.
a
].
position
.
clone
());
s
=
w
.
matrix
.
transform
(
h
[
i
.
b
].
position
.
clone
());
q
=
w
.
matrix
.
transform
(
h
[
i
.
c
].
position
.
clone
());
p
=
i
instanceof
THREE
.
Face4
?
w
.
matrix
.
transform
(
h
[
i
.
d
].
position
.
clone
()):
null
;
v
=
w
.
matrixRotation
.
transform
(
i
.
normal
.
clone
());
k
=
r
.
dot
(
v
);
if
(
k
<
0
){
x
=
v
.
dot
(
new
THREE
.
Vector3
().
sub
(
t
,
u
))
/
k
;
m
=
u
.
addSelf
(
r
.
multiplyScalar
(
x
));
if
(
i
instanceof
THREE
.
Face3
){
if
(
l
(
m
,
t
,
s
,
q
)){
o
=
{
distance
:
this
.
origin
.
distanceTo
(
m
),
point
:
m
,
face
:
i
,
object
:
w
};
e
.
push
(
o
)}}
else
{
if
(
i
instanceof
THREE
.
Face4
){
if
(
l
(
m
,
t
,
s
,
p
)
||
l
(
m
,
s
,
q
,
p
)){
o
=
{
distance
:
this
.
origin
.
distanceTo
(
m
),
point
:
m
,
face
:
i
,
object
:
w
};
e
.
push
(
o
)}}}}}
return
e
;
function
l
(
d
,
G
,
D
,
B
){
var
J
=
B
.
clone
().
subSelf
(
G
),
H
=
D
.
clone
().
subSelf
(
G
),
E
=
d
.
clone
().
subSelf
(
G
),
F
=
J
.
dot
(
J
),
C
=
J
.
dot
(
H
),
A
=
J
.
dot
(
E
),
z
=
H
.
dot
(
H
),
f
=
H
.
dot
(
E
),
y
=
1
/
(
F
*
z
-
C
*
C
),
K
=
(
z
*
A
-
C
*
f
)
*
y
,
I
=
(
F
*
f
-
C
*
A
)
*
y
;
return
(
K
>
0
)
&&
(
I
>
0
)
&&
(
K
+
I
<
1
)}}};
THREE
.
Rectangle
=
function
(){
var
e
,
g
,
h
,
d
,
a
,
c
,
f
=
true
;
function
b
(){
a
=
h
-
e
;
c
=
d
-
g
}
this
.
getX
=
function
(){
return
e
};
this
.
getY
=
function
(){
return
g
};
this
.
getWidth
=
function
(){
return
a
};
this
.
getHeight
=
function
(){
return
c
};
this
.
getLeft
=
function
(){
return
e
};
this
.
getTop
=
function
(){
return
g
};
this
.
getRight
=
function
(){
return
h
};
this
.
getBottom
=
function
(){
return
d
};
this
.
set
=
function
(
l
,
k
,
j
,
i
){
f
=
false
;
e
=
l
;
g
=
k
;
h
=
j
;
d
=
i
;
b
()};
this
.
addPoint
=
function
(
i
,
j
){
if
(
f
){
f
=
false
;
e
=
i
;
g
=
j
;
h
=
i
;
d
=
j
}
else
{
e
=
Math
.
min
(
e
,
i
);
g
=
Math
.
min
(
g
,
j
);
h
=
Math
.
max
(
h
,
i
);
d
=
Math
.
max
(
d
,
j
)}
b
()};
this
.
addRectangle
=
function
(
i
){
if
(
f
){
f
=
false
;
e
=
i
.
getLeft
();
g
=
i
.
getTop
();
h
=
i
.
getRight
();
d
=
i
.
getBottom
()}
else
{
e
=
Math
.
min
(
e
,
i
.
getLeft
());
g
=
Math
.
min
(
g
,
i
.
getTop
());
h
=
Math
.
max
(
h
,
i
.
getRight
());
d
=
Math
.
max
(
d
,
i
.
getBottom
())}
b
()};
this
.
inflate
=
function
(
i
){
e
-=
i
;
g
-=
i
;
h
+=
i
;
d
+=
i
;
b
()};
this
.
minSelf
=
function
(
i
){
e
=
Math
.
max
(
e
,
i
.
getLeft
());
g
=
Math
.
max
(
g
,
i
.
getTop
());
h
=
Math
.
min
(
h
,
i
.
getRight
());
d
=
Math
.
min
(
d
,
i
.
getBottom
());
b
()};
this
.
instersects
=
function
(
i
){
return
Math
.
min
(
h
,
i
.
getRight
())
-
Math
.
max
(
e
,
i
.
getLeft
())
>=
0
&&
Math
.
min
(
d
,
i
.
getBottom
())
-
Math
.
max
(
g
,
i
.
getTop
())
>=
0
};
this
.
empty
=
function
(){
f
=
true
;
e
=
0
;
g
=
0
;
h
=
0
;
d
=
0
;
b
()};
this
.
isEmpty
=
function
(){
return
f
};
this
.
toString
=
function
(){
return
"
THREE.Rectangle ( left:
"
+
e
+
"
, right:
"
+
h
+
"
, top:
"
+
g
+
"
, bottom:
"
+
d
+
"
, width:
"
+
a
+
"
, height:
"
+
c
+
"
)
"
}};
THREE
.
Matrix3
=
function
(){
this
.
m
=
[]};
THREE
.
Matrix3
.
prototype
=
{
transpose
:
function
(){
var
a
;
a
=
this
.
m
[
1
];
this
.
m
[
1
]
=
this
.
m
[
3
];
this
.
m
[
3
]
=
a
;
a
=
this
.
m
[
2
];
this
.
m
[
2
]
=
this
.
m
[
6
];
this
.
m
[
6
]
=
a
;
a
=
this
.
m
[
5
];
this
.
m
[
5
]
=
this
.
m
[
7
];
this
.
m
[
7
]
=
a
;
return
this
}};
THREE
.
Matrix4
=
function
(){
this
.
_x
=
new
THREE
.
Vector3
();
this
.
_y
=
new
THREE
.
Vector3
();
this
.
_z
=
new
THREE
.
Vector3
()};
THREE
.
Matrix4
.
prototype
=
{
n11
:
1
,
n12
:
0
,
n13
:
0
,
n14
:
0
,
n21
:
0
,
n22
:
1
,
n23
:
0
,
n24
:
0
,
n31
:
0
,
n32
:
0
,
n33
:
1
,
n34
:
0
,
n41
:
0
,
n42
:
0
,
n43
:
0
,
n44
:
1
,
identity
:
function
(){
this
.
n11
=
1
;
this
.
n12
=
0
;
this
.
n13
=
0
;
this
.
n14
=
0
;
this
.
n21
=
0
;
this
.
n22
=
1
;
this
.
n23
=
0
;
this
.
n24
=
0
;
this
.
n31
=
0
;
this
.
n32
=
0
;
this
.
n33
=
1
;
this
.
n34
=
0
;
this
.
n41
=
0
;
this
.
n42
=
0
;
this
.
n43
=
0
;
this
.
n44
=
1
},
copy
:
function
(
a
){
this
.
n11
=
a
.
n11
;
this
.
n12
=
a
.
n12
;
this
.
n13
=
a
.
n13
;
this
.
n14
=
a
.
n14
;
this
.
n21
=
a
.
n21
;
this
.
n22
=
a
.
n22
;
this
.
n23
=
a
.
n23
;
this
.
n24
=
a
.
n24
;
this
.
n31
=
a
.
n31
;
this
.
n32
=
a
.
n32
;
this
.
n33
=
a
.
n33
;
this
.
n34
=
a
.
n34
;
this
.
n41
=
a
.
n41
;
this
.
n42
=
a
.
n42
;
this
.
n43
=
a
.
n43
;
this
.
n44
=
a
.
n44
},
lookAt
:
function
(
d
,
c
,
b
){
var
a
=
this
.
_x
,
f
=
this
.
_y
,
e
=
this
.
_z
;
e
.
sub
(
d
,
c
);
e
.
normalize
();
a
.
cross
(
b
,
e
);
a
.
normalize
();
f
.
cross
(
e
,
a
);
f
.
normalize
();
this
.
n11
=
a
.
x
;
this
.
n12
=
a
.
y
;
this
.
n13
=
a
.
z
;
this
.
n14
=-
a
.
dot
(
d
);
this
.
n21
=
f
.
x
;
this
.
n22
=
f
.
y
;
this
.
n23
=
f
.
z
;
this
.
n24
=-
f
.
dot
(
d
);
this
.
n31
=
e
.
x
;
this
.
n32
=
e
.
y
;
this
.
n33
=
e
.
z
;
this
.
n34
=-
e
.
dot
(
d
);
this
.
n41
=
0
;
this
.
n42
=
0
;
this
.
n43
=
0
;
this
.
n44
=
1
},
transform
:
function
(
a
){
var
d
=
a
.
x
,
c
=
a
.
y
,
b
=
a
.
z
,
e
=
a
.
w
?
a
.
w
:
1
;
a
.
x
=
this
.
n11
*
d
+
this
.
n12
*
c
+
this
.
n13
*
b
+
this
.
n14
*
e
;
a
.
y
=
this
.
n21
*
d
+
this
.
n22
*
c
+
this
.
n23
*
b
+
this
.
n24
*
e
;
a
.
z
=
this
.
n31
*
d
+
this
.
n32
*
c
+
this
.
n33
*
b
+
this
.
n34
*
e
;
e
=
this
.
n41
*
d
+
this
.
n42
*
c
+
this
.
n43
*
b
+
this
.
n44
*
e
;
if
(
a
.
w
){
a
.
w
=
e
}
else
{
a
.
x
=
a
.
x
/
e
;
a
.
y
=
a
.
y
/
e
;
a
.
z
=
a
.
z
/
e
}
return
a
},
crossVector
:
function
(
b
){
var
c
=
new
THREE
.
Vector4
();
c
.
x
=
this
.
n11
*
b
.
x
+
this
.
n12
*
b
.
y
+
this
.
n13
*
b
.
z
+
this
.
n14
*
b
.
w
;
c
.
y
=
this
.
n21
*
b
.
x
+
this
.
n22
*
b
.
y
+
this
.
n23
*
b
.
z
+
this
.
n24
*
b
.
w
;
c
.
z
=
this
.
n31
*
b
.
x
+
this
.
n32
*
b
.
y
+
this
.
n33
*
b
.
z
+
this
.
n34
*
b
.
w
;
c
.
w
=
(
b
.
w
)?
this
.
n41
*
b
.
x
+
this
.
n42
*
b
.
y
+
this
.
n43
*
b
.
z
+
this
.
n44
*
b
.
w
:
1
;
return
c
},
multiply
:
function
(
d
,
c
){
this
.
n11
=
d
.
n11
*
c
.
n11
+
d
.
n12
*
c
.
n21
+
d
.
n13
*
c
.
n31
+
d
.
n14
*
c
.
n41
;
this
.
n12
=
d
.
n11
*
c
.
n12
+
d
.
n12
*
c
.
n22
+
d
.
n13
*
c
.
n32
+
d
.
n14
*
c
.
n42
;
this
.
n13
=
d
.
n11
*
c
.
n13
+
d
.
n12
*
c
.
n23
+
d
.
n13
*
c
.
n33
+
d
.
n14
*
c
.
n43
;
this
.
n14
=
d
.
n11
*
c
.
n14
+
d
.
n12
*
c
.
n24
+
d
.
n13
*
c
.
n34
+
d
.
n14
*
c
.
n44
;
this
.
n21
=
d
.
n21
*
c
.
n11
+
d
.
n22
*
c
.
n21
+
d
.
n23
*
c
.
n31
+
d
.
n24
*
c
.
n41
;
this
.
n22
=
d
.
n21
*
c
.
n12
+
d
.
n22
*
c
.
n22
+
d
.
n23
*
c
.
n32
+
d
.
n24
*
c
.
n42
;
this
.
n23
=
d
.
n21
*
c
.
n13
+
d
.
n22
*
c
.
n23
+
d
.
n23
*
c
.
n33
+
d
.
n24
*
c
.
n43
;
this
.
n24
=
d
.
n21
*
c
.
n14
+
d
.
n22
*
c
.
n24
+
d
.
n23
*
c
.
n34
+
d
.
n24
*
c
.
n44
;
this
.
n31
=
d
.
n31
*
c
.
n11
+
d
.
n32
*
c
.
n21
+
d
.
n33
*
c
.
n31
+
d
.
n34
*
c
.
n41
;
this
.
n32
=
d
.
n31
*
c
.
n12
+
d
.
n32
*
c
.
n22
+
d
.
n33
*
c
.
n32
+
d
.
n34
*
c
.
n42
;
this
.
n33
=
d
.
n31
*
c
.
n13
+
d
.
n32
*
c
.
n23
+
d
.
n33
*
c
.
n33
+
d
.
n34
*
c
.
n43
;
this
.
n34
=
d
.
n31
*
c
.
n14
+
d
.
n32
*
c
.
n24
+
d
.
n33
*
c
.
n34
+
d
.
n34
*
c
.
n44
;
this
.
n41
=
d
.
n41
*
c
.
n11
+
d
.
n42
*
c
.
n21
+
d
.
n43
*
c
.
n31
+
d
.
n44
*
c
.
n41
;
this
.
n42
=
d
.
n41
*
c
.
n12
+
d
.
n42
*
c
.
n22
+
d
.
n43
*
c
.
n32
+
d
.
n44
*
c
.
n42
;
this
.
n43
=
d
.
n41
*
c
.
n13
+
d
.
n42
*
c
.
n23
+
d
.
n43
*
c
.
n33
+
d
.
n44
*
c
.
n43
;
this
.
n44
=
d
.
n41
*
c
.
n14
+
d
.
n42
*
c
.
n24
+
d
.
n43
*
c
.
n34
+
d
.
n44
*
c
.
n44
},
multiplySelf
:
function
(
c
){
var
o
=
this
.
n11
,
n
=
this
.
n12
,
k
=
this
.
n13
,
i
=
this
.
n14
,
f
=
this
.
n21
,
e
=
this
.
n22
,
d
=
this
.
n23
,
b
=
this
.
n24
,
a
=
this
.
n31
,
r
=
this
.
n32
,
q
=
this
.
n33
,
p
=
this
.
n34
,
l
=
this
.
n41
,
j
=
this
.
n42
,
h
=
this
.
n43
,
g
=
this
.
n44
;
this
.
n11
=
o
*
c
.
n11
+
n
*
c
.
n21
+
k
*
c
.
n31
+
i
*
c
.
n41
;
this
.
n12
=
o
*
c
.
n12
+
n
*
c
.
n22
+
k
*
c
.
n32
+
i
*
c
.
n42
;
this
.
n13
=
o
*
c
.
n13
+
n
*
c
.
n23
+
k
*
c
.
n33
+
i
*
c
.
n43
;
this
.
n14
=
o
*
c
.
n14
+
n
*
c
.
n24
+
k
*
c
.
n34
+
i
*
c
.
n44
;
this
.
n21
=
f
*
c
.
n11
+
e
*
c
.
n21
+
d
*
c
.
n31
+
b
*
c
.
n41
;
this
.
n22
=
f
*
c
.
n12
+
e
*
c
.
n22
+
d
*
c
.
n32
+
b
*
c
.
n42
;
this
.
n23
=
f
*
c
.
n13
+
e
*
c
.
n23
+
d
*
c
.
n33
+
b
*
c
.
n43
;
this
.
n24
=
f
*
c
.
n14
+
e
*
c
.
n24
+
d
*
c
.
n34
+
b
*
c
.
n44
;
this
.
n31
=
a
*
c
.
n11
+
r
*
c
.
n21
+
q
*
c
.
n31
+
p
*
c
.
n41
;
this
.
n32
=
a
*
c
.
n12
+
r
*
c
.
n22
+
q
*
c
.
n32
+
p
*
c
.
n42
;
this
.
n33
=
a
*
c
.
n13
+
r
*
c
.
n23
+
q
*
c
.
n33
+
p
*
c
.
n43
;
this
.
n34
=
a
*
c
.
n14
+
r
*
c
.
n24
+
q
*
c
.
n34
+
p
*
c
.
n44
;
this
.
n41
=
l
*
c
.
n11
+
j
*
c
.
n21
+
h
*
c
.
n31
+
g
*
c
.
n41
;
this
.
n42
=
l
*
c
.
n12
+
j
*
c
.
n22
+
h
*
c
.
n32
+
g
*
c
.
n42
;
this
.
n43
=
l
*
c
.
n13
+
j
*
c
.
n23
+
h
*
c
.
n33
+
g
*
c
.
n43
;
this
.
n44
=
l
*
c
.
n14
+
j
*
c
.
n24
+
h
*
c
.
n34
+
g
*
c
.
n44
},
multiplyScalar
:
function
(
a
){
this
.
n11
*=
a
;
this
.
n12
*=
a
;
this
.
n13
*=
a
;
this
.
n14
*=
a
;
this
.
n21
*=
a
;
this
.
n22
*=
a
;
this
.
n23
*=
a
;
this
.
n24
*=
a
;
this
.
n31
*=
a
;
this
.
n32
*=
a
;
this
.
n33
*=
a
;
this
.
n34
*=
a
;
this
.
n41
*=
a
;
this
.
n42
*=
a
;
this
.
n43
*=
a
;
this
.
n44
*=
a
},
determinant
:
function
(){
return
(
this
.
n14
*
this
.
n23
*
this
.
n32
*
this
.
n41
-
this
.
n13
*
this
.
n24
*
this
.
n32
*
this
.
n41
-
this
.
n14
*
this
.
n22
*
this
.
n33
*
this
.
n41
+
this
.
n12
*
this
.
n24
*
this
.
n33
*
this
.
n41
+
this
.
n13
*
this
.
n22
*
this
.
n34
*
this
.
n41
-
this
.
n12
*
this
.
n23
*
this
.
n34
*
this
.
n41
-
this
.
n14
*
this
.
n23
*
this
.
n31
*
this
.
n42
+
this
.
n13
*
this
.
n24
*
this
.
n31
*
this
.
n42
+
this
.
n14
*
this
.
n21
*
this
.
n33
*
this
.
n42
-
this
.
n11
*
this
.
n24
*
this
.
n33
*
this
.
n42
-
this
.
n13
*
this
.
n21
*
this
.
n34
*
this
.
n42
+
this
.
n11
*
this
.
n23
*
this
.
n34
*
this
.
n42
+
this
.
n14
*
this
.
n22
*
this
.
n31
*
this
.
n43
-
this
.
n12
*
this
.
n24
*
this
.
n31
*
this
.
n43
-
this
.
n14
*
this
.
n21
*
this
.
n32
*
this
.
n43
+
this
.
n11
*
this
.
n24
*
this
.
n32
*
this
.
n43
+
this
.
n12
*
this
.
n21
*
this
.
n34
*
this
.
n43
-
this
.
n11
*
this
.
n22
*
this
.
n34
*
this
.
n43
-
this
.
n13
*
this
.
n22
*
this
.
n31
*
this
.
n44
+
this
.
n12
*
this
.
n23
*
this
.
n31
*
this
.
n44
+
this
.
n13
*
this
.
n21
*
this
.
n32
*
this
.
n44
-
this
.
n11
*
this
.
n23
*
this
.
n32
*
this
.
n44
-
this
.
n12
*
this
.
n21
*
this
.
n33
*
this
.
n44
+
this
.
n11
*
this
.
n22
*
this
.
n33
*
this
.
n44
)},
transpose
:
function
(){
function
a
(
d
,
e
,
c
){
var
b
=
d
[
e
];
d
[
e
]
=
d
[
c
];
d
[
c
]
=
b
}
a
(
this
,
"
n21
"
,
"
n12
"
);
a
(
this
,
"
n31
"
,
"
n13
"
);
a
(
this
,
"
n32
"
,
"
n23
"
);
a
(
this
,
"
n41
"
,
"
n14
"
);
a
(
this
,
"
n42
"
,
"
n24
"
);
a
(
this
,
"
n43
"
,
"
n34
"
);
return
this
},
clone
:
function
(){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
this
.
n11
;
a
.
n12
=
this
.
n12
;
a
.
n13
=
this
.
n13
;
a
.
n14
=
this
.
n14
;
a
.
n21
=
this
.
n21
;
a
.
n22
=
this
.
n22
;
a
.
n23
=
this
.
n23
;
a
.
n24
=
this
.
n24
;
a
.
n31
=
this
.
n31
;
a
.
n32
=
this
.
n32
;
a
.
n33
=
this
.
n33
;
a
.
n34
=
this
.
n34
;
a
.
n41
=
this
.
n41
;
a
.
n42
=
this
.
n42
;
a
.
n43
=
this
.
n43
;
a
.
n44
=
this
.
n44
;
return
a
},
flatten
:
function
(){
return
[
this
.
n11
,
this
.
n21
,
this
.
n31
,
this
.
n41
,
this
.
n12
,
this
.
n22
,
this
.
n32
,
this
.
n42
,
this
.
n13
,
this
.
n23
,
this
.
n33
,
this
.
n43
,
this
.
n14
,
this
.
n24
,
this
.
n34
,
this
.
n44
]},
toString
:
function
(){
return
"
|
"
+
this
.
n11
+
"
"
+
this
.
n12
+
"
"
+
this
.
n13
+
"
"
+
this
.
n14
+
"
|
\n
|
"
+
this
.
n21
+
"
"
+
this
.
n22
+
"
"
+
this
.
n23
+
"
"
+
this
.
n24
+
"
|
\n
|
"
+
this
.
n31
+
"
"
+
this
.
n32
+
"
"
+
this
.
n33
+
"
"
+
this
.
n34
+
"
|
\n
|
"
+
this
.
n41
+
"
"
+
this
.
n42
+
"
"
+
this
.
n43
+
"
"
+
this
.
n44
+
"
|
"
}};
THREE
.
Matrix4
.
translationMatrix
=
function
(
b
,
d
,
c
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n14
=
b
;
a
.
n24
=
d
;
a
.
n34
=
c
;
return
a
};
THREE
.
Matrix4
.
scaleMatrix
=
function
(
b
,
d
,
c
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
b
;
a
.
n22
=
d
;
a
.
n33
=
c
;
return
a
};
THREE
.
Matrix4
.
rotationXMatrix
=
function
(
b
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n22
=
a
.
n33
=
Math
.
cos
(
b
);
a
.
n32
=
Math
.
sin
(
b
);
a
.
n23
=-
a
.
n32
;
return
a
};
THREE
.
Matrix4
.
rotationYMatrix
=
function
(
b
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
a
.
n33
=
Math
.
cos
(
b
);
a
.
n13
=
Math
.
sin
(
b
);
a
.
n31
=-
a
.
n13
;
return
a
};
THREE
.
Matrix4
.
rotationZMatrix
=
function
(
b
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
a
.
n22
=
Math
.
cos
(
b
);
a
.
n21
=
Math
.
sin
(
b
);
a
.
n12
=-
a
.
n21
;
return
a
};
THREE
.
Matrix4
.
rotationAxisAngleMatrix
=
function
(
b
,
d
){
var
a
=
new
THREE
.
Matrix4
(),
f
=
Math
.
cos
(
d
),
j
=
Math
.
sin
(
d
),
i
=
1
-
f
,
h
=
b
.
x
,
g
=
b
.
y
,
e
=
b
.
z
;
a
.
n11
=
i
*
h
*
h
+
f
;
a
.
n12
=
i
*
h
*
g
-
j
*
e
;
a
.
n13
=
i
*
h
*
e
+
j
*
g
;
a
.
n21
=
i
*
h
*
g
+
j
*
e
;
a
.
n22
=
i
*
g
*
g
+
f
;
a
.
n23
=
i
*
g
*
e
-
j
*
h
;
a
.
n31
=
i
*
h
*
e
-
j
*
g
;
a
.
n32
=
i
*
g
*
e
+
j
*
h
;
a
.
n33
=
i
*
e
*
e
+
f
;
return
a
};
THREE
.
Matrix4
.
makeInvert
=
function
(
b
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
b
.
n23
*
b
.
n34
*
b
.
n42
-
b
.
n24
*
b
.
n33
*
b
.
n42
+
b
.
n24
*
b
.
n32
*
b
.
n43
-
b
.
n22
*
b
.
n34
*
b
.
n43
-
b
.
n23
*
b
.
n32
*
b
.
n44
+
b
.
n22
*
b
.
n33
*
b
.
n44
;
a
.
n12
=
b
.
n14
*
b
.
n33
*
b
.
n42
-
b
.
n13
*
b
.
n34
*
b
.
n42
-
b
.
n14
*
b
.
n32
*
b
.
n43
+
b
.
n12
*
b
.
n34
*
b
.
n43
+
b
.
n13
*
b
.
n32
*
b
.
n44
-
b
.
n12
*
b
.
n33
*
b
.
n44
;
a
.
n13
=
b
.
n13
*
b
.
n24
*
b
.
n42
-
b
.
n14
*
b
.
n23
*
b
.
n42
+
b
.
n14
*
b
.
n22
*
b
.
n43
-
b
.
n12
*
b
.
n24
*
b
.
n43
-
b
.
n13
*
b
.
n22
*
b
.
n44
+
b
.
n12
*
b
.
n23
*
b
.
n44
;
a
.
n14
=
b
.
n14
*
b
.
n23
*
b
.
n32
-
b
.
n13
*
b
.
n24
*
b
.
n32
-
b
.
n14
*
b
.
n22
*
b
.
n33
+
b
.
n12
*
b
.
n24
*
b
.
n33
+
b
.
n13
*
b
.
n22
*
b
.
n34
-
b
.
n12
*
b
.
n23
*
b
.
n34
;
a
.
n21
=
b
.
n24
*
b
.
n33
*
b
.
n41
-
b
.
n23
*
b
.
n34
*
b
.
n41
-
b
.
n24
*
b
.
n31
*
b
.
n43
+
b
.
n21
*
b
.
n34
*
b
.
n43
+
b
.
n23
*
b
.
n31
*
b
.
n44
-
b
.
n21
*
b
.
n33
*
b
.
n44
;
a
.
n22
=
b
.
n13
*
b
.
n34
*
b
.
n41
-
b
.
n14
*
b
.
n33
*
b
.
n41
+
b
.
n14
*
b
.
n31
*
b
.
n43
-
b
.
n11
*
b
.
n34
*
b
.
n43
-
b
.
n13
*
b
.
n31
*
b
.
n44
+
b
.
n11
*
b
.
n33
*
b
.
n44
;
a
.
n23
=
b
.
n14
*
b
.
n23
*
b
.
n41
-
b
.
n13
*
b
.
n24
*
b
.
n41
-
b
.
n14
*
b
.
n21
*
b
.
n43
+
b
.
n11
*
b
.
n24
*
b
.
n43
+
b
.
n13
*
b
.
n21
*
b
.
n44
-
b
.
n11
*
b
.
n23
*
b
.
n44
;
a
.
n24
=
b
.
n13
*
b
.
n24
*
b
.
n31
-
b
.
n14
*
b
.
n23
*
b
.
n31
+
b
.
n14
*
b
.
n21
*
b
.
n33
-
b
.
n11
*
b
.
n24
*
b
.
n33
-
b
.
n13
*
b
.
n21
*
b
.
n34
+
b
.
n11
*
b
.
n23
*
b
.
n34
;
a
.
n31
=
b
.
n22
*
b
.
n34
*
b
.
n41
-
b
.
n24
*
b
.
n32
*
b
.
n41
+
b
.
n24
*
b
.
n31
*
b
.
n42
-
b
.
n21
*
b
.
n34
*
b
.
n42
-
b
.
n22
*
b
.
n31
*
b
.
n44
+
b
.
n21
*
b
.
n32
*
b
.
n44
;
a
.
n32
=
b
.
n14
*
b
.
n32
*
b
.
n41
-
b
.
n12
*
b
.
n34
*
b
.
n41
-
b
.
n14
*
b
.
n31
*
b
.
n42
+
b
.
n11
*
b
.
n34
*
b
.
n42
+
b
.
n12
*
b
.
n31
*
b
.
n44
-
b
.
n11
*
b
.
n32
*
b
.
n44
;
a
.
n33
=
b
.
n13
*
b
.
n24
*
b
.
n41
-
b
.
n14
*
b
.
n22
*
b
.
n41
+
b
.
n14
*
b
.
n21
*
b
.
n42
-
b
.
n11
*
b
.
n24
*
b
.
n42
-
b
.
n12
*
b
.
n21
*
b
.
n44
+
b
.
n11
*
b
.
n22
*
b
.
n44
;
a
.
n34
=
b
.
n14
*
b
.
n22
*
b
.
n31
-
b
.
n12
*
b
.
n24
*
b
.
n31
-
b
.
n14
*
b
.
n21
*
b
.
n32
+
b
.
n11
*
b
.
n24
*
b
.
n32
+
b
.
n12
*
b
.
n21
*
b
.
n34
-
b
.
n11
*
b
.
n22
*
b
.
n34
;
a
.
n41
=
b
.
n23
*
b
.
n32
*
b
.
n41
-
b
.
n22
*
b
.
n33
*
b
.
n41
-
b
.
n23
*
b
.
n31
*
b
.
n42
+
b
.
n21
*
b
.
n33
*
b
.
n42
+
b
.
n22
*
b
.
n31
*
b
.
n43
-
b
.
n21
*
b
.
n32
*
b
.
n43
;
a
.
n42
=
b
.
n12
*
b
.
n33
*
b
.
n41
-
b
.
n13
*
b
.
n32
*
b
.
n41
+
b
.
n13
*
b
.
n31
*
b
.
n42
-
b
.
n11
*
b
.
n33
*
b
.
n42
-
b
.
n12
*
b
.
n31
*
b
.
n43
+
b
.
n11
*
b
.
n32
*
b
.
n43
;
a
.
n43
=
b
.
n13
*
b
.
n22
*
b
.
n41
-
b
.
n12
*
b
.
n23
*
b
.
n41
-
b
.
n13
*
b
.
n21
*
b
.
n42
+
b
.
n11
*
b
.
n23
*
b
.
n42
+
b
.
n12
*
b
.
n21
*
b
.
n43
-
b
.
n11
*
b
.
n22
*
b
.
n43
;
a
.
n44
=
b
.
n12
*
b
.
n23
*
b
.
n31
-
b
.
n13
*
b
.
n22
*
b
.
n31
+
b
.
n13
*
b
.
n21
*
b
.
n32
-
b
.
n11
*
b
.
n23
*
b
.
n32
-
b
.
n12
*
b
.
n21
*
b
.
n33
+
b
.
n11
*
b
.
n22
*
b
.
n33
;
a
.
multiplyScalar
(
1
/
b
.
determinant
());
return
a
};
THREE
.
Matrix4
.
makeInvert3x3
=
function
(
o
){
var
e
=
o
.
flatten
(),
l
=
new
THREE
.
Matrix3
(),
n
=
e
[
10
]
*
e
[
5
]
-
e
[
6
]
*
e
[
9
],
i
=-
e
[
10
]
*
e
[
1
]
+
e
[
2
]
*
e
[
9
],
d
=
e
[
6
]
*
e
[
1
]
-
e
[
2
]
*
e
[
5
],
k
=-
e
[
10
]
*
e
[
4
]
+
e
[
6
]
*
e
[
8
],
g
=
e
[
10
]
*
e
[
0
]
-
e
[
2
]
*
e
[
8
],
c
=-
e
[
6
]
*
e
[
0
]
+
e
[
2
]
*
e
[
4
],
j
=
e
[
9
]
*
e
[
4
]
-
e
[
5
]
*
e
[
8
],
f
=-
e
[
9
]
*
e
[
0
]
+
e
[
1
]
*
e
[
8
],
a
=
e
[
5
]
*
e
[
0
]
-
e
[
1
]
*
e
[
4
],
h
=
e
[
0
]
*
(
n
)
+
e
[
1
]
*
(
k
)
+
e
[
2
]
*
(
j
),
b
;
if
(
h
==
0
){
throw
"
matrix not invertible
"
}
b
=
1
/
h
;
l
.
m
[
0
]
=
b
*
n
;
l
.
m
[
1
]
=
b
*
i
;
l
.
m
[
2
]
=
b
*
d
;
l
.
m
[
3
]
=
b
*
k
;
l
.
m
[
4
]
=
b
*
g
;
l
.
m
[
5
]
=
b
*
c
;
l
.
m
[
6
]
=
b
*
j
;
l
.
m
[
7
]
=
b
*
f
;
l
.
m
[
8
]
=
b
*
a
;
return
l
};
THREE
.
Matrix4
.
makeFrustum
=
function
(
f
,
r
,
e
,
o
,
i
,
h
){
var
g
,
q
,
n
,
p
,
l
,
k
,
j
;
g
=
new
THREE
.
Matrix4
();
q
=
2
*
i
/
(
r
-
f
);
n
=
2
*
i
/
(
o
-
e
);
p
=
(
r
+
f
)
/
(
r
-
f
);
l
=
(
o
+
e
)
/
(
o
-
e
);
k
=-
(
h
+
i
)
/
(
h
-
i
);
j
=-
2
*
h
*
i
/
(
h
-
i
);
g
.
n11
=
q
;
g
.
n12
=
0
;
g
.
n13
=
p
;
g
.
n14
=
0
;
g
.
n21
=
0
;
g
.
n22
=
n
;
g
.
n23
=
l
;
g
.
n24
=
0
;
g
.
n31
=
0
;
g
.
n32
=
0
;
g
.
n33
=
k
;
g
.
n34
=
j
;
g
.
n41
=
0
;
g
.
n42
=
0
;
g
.
n43
=-
1
;
g
.
n44
=
0
;
return
g
};
THREE
.
Matrix4
.
makePerspective
=
function
(
e
,
c
,
g
,
b
){
var
a
,
f
,
h
,
d
;
a
=
g
*
Math
.
tan
(
e
*
Math
.
PI
/
360
);
f
=-
a
;
h
=
f
*
c
;
d
=
a
*
c
;
return
THREE
.
Matrix4
.
makeFrustum
(
h
,
d
,
f
,
a
,
g
,
b
)};
THREE
.
Matrix4
.
makeOrtho
=
function
(
c
,
o
,
k
,
a
,
g
,
f
){
var
d
,
l
,
j
,
i
,
n
,
e
,
b
;
d
=
new
THREE
.
Matrix4
();
n
=
o
-
c
;
e
=
k
-
a
;
b
=
f
-
g
;
l
=
(
o
+
c
)
/
n
;
j
=
(
k
+
a
)
/
e
;
i
=
(
f
+
g
)
/
b
;
d
.
n11
=
2
/
n
;
d
.
n12
=
0
;
d
.
n13
=
0
;
d
.
n14
=-
l
;
d
.
n21
=
0
;
d
.
n22
=
2
/
e
;
d
.
n23
=
0
;
d
.
n24
=-
j
;
d
.
n31
=
0
;
d
.
n32
=
0
;
d
.
n33
=-
2
/
b
;
d
.
n34
=-
i
;
d
.
n41
=
0
;
d
.
n42
=
0
;
d
.
n43
=
0
;
d
.
n44
=
1
;
return
d
};
THREE
.
Vertex
=
function
(
a
,
b
){
this
.
position
=
a
||
new
THREE
.
Vector3
();
this
.
positionWorld
=
new
THREE
.
Vector3
();
this
.
positionScreen
=
new
THREE
.
Vector3
();
this
.
normal
=
b
||
new
THREE
.
Vector3
();
this
.
normalWorld
=
new
THREE
.
Vector3
();
this
.
normalScreen
=
new
THREE
.
Vector3
();
this
.
__visible
=
true
};
THREE
.
Vertex
.
prototype
=
{
toString
:
function
(){
return
"
THREE.Vertex ( position:
"
+
this
.
position
+
"
, normal:
"
+
this
.
normal
+
"
)
"
}};
THREE
.
Face3
=
function
(
e
,
d
,
h
,
g
,
f
){
this
.
a
=
e
;
this
.
b
=
d
;
this
.
c
=
h
;
this
.
centroid
=
new
THREE
.
Vector3
();
this
.
normal
=
g
instanceof
THREE
.
Vector3
?
g
:
new
THREE
.
Vector3
();
this
.
vertexNormals
=
g
instanceof
Array
?
g
:[];
this
.
material
=
f
instanceof
Array
?
f
:[
f
]};
THREE
.
Face3
.
prototype
=
{
toString
:
function
(){
return
"
THREE.Face3 (
"
+
this
.
a
+
"
,
"
+
this
.
b
+
"
,
"
+
this
.
c
+
"
)
"
}};
THREE
.
Face4
=
function
(
f
,
e
,
j
,
i
,
h
,
g
){
this
.
a
=
f
;
this
.
b
=
e
;
this
.
c
=
j
;
this
.
d
=
i
;
this
.
centroid
=
new
THREE
.
Vector3
();
this
.
normal
=
h
instanceof
THREE
.
Vector3
?
h
:
new
THREE
.
Vector3
();
this
.
vertexNormals
=
h
instanceof
Array
?
h
:[];
this
.
material
=
g
instanceof
Array
?
g
:[
g
]};
THREE
.
Face4
.
prototype
=
{
toString
:
function
(){
return
"
THREE.Face4 (
"
+
this
.
a
+
"
,
"
+
this
.
b
+
"
,
"
+
this
.
c
+
"
"
+
this
.
d
+
"
)
"
}};
THREE
.
UV
=
function
(
b
,
a
){
this
.
u
=
b
||
0
;
this
.
v
=
a
||
0
};
THREE
.
UV
.
prototype
=
{
copy
:
function
(
a
){
this
.
u
=
a
.
u
;
this
.
v
=
a
.
v
},
toString
:
function
(){
return
"
THREE.UV (
"
+
this
.
u
+
"
,
"
+
this
.
v
+
"
)
"
}};
THREE
.
Geometry
=
function
(){
this
.
vertices
=
[];
this
.
faces
=
[];
this
.
uvs
=
[]};
THREE
.
Geometry
.
prototype
=
{
computeCentroids
:
function
(){
var
c
,
b
,
a
;
for
(
c
=
0
,
b
=
this
.
faces
.
length
;
c
<
b
;
c
++
){
a
=
this
.
faces
[
c
];
a
.
centroid
.
set
(
0
,
0
,
0
);
if
(
a
instanceof
THREE
.
Face3
){
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
a
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
b
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
c
].
position
);
a
.
centroid
.
divideScalar
(
3
)}
else
{
if
(
a
instanceof
THREE
.
Face4
){
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
a
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
b
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
c
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
d
].
position
);
a
.
centroid
.
divideScalar
(
4
)}}}},
computeNormals
:
function
(
m
){
var
e
,
b
,
o
,
g
,
i
,
j
,
l
,
k
,
d
,
c
,
a
,
h
=
new
THREE
.
Vector3
(),
p
=
new
THREE
.
Vector3
();
for
(
o
=
0
,
g
=
this
.
vertices
.
length
;
o
<
g
;
o
++
){
i
=
this
.
vertices
[
o
];
i
.
normal
.
set
(
0
,
0
,
0
)}
for
(
j
=
0
,
l
=
this
.
faces
.
length
;
j
<
l
;
j
++
){
k
=
this
.
faces
[
j
];
if
(
m
&&
k
.
vertexNormals
.
length
){
h
.
set
(
0
,
0
,
0
);
for
(
e
=
0
,
b
=
k
.
normal
.
length
;
e
<
b
;
e
++
){
h
.
addSelf
(
k
.
vertexNormals
[
e
])}
h
.
divideScalar
(
3
);
if
(
!
h
.
isZero
()){
h
.
normalize
()}
k
.
normal
.
copy
(
h
)}
else
{
d
=
this
.
vertices
[
k
.
a
];
c
=
this
.
vertices
[
k
.
b
];
a
=
this
.
vertices
[
k
.
c
];
h
.
sub
(
a
.
position
,
c
.
position
);
p
.
sub
(
d
.
position
,
c
.
position
);
h
.
crossSelf
(
p
);
if
(
!
h
.
isZero
()){
h
.
normalize
()}
k
.
normal
.
copy
(
h
)}}},
computeBoundingBox
:
function
(){
if
(
this
.
vertices
.
length
>
0
){
this
.
bbox
=
{
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
a
=
1
,
b
=
this
.
vertices
.
length
;
a
<
b
;
a
++
){
vertex
=
this
.
vertices
[
a
];
if
(
vertex
.
position
.
x
<
this
.
bbox
.
x
[
0
]){
this
.
bbox
.
x
[
0
]
=
vertex
.
position
.
x
}
else
{
if
(
vertex
.
position
.
x
>
this
.
bbox
.
x
[
1
]){
this
.
bbox
.
x
[
1
]
=
vertex
.
position
.
x
}}
if
(
vertex
.
position
.
y
<
this
.
bbox
.
y
[
0
]){
this
.
bbox
.
y
[
0
]
=
vertex
.
position
.
y
}
else
{
if
(
vertex
.
position
.
y
>
this
.
bbox
.
y
[
1
]){
this
.
bbox
.
y
[
1
]
=
vertex
.
position
.
y
}}
if
(
vertex
.
position
.
z
<
this
.
bbox
.
z
[
0
]){
this
.
bbox
.
z
[
0
]
=
vertex
.
position
.
z
}
else
{
if
(
vertex
.
position
.
z
>
this
.
bbox
.
z
[
1
]){
this
.
bbox
.
z
[
1
]
=
vertex
.
position
.
z
}}}}},
toString
:
function
(){
return
"
THREE.Geometry ( vertices:
"
+
this
.
vertices
+
"
, faces:
"
+
this
.
faces
+
"
)
"
}};
THREE
.
Camera
=
function
(
c
,
b
,
d
,
a
){
this
.
position
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
this
.
target
=
{
position
:
new
THREE
.
Vector3
(
0
,
0
,
0
)};
this
.
up
=
new
THREE
.
Vector3
(
0
,
1
,
0
);
this
.
matrix
=
new
THREE
.
Matrix4
();
this
.
projectionMatrix
=
THREE
.
Matrix4
.
makePerspective
(
c
,
b
,
d
,
a
);
this
.
autoUpdateMatrix
=
true
;
this
.
updateMatrix
=
function
(){
this
.
matrix
.
lookAt
(
this
.
position
,
this
.
target
.
position
,
this
.
up
)};
this
.
toString
=
function
(){
return
"
THREE.Camera (
"
+
this
.
position
+
"
,
"
+
this
.
target
.
position
+
"
)
"
}};
THREE
.
Loader
=
function
(){};
THREE
.
Loader
.
prototype
=
{
loadAsciiOld
:
function
(
a
,
c
){
var
b
=
document
.
createElement
(
"
script
"
);
b
.
type
=
"
text/javascript
"
;
b
.
onload
=
c
;
b
.
src
=
a
;
document
.
getElementsByTagName
(
"
head
"
)[
0
].
appendChild
(
b
)},
loadAscii
:
function
(
a
,
e
,
b
){
var
c
=
(
new
Date
).
getTime
(),
d
=
new
Worker
(
a
);
d
.
onmessage
=
function
(
f
){
THREE
.
Loader
.
prototype
.
createModel
(
f
.
data
,
e
,
b
)};
d
.
postMessage
(
c
)},
loadBinary
:
function
(
a
,
e
,
b
){
var
c
=
(
new
Date
).
getTime
(),
d
=
new
Worker
(
a
);
d
.
onmessage
=
function
(
h
){
var
g
=
h
.
data
.
materials
,
f
=
h
.
data
.
buffers
;
THREE
.
Loader
.
prototype
.
loadAjaxBuffers
(
f
,
g
,
e
,
b
)};
d
.
onerror
=
function
(
f
){
alert
(
"
worker.onerror:
"
+
f
.
message
+
"
\n
"
+
f
.
data
);
f
.
preventDefault
()};
d
.
postMessage
(
c
)},
loadAjaxBuffers
:
function
(
b
,
a
,
f
,
d
){
var
e
=
new
XMLHttpRequest
(),
c
=
d
+
"
/
"
+
b
;
e
.
onreadystatechange
=
function
(){
if
(
e
.
readyState
==
4
){
if
(
e
.
status
==
200
||
e
.
status
==
0
){
THREE
.
Loader
.
prototype
.
createBinModel
(
e
.
responseText
,
f
,
d
,
a
)}
else
{
alert
(
"
Couldn't load [
"
+
c
+
"
] [
"
+
e
.
status
+
"
]
"
)}}};
e
.
open
(
"
GET
"
,
c
,
true
);
e
.
overrideMimeType
(
"
text/plain; charset=x-user-defined
"
);
e
.
setRequestHeader
(
"
Content-Type
"
,
"
text/plain
"
);
e
.
send
(
null
)},
createBinModel
:
function
(
c
,
e
,
b
,
a
){
var
d
=
function
(
aa
){
var
I
=
this
,
h
=
0
,
x
,
A
=
[],
L
=
[],
V
,
T
,
O
,
U
,
R
,
P
,
D
,
C
,
B
,
y
,
r
,
q
,
p
,
o
,
u
,
t
,
N
,
K
,
J
;
THREE
.
Geometry
.
call
(
this
);
THREE
.
Loader
.
prototype
.
init_materials
(
I
,
a
,
aa
);
x
=
W
(
c
,
h
);
h
+=
x
.
header_bytes
;
V
=
x
.
vertex_index_bytes
,
T
=
x
.
vertex_index_bytes
*
2
,
O
=
x
.
vertex_index_bytes
*
3
,
U
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
,
R
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
,
P
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
2
,
D
=
x
.
vertex_index_bytes
,
C
=
x
.
vertex_index_bytes
*
2
,
B
=
x
.
vertex_index_bytes
*
3
,
y
=
x
.
vertex_index_bytes
*
4
,
r
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
,
q
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
,
p
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
2
,
o
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
3
,
u
=
x
.
uv_index_bytes
,
t
=
x
.
uv_index_bytes
*
2
,
N
=
x
.
uv_index_bytes
,
K
=
x
.
uv_index_bytes
*
2
,
J
=
x
.
uv_index_bytes
*
3
;
h
+=
w
(
h
);
h
+=
H
(
h
);
h
+=
G
(
h
);
h
+=
Q
(
h
);
h
+=
S
(
h
);
h
+=
ab
(
h
);
h
+=
n
(
h
);
h
+=
g
(
h
);
h
+=
k
(
h
);
h
+=
s
(
h
);
h
+=
z
(
h
);
this
.
computeCentroids
();
this
.
computeNormals
();
function
W
(
ad
,
ae
){
var
ac
=
{
signature
:
F
(
ad
,
ae
,
8
),
header_bytes
:
j
(
ad
,
ae
+
8
),
vertex_coordinate_bytes
:
j
(
ad
,
ae
+
9
),
normal_coordinate_bytes
:
j
(
ad
,
ae
+
10
),
uv_coordinate_bytes
:
j
(
ad
,
ae
+
11
),
vertex_index_bytes
:
j
(
ad
,
ae
+
12
),
normal_index_bytes
:
j
(
ad
,
ae
+
13
),
uv_index_bytes
:
j
(
ad
,
ae
+
14
),
material_index_bytes
:
j
(
ad
,
ae
+
15
),
nvertices
:
v
(
ad
,
ae
+
16
),
nnormals
:
v
(
ad
,
ae
+
16
+
4
*
1
),
nuvs
:
v
(
ad
,
ae
+
16
+
4
*
2
),
ntri_flat
:
v
(
ad
,
ae
+
16
+
4
*
3
),
ntri_smooth
:
v
(
ad
,
ae
+
16
+
4
*
4
),
ntri_flat_uv
:
v
(
ad
,
ae
+
16
+
4
*
5
),
ntri_smooth_uv
:
v
(
ad
,
ae
+
16
+
4
*
6
),
nquad_flat
:
v
(
ad
,
ae
+
16
+
4
*
7
),
nquad_smooth
:
v
(
ad
,
ae
+
16
+
4
*
8
),
nquad_flat_uv
:
v
(
ad
,
ae
+
16
+
4
*
9
),
nquad_smooth_uv
:
v
(
ad
,
ae
+
16
+
4
*
10
)};
return
ac
}
function
F
(
ad
,
ae
,
ac
){
return
ad
.
substr
(
ae
,
ac
)}
function
f
(
af
,
ae
){
var
ag
=
j
(
af
,
ae
),
ai
=
j
(
af
,
ae
+
1
),
aj
=
j
(
af
,
ae
+
2
),
ak
=
j
(
af
,
ae
+
3
),
ad
=
1
-
(
2
*
(
ak
>>
7
)),
ah
=
(((
ak
<<
1
)
&
255
)
|
(
aj
>>
7
))
-
127
,
ac
=
((
aj
&
127
)
<<
16
)
|
(
ai
<<
8
)
|
ag
;
if
(
ac
==
0
&&
ah
==-
127
){
return
0
}
return
ad
*
(
1
+
ac
*
Math
.
pow
(
2
,
-
23
))
*
Math
.
pow
(
2
,
ah
)}
function
v
(
ag
,
ah
){
var
af
=
j
(
ag
,
ah
),
ae
=
j
(
ag
,
ah
+
1
),
ad
=
j
(
ag
,
ah
+
2
),
ac
=
j
(
ag
,
ah
+
3
);
return
(
ac
<<
24
)
+
(
ad
<<
16
)
+
(
ae
<<
8
)
+
af
}
function
Z
(
ae
,
af
){
var
ad
=
j
(
ae
,
af
),
ac
=
j
(
ae
,
af
+
1
);
return
(
ac
<<
8
)
+
ad
}
function
i
(
ad
,
ae
){
var
ac
=
j
(
ad
,
ae
);
return
ac
>
127
?
ac
-
256
:
ac
}
function
j
(
ac
,
ad
){
return
ac
.
charCodeAt
(
ad
)
&
255
}
function
w
(
ai
){
var
ae
,
ac
,
ah
,
ag
,
af
=
x
.
vertex_coordinate_bytes
*
3
,
ad
=
ai
+
x
.
nvertices
*
af
;
for
(
ae
=
ai
;
ae
<
ad
;
ae
+=
af
){
ac
=
f
(
c
,
ae
);
ah
=
f
(
c
,
ae
+
x
.
vertex_coordinate_bytes
);
ag
=
f
(
c
,
ae
+
x
.
vertex_coordinate_bytes
*
2
);
THREE
.
Loader
.
prototype
.
v
(
I
,
ac
,
ah
,
ag
)}
return
x
.
nvertices
*
af
}
function
H
(
ai
){
var
ae
,
ac
,
ah
,
ag
,
af
=
x
.
normal_coordinate_bytes
*
3
,
ad
=
ai
+
x
.
nnormals
*
af
;
for
(
ae
=
ai
;
ae
<
ad
;
ae
+=
af
){
ac
=
i
(
c
,
ae
);
ah
=
i
(
c
,
ae
+
x
.
normal_coordinate_bytes
);
ag
=
i
(
c
,
ae
+
x
.
normal_coordinate_bytes
*
2
);
A
.
push
(
ac
/
127
,
ah
/
127
,
ag
/
127
)}
return
x
.
nnormals
*
af
}
function
G
(
ah
){
var
af
,
ae
,
ad
,
ag
=
x
.
uv_coordinate_bytes
*
2
,
ac
=
ah
+
x
.
nuvs
*
ag
;
for
(
af
=
ah
;
af
<
ac
;
af
+=
ag
){
ae
=
f
(
c
,
af
);
ad
=
f
(
c
,
af
+
x
.
uv_coordinate_bytes
);
L
.
push
(
ae
,
ad
)}
return
x
.
nuvs
*
ag
}
function
M
(
af
){
var
ae
,
ad
,
ag
,
ac
;
ae
=
v
(
c
,
af
);
ad
=
v
(
c
,
af
+
V
);
ag
=
v
(
c
,
af
+
T
);
ac
=
Z
(
c
,
af
+
O
);
THREE
.
Loader
.
prototype
.
f3
(
I
,
ae
,
ad
,
ag
,
ac
)}
function
m
(
ah
){
var
ag
,
ae
,
aj
,
ad
,
af
,
ac
,
ai
;
ag
=
v
(
c
,
ah
);
ae
=
v
(
c
,
ah
+
V
);
aj
=
v
(
c
,
ah
+
T
);
ad
=
Z
(
c
,
ah
+
O
);
af
=
v
(
c
,
ah
+
U
);
ac
=
v
(
c
,
ah
+
R
);
ai
=
v
(
c
,
ah
+
P
);
THREE
.
Loader
.
prototype
.
f3n
(
I
,
A
,
ag
,
ae
,
aj
,
ad
,
af
,
ac
,
ai
)}
function
E
(
af
){
var
ae
,
ad
,
ah
,
ag
,
ac
;
ae
=
v
(
c
,
af
);
ad
=
v
(
c
,
af
+
D
);
ah
=
v
(
c
,
af
+
C
);
ag
=
v
(
c
,
af
+
B
);
ac
=
Z
(
c
,
af
+
y
);
THREE
.
Loader
.
prototype
.
f4
(
I
,
ae
,
ad
,
ah
,
ag
,
ac
)}
function
l
(
af
){
var
al
,
ak
,
aj
,
ai
,
ac
,
ah
,
ag
,
ae
,
ad
;
al
=
v
(
c
,
af
);
ak
=
v
(
c
,
af
+
D
);
aj
=
v
(
c
,
af
+
C
);
ai
=
v
(
c
,
af
+
B
);
ac
=
Z
(
c
,
af
+
y
);
ah
=
v
(
c
,
af
+
r
);
ag
=
v
(
c
,
af
+
q
);
ae
=
v
(
c
,
af
+
p
);
ad
=
v
(
c
,
af
+
o
);
THREE
.
Loader
.
prototype
.
f4n
(
I
,
A
,
al
,
ak
,
aj
,
ai
,
ac
,
ah
,
ag
,
ae
,
ad
)}
function
Y
(
ai
){
var
ah
,
ae
,
ac
,
ag
,
af
,
ad
,
al
,
ak
,
aj
;
ah
=
v
(
c
,
ai
);
ae
=
v
(
c
,
ai
+
u
);
ac
=
v
(
c
,
ai
+
t
);
ag
=
L
[
ah
*
2
];
al
=
L
[
ah
*
2
+
1
];
af
=
L
[
ae
*
2
];
ak
=
L
[
ae
*
2
+
1
];
ad
=
L
[
ac
*
2
];
aj
=
L
[
ac
*
2
+
1
];
THREE
.
Loader
.
prototype
.
uv
(
I
,
ag
,
al
,
af
,
ak
,
ad
,
aj
)}
function
X
(
ak
){
var
aj
,
ag
,
ae
,
ad
,
ai
,
ah
,
af
,
ac
,
ao
,
an
,
am
,
al
;
aj
=
v
(
c
,
ak
);
ag
=
v
(
c
,
ak
+
N
);
ae
=
v
(
c
,
ak
+
K
);
ad
=
v
(
c
,
ak
+
J
);
ai
=
L
[
aj
*
2
];
ao
=
L
[
aj
*
2
+
1
];
ah
=
L
[
ag
*
2
];
an
=
L
[
ag
*
2
+
1
];
af
=
L
[
ae
*
2
];
am
=
L
[
ae
*
2
+
1
];
ac
=
L
[
ad
*
2
];
al
=
L
[
ad
*
2
+
1
];
THREE
.
Loader
.
prototype
.
uv
(
I
,
ai
,
ao
,
ah
,
an
,
af
,
am
,
ac
,
al
)}
function
Q
(
af
){
var
ad
,
ae
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
,
ac
=
af
+
x
.
ntri_flat
*
ae
;
for
(
ad
=
af
;
ad
<
ac
;
ad
+=
ae
){
M
(
ad
)}
return
ac
-
af
}
function
ab
(
ag
){
var
ad
,
af
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
,
ae
=
af
+
x
.
uv_index_bytes
*
3
,
ac
=
ag
+
x
.
ntri_flat_uv
*
ae
;
for
(
ad
=
ag
;
ad
<
ac
;
ad
+=
ae
){
M
(
ad
);
Y
(
ad
+
af
)}
return
ac
-
ag
}
function
S
(
af
){
var
ad
,
ae
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
3
,
ac
=
af
+
x
.
ntri_smooth
*
ae
;
for
(
ad
=
af
;
ad
<
ac
;
ad
+=
ae
){
m
(
ad
)}
return
ac
-
af
}
function
n
(
ag
){
var
ad
,
af
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
3
,
ae
=
af
+
x
.
uv_index_bytes
*
3
,
ac
=
ag
+
x
.
ntri_smooth_uv
*
ae
;
for
(
ad
=
ag
;
ad
<
ac
;
ad
+=
ae
){
m
(
ad
);
Y
(
ad
+
af
)}
return
ac
-
ag
}
function
g
(
af
){
var
ad
,
ae
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
,
ac
=
af
+
x
.
nquad_flat
*
ae
;
for
(
ad
=
af
;
ad
<
ac
;
ad
+=
ae
){
E
(
ad
)}
return
ac
-
af
}
function
s
(
ag
){
var
ad
,
af
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
,
ae
=
af
+
x
.
uv_index_bytes
*
4
,
ac
=
ag
+
x
.
nquad_flat_uv
*
ae
;
for
(
ad
=
ag
;
ad
<
ac
;
ad
+=
ae
){
E
(
ad
);
X
(
ad
+
af
)}
return
ac
-
ag
}
function
k
(
af
){
var
ad
,
ae
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
4
,
ac
=
af
+
x
.
nquad_smooth
*
ae
;
for
(
ad
=
af
;
ad
<
ac
;
ad
+=
ae
){
l
(
ad
)}
return
ac
-
af
}
function
z
(
ag
){
var
ad
,
af
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
4
,
ae
=
af
+
x
.
uv_index_bytes
*
4
,
ac
=
ag
+
x
.
nquad_smooth_uv
*
ae
;
for
(
ad
=
ag
;
ad
<
ac
;
ad
+=
ae
){
l
(
ad
);
X
(
ad
+
af
)}
return
ac
-
ag
}};
d
.
prototype
=
new
THREE
.
Geometry
();
d
.
prototype
.
constructor
=
d
;
e
(
new
d
(
b
))},
createModel
:
function
(
b
,
d
,
a
){
var
c
=
function
(
f
){
var
g
=
this
;
THREE
.
Geometry
.
call
(
this
);
THREE
.
Loader
.
prototype
.
init_materials
(
g
,
b
.
materials
,
f
);
e
();
h
();
this
.
computeCentroids
();
this
.
computeNormals
();
function
e
(){
var
m
,
k
,
j
,
o
,
n
;
for
(
m
=
0
,
k
=
b
.
vertices
.
length
;
m
<
k
;
m
+=
3
){
j
=
b
.
vertices
[
m
];
o
=
b
.
vertices
[
m
+
1
];
n
=
b
.
vertices
[
m
+
2
];
THREE
.
Loader
.
prototype
.
v
(
g
,
j
,
o
,
n
)}}
function
h
(){
function
p
(
v
,
u
){
var
t
,
s
,
w
,
l
;
t
=
v
[
u
];
s
=
v
[
u
+
1
];
w
=
v
[
u
+
2
];
l
=
v
[
u
+
3
];
THREE
.
Loader
.
prototype
.
f3
(
g
,
t
,
s
,
w
,
l
)}
function
k
(
l
,
u
){
var
z
,
y
,
x
,
s
,
w
,
v
,
t
;
z
=
l
[
u
];
y
=
l
[
u
+
1
];
x
=
l
[
u
+
2
];
s
=
l
[
u
+
3
];
w
=
l
[
u
+
4
];
v
=
l
[
u
+
5
];
t
=
l
[
u
+
6
];
THREE
.
Loader
.
prototype
.
f3n
(
g
,
b
.
normals
,
z
,
y
,
x
,
s
,
w
,
v
,
t
)}
function
o
(
w
,
u
){
var
t
,
s
,
x
,
v
,
l
;
t
=
w
[
u
];
s
=
w
[
u
+
1
];
x
=
w
[
u
+
2
];
v
=
w
[
u
+
3
];
l
=
w
[
u
+
4
];
THREE
.
Loader
.
prototype
.
f4
(
g
,
t
,
s
,
x
,
v
,
l
)}
function
j
(
l
,
v
){
var
B
,
A
,
z
,
y
,
s
,
x
,
w
,
u
,
t
;
B
=
l
[
v
];
A
=
l
[
v
+
1
];
z
=
l
[
v
+
2
];
y
=
l
[
v
+
3
];
s
=
l
[
v
+
4
];
x
=
l
[
v
+
5
];
w
=
l
[
v
+
6
];
u
=
l
[
v
+
7
];
t
=
l
[
v
+
8
];
THREE
.
Loader
.
prototype
.
f4n
(
g
,
b
.
normals
,
B
,
A
,
z
,
y
,
s
,
x
,
w
,
u
,
t
)}
function
r
(
l
,
y
){
var
x
,
u
,
s
,
w
,
v
,
t
,
B
,
A
,
z
;
x
=
l
[
y
];
u
=
l
[
y
+
1
];
s
=
l
[
y
+
2
];
w
=
b
.
uvs
[
x
*
2
];
B
=
b
.
uvs
[
x
*
2
+
1
];
v
=
b
.
uvs
[
u
*
2
];
A
=
b
.
uvs
[
u
*
2
+
1
];
t
=
b
.
uvs
[
s
*
2
];
z
=
b
.
uvs
[
s
*
2
+
1
];
THREE
.
Loader
.
prototype
.
uv
(
g
,
w
,
B
,
v
,
A
,
t
,
z
)}
function
q
(
s
,
A
){
var
z
,
w
,
v
,
t
,
y
,
x
,
u
,
l
,
E
,
D
,
C
,
B
;
z
=
s
[
A
];
w
=
s
[
A
+
1
];
v
=
s
[
A
+
2
];
t
=
s
[
A
+
3
];
y
=
b
.
uvs
[
z
*
2
];
E
=
b
.
uvs
[
z
*
2
+
1
];
x
=
b
.
uvs
[
w
*
2
];
D
=
b
.
uvs
[
w
*
2
+
1
];
u
=
b
.
uvs
[
v
*
2
];
C
=
b
.
uvs
[
v
*
2
+
1
];
l
=
b
.
uvs
[
t
*
2
];
B
=
b
.
uvs
[
t
*
2
+
1
];
THREE
.
Loader
.
prototype
.
uv
(
g
,
y
,
E
,
x
,
D
,
u
,
C
,
l
,
B
)}
var
n
,
m
;
for
(
n
=
0
,
m
=
b
.
triangles
.
length
;
n
<
m
;
n
+=
4
){
p
(
b
.
triangles
,
n
)}
for
(
n
=
0
,
m
=
b
.
triangles_uv
.
length
;
n
<
m
;
n
+=
7
){
p
(
b
.
triangles_uv
,
n
);
r
(
b
.
triangles_uv
,
n
+
4
)}
for
(
n
=
0
,
m
=
b
.
triangles_n
.
length
;
n
<
m
;
n
+=
7
){
k
(
b
.
triangles_n
,
n
)}
for
(
n
=
0
,
m
=
b
.
triangles_n_uv
.
length
;
n
<
m
;
n
+=
10
){
k
(
b
.
triangles_n_uv
,
n
);
r
(
b
.
triangles_n_uv
,
n
+
7
)}
for
(
n
=
0
,
m
=
b
.
quads
.
length
;
n
<
m
;
n
+=
5
){
o
(
b
.
quads
,
n
)}
for
(
n
=
0
,
m
=
b
.
quads_uv
.
length
;
n
<
m
;
n
+=
9
){
o
(
b
.
quads_uv
,
n
);
q
(
b
.
quads_uv
,
n
+
5
)}
for
(
n
=
0
,
m
=
b
.
quads_n
.
length
;
n
<
m
;
n
+=
9
){
j
(
b
.
quads_n
,
n
)}
for
(
n
=
0
,
m
=
b
.
quads_n_uv
.
length
;
n
<
m
;
n
+=
13
){
j
(
b
.
quads_n_uv
,
n
);
q
(
b
.
quads_n_uv
,
n
+
9
)}}};
c
.
prototype
=
new
THREE
.
Geometry
();
c
.
prototype
.
constructor
=
c
;
d
(
new
c
(
a
))},
v
:
function
(
b
,
a
,
d
,
c
){
b
.
vertices
.
push
(
new
THREE
.
Vertex
(
new
THREE
.
Vector3
(
a
,
d
,
c
)))},
f3
:
function
(
h
,
e
,
d
,
i
,
f
){
var
g
=
h
.
materials
[
f
];
h
.
faces
.
push
(
new
THREE
.
Face3
(
e
,
d
,
i
,
null
,
g
))},
f4
:
function
(
i
,
f
,
e
,
k
,
j
,
g
){
var
h
=
i
.
materials
[
g
];
i
.
faces
.
push
(
new
THREE
.
Face4
(
f
,
e
,
k
,
j
,
null
,
h
))},
f3n
:
function
(
d
,
l
,
s
,
r
,
q
,
p
,
j
,
i
,
h
){
var
k
=
d
.
materials
[
p
],
g
=
l
[
j
*
3
],
f
=
l
[
j
*
3
+
1
],
e
=
l
[
j
*
3
+
2
],
o
=
l
[
i
*
3
],
n
=
l
[
i
*
3
+
1
],
m
=
l
[
i
*
3
+
2
],
v
=
l
[
h
*
3
],
u
=
l
[
h
*
3
+
1
],
t
=
l
[
h
*
3
+
2
];
d
.
faces
.
push
(
new
THREE
.
Face3
(
s
,
r
,
q
,[
new
THREE
.
Vector3
(
g
,
f
,
e
),
new
THREE
.
Vector3
(
o
,
n
,
m
),
new
THREE
.
Vector3
(
v
,
u
,
t
)],
k
))},
f4n
:
function
(
e
,
q
,
y
,
x
,
w
,
u
,
v
,
o
,
n
,
m
,
k
){
var
p
=
e
.
materials
[
v
],
j
=
q
[
o
*
3
],
h
=
q
[
o
*
3
+
1
],
f
=
q
[
o
*
3
+
2
],
t
=
q
[
n
*
3
],
s
=
q
[
n
*
3
+
1
],
r
=
q
[
n
*
3
+
2
],
B
=
q
[
m
*
3
],
A
=
q
[
m
*
3
+
1
],
z
=
q
[
m
*
3
+
2
],
l
=
q
[
k
*
3
],
i
=
q
[
k
*
3
+
1
],
g
=
q
[
k
*
3
+
2
];
e
.
faces
.
push
(
new
THREE
.
Face4
(
y
,
x
,
w
,
u
,[
new
THREE
.
Vector3
(
j
,
h
,
f
),
new
THREE
.
Vector3
(
t
,
s
,
r
),
new
THREE
.
Vector3
(
B
,
A
,
z
),
new
THREE
.
Vector3
(
l
,
i
,
g
)],
p
))},
uv
:
function
(
j
,
e
,
i
,
c
,
h
,
b
,
g
,
a
,
f
){
var
d
=
[];
d
.
push
(
new
THREE
.
UV
(
e
,
i
));
d
.
push
(
new
THREE
.
UV
(
c
,
h
));
d
.
push
(
new
THREE
.
UV
(
b
,
g
));
if
(
a
&&
f
){
d
.
push
(
new
THREE
.
UV
(
a
,
f
))}
j
.
uvs
.
push
(
d
)},
init_materials
:
function
(
d
,
a
,
c
){
d
.
materials
=
[];
for
(
var
b
=
0
;
b
<
a
.
length
;
++
b
){
d
.
materials
[
b
]
=
[
THREE
.
Loader
.
prototype
.
createMaterial
(
a
[
b
],
c
)]}},
createMaterial
:
function
(
a
,
c
){
function
g
(
j
){
var
i
=
Math
.
log
(
j
)
/
Math
.
LN2
;
return
Math
.
floor
(
i
)
==
i
}
function
f
(
j
){
var
i
=
Math
.
log
(
j
)
/
Math
.
LN2
;
return
Math
.
pow
(
2
,
Math
.
round
(
i
))}
var
d
,
e
,
h
,
b
;
if
(
a
.
map_diffuse
&&
c
){
e
=
document
.
createElement
(
"
canvas
"
);
d
=
new
THREE
.
MeshBitmapMaterial
(
e
);
h
=
new
Image
();
h
.
onload
=
function
(){
if
(
!
g
(
this
.
width
)
||!
g
(
this
.
height
)){
var
i
=
f
(
this
.
width
),
j
=
f
(
this
.
height
);
d
.
bitmap
.
width
=
i
;
d
.
bitmap
.
height
=
j
;
d
.
bitmap
.
getContext
(
"
2d
"
).
drawImage
(
this
,
0
,
0
,
i
,
j
)}
else
{
d
.
bitmap
=
this
}
d
.
loaded
=
1
};
h
.
src
=
c
+
"
/
"
+
a
.
map_diffuse
}
else
{
if
(
a
.
col_diffuse
){
b
=
(
a
.
col_diffuse
[
0
]
*
255
<<
16
)
+
(
a
.
col_diffuse
[
1
]
*
255
<<
8
)
+
a
.
col_diffuse
[
2
]
*
255
;
d
=
new
THREE
.
MeshColorFillMaterial
(
b
,
a
.
transparency
)}
else
{
if
(
a
.
a_dbg_color
){
d
=
new
THREE
.
MeshColorFillMaterial
(
a
.
a_dbg_color
)}
else
{
d
=
new
THREE
.
MeshColorFillMaterial
(
15658734
)}}}
return
d
}};
THREE
.
Light
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
255
<<
24
|
a
)};
THREE
.
AmbientLight
=
function
(
a
){
THREE
.
Light
.
call
(
this
,
a
)};
THREE
.
AmbientLight
.
prototype
=
new
THREE
.
Light
();
THREE
.
AmbientLight
.
prototype
.
constructor
=
THREE
.
AmbientLight
;
THREE
.
DirectionalLight
=
function
(
b
,
a
){
THREE
.
Light
.
call
(
this
,
b
);
this
.
position
=
new
THREE
.
Vector3
(
0
,
1
,
0
);
this
.
intensity
=
a
||
1
};
THREE
.
DirectionalLight
.
prototype
=
new
THREE
.
Light
();
THREE
.
DirectionalLight
.
prototype
.
constructor
=
THREE
.
DirectionalLight
;
THREE
.
PointLight
=
function
(
b
,
a
){
THREE
.
Light
.
call
(
this
,
b
);
this
.
position
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
this
.
intensity
=
a
||
1
};
THREE
.
DirectionalLight
.
prototype
=
new
THREE
.
Light
();
THREE
.
DirectionalLight
.
prototype
.
constructor
=
THREE
.
PointLight
;
THREE
.
Object3D
=
function
(
a
){
this
.
position
=
new
THREE
.
Vector3
();
this
.
rotation
=
new
THREE
.
Vector3
();
this
.
scale
=
new
THREE
.
Vector3
(
1
,
1
,
1
);
this
.
matrix
=
new
THREE
.
Matrix4
();
this
.
matrixTranslation
=
new
THREE
.
Matrix4
();
this
.
matrixRotation
=
new
THREE
.
Matrix4
();
this
.
matrixScale
=
new
THREE
.
Matrix4
();
this
.
screen
=
new
THREE
.
Vector3
();
this
.
autoUpdateMatrix
=
true
;
this
.
updateMatrix
=
function
(){
this
.
matrixPosition
=
THREE
.
Matrix4
.
translationMatrix
(
this
.
position
.
x
,
this
.
position
.
y
,
this
.
position
.
z
);
this
.
matrixRotation
=
THREE
.
Matrix4
.
rotationXMatrix
(
this
.
rotation
.
x
);
this
.
matrixRotation
.
multiplySelf
(
THREE
.
Matrix4
.
rotationYMatrix
(
this
.
rotation
.
y
));
this
.
matrixRotation
.
multiplySelf
(
THREE
.
Matrix4
.
rotationZMatrix
(
this
.
rotation
.
z
));
this
.
matrixScale
=
THREE
.
Matrix4
.
scaleMatrix
(
this
.
scale
.
x
,
this
.
scale
.
y
,
this
.
scale
.
z
);
this
.
matrix
.
copy
(
this
.
matrixPosition
);
this
.
matrix
.
multiplySelf
(
this
.
matrixRotation
);
this
.
matrix
.
multiplySelf
(
this
.
matrixScale
)}};
THREE
.
Particle
=
function
(
a
){
THREE
.
Object3D
.
call
(
this
);
this
.
material
=
a
instanceof
Array
?
a
:[
a
];
this
.
autoUpdateMatrix
=
false
};
THREE
.
Particle
.
prototype
=
new
THREE
.
Object3D
();
THREE
.
Particle
.
prototype
.
constructor
=
THREE
.
Particle
;
THREE
.
Line
=
function
(
b
,
a
){
THREE
.
Object3D
.
call
(
this
);
this
.
geometry
=
b
;
this
.
material
=
a
instanceof
Array
?
a
:[
a
]};
THREE
.
Line
.
prototype
=
new
THREE
.
Object3D
();
THREE
.
Line
.
prototype
.
constructor
=
THREE
.
Line
;
THREE
.
Mesh
=
function
(
b
,
a
,
c
){
THREE
.
Object3D
.
call
(
this
);
this
.
geometry
=
b
;
this
.
material
=
a
instanceof
Array
?
a
:[
a
];
this
.
flipSided
=
false
;
this
.
doubleSided
=
false
;
this
.
overdraw
=
false
;
this
.
materialFaceGroup
=
{};
this
.
sortFacesByMaterial
();
if
(
c
){
this
.
normalizeUVs
()}
this
.
geometry
.
computeBoundingBox
()};
THREE
.
Mesh
.
prototype
=
new
THREE
.
Object3D
();
THREE
.
Mesh
.
prototype
.
constructor
=
THREE
.
Mesh
;
THREE
.
Mesh
.
prototype
.
sortFacesByMaterial
=
function
(){
var
c
,
b
,
e
,
m
,
k
,
h
,
j
,
n
,
d
,
g
=
{};
function
a
(
f
){
var
i
=
[];
for
(
c
=
0
,
b
=
f
.
length
;
c
<
b
;
c
++
){
if
(
f
[
c
]
==
undefined
){
i
.
push
(
"
undefined
"
)}
else
{
i
.
push
(
f
[
c
].
toString
())}}
return
i
.
join
(
"
_
"
)}
for
(
e
=
0
,
m
=
this
.
geometry
.
faces
.
length
;
e
<
m
;
e
++
){
k
=
this
.
geometry
.
faces
[
e
];
h
=
k
.
material
;
n
=
a
(
h
);
if
(
g
[
n
]
==
undefined
){
g
[
n
]
=
{
hash
:
n
,
counter
:
0
}}
d
=
g
[
n
].
hash
+
"
_
"
+
g
[
n
].
counter
;
if
(
this
.
materialFaceGroup
[
d
]
==
undefined
){
this
.
materialFaceGroup
[
d
]
=
{
faces
:[],
material
:
h
,
vertices
:
0
}}
j
=
k
instanceof
THREE
.
Face3
?
3
:
4
;
if
(
this
.
materialFaceGroup
[
d
].
vertices
+
j
>
65535
){
g
[
n
].
counter
+=
1
;
d
=
g
[
n
].
hash
+
"
_
"
+
g
[
n
].
counter
;
if
(
this
.
materialFaceGroup
[
d
]
==
undefined
){
this
.
materialFaceGroup
[
d
]
=
{
faces
:[],
material
:
h
,
vertices
:
0
}}}
this
.
materialFaceGroup
[
d
].
faces
.
push
(
e
);
this
.
materialFaceGroup
[
d
].
vertices
+=
j
}};
THREE
.
Mesh
.
prototype
.
normalizeUVs
=
function
(){
var
e
,
a
,
b
,
d
,
c
;
for
(
e
=
0
,
a
=
this
.
geometry
.
uvs
.
length
;
e
<
a
;
e
++
){
c
=
this
.
geometry
.
uvs
[
e
];
for
(
b
=
0
,
d
=
c
.
length
;
b
<
d
;
b
++
){
if
(
c
[
b
].
u
!=
1
){
c
[
b
].
u
=
c
[
b
].
u
-
Math
.
floor
(
c
[
b
].
u
)}
if
(
c
[
b
].
v
!=
1
){
c
[
b
].
v
=
c
[
b
].
v
-
Math
.
floor
(
c
[
b
].
v
)}}}};
THREE
.
FlatShading
=
0
;
THREE
.
GouraudShading
=
1
;
THREE
.
PhongShading
=
2
;
THREE
.
NormalBlending
=
0
;
THREE
.
AdditiveBlending
=
1
;
THREE
.
SubstractiveBlending
=
2
;
THREE
.
LineBasicMaterial
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
linewidth
=
1
;
if
(
a
){
if
(
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
.
linewidth
!==
undefined
){
this
.
linewidth
=
a
.
linewidth
}}
this
.
toString
=
function
(){
return
"
THREE.LineBasicMaterial (<br/>color:
"
+
this
.
color
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>linewidth:
"
+
this
.
linewidth
+
"
<br/>)
"
}};
THREE
.
MeshBasicMaterial
=
function
(
a
){
this
.
id
=
THREE
.
MeshBasicMaterialCounter
.
value
++
;
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
wireframe
=
false
;
this
.
wireframe_linewidth
=
1
;
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
.
setHex
(
a
.
color
)}
if
(
a
.
map
!==
undefined
){
this
.
map
=
a
.
map
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}
if
(
a
.
wireframe
!==
undefined
){
this
.
wireframe
=
a
.
wireframe
}
if
(
a
.
wireframe_linewidth
!==
undefined
){
this
.
wireframe_linewidth
=
a
.
wireframe_linewidth
}}
this
.
toString
=
function
(){
return
"
THREE.MeshBasicMaterial (<br/>id:
"
+
this
.
id
+
"
<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>wireframe:
"
+
this
.
wireframe
+
"
<br/>wireframe_linewidth:
"
+
this
.
wireframe_linewidth
+
"
<br/>)
"
}};
THREE
.
MeshBasicMaterialCounter
=
{
value
:
0
};
THREE
.
MeshDepthMaterial
=
function
(
a
){
this
.
near
=
1
;
this
.
far
=
1000
;
this
.
opacity
=
1
;
this
.
wireframe
=
false
;
this
.
wireframe_linewidth
=
1
;
if
(
a
){
if
(
a
.
near
!==
undefined
){
this
.
near
=
a
.
near
}
if
(
a
.
far
!==
undefined
){
this
.
far
=
a
.
far
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
wireframe
!==
undefined
){
this
.
wireframe
=
a
.
wireframe
}
if
(
a
.
wireframe_linewidth
!==
undefined
){
this
.
wireframe_linewidth
=
a
.
wireframe_linewidth
}}
this
.
__2near
=
2
*
this
.
near
;
this
.
__farPlusNear
=
this
.
far
+
this
.
near
;
this
.
__farMinusNear
=
this
.
far
-
this
.
near
;
this
.
toString
=
function
(){
return
"
THREE.MeshDepthMaterial
"
}};
THREE
.
MeshLambertMaterial
=
function
(
a
){
this
.
id
=
THREE
.
MeshLambertMaterialCounter
.
value
++
;
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
opacity
=
1
;
this
.
shading
=
THREE
.
GouraudShading
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
wireframe
=
false
;
this
.
wireframe_linewidth
=
1
;
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
.
setHex
(
a
.
color
)}
if
(
a
.
map
!==
undefined
){
this
.
map
=
a
.
map
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
shading
!==
undefined
){
this
.
shading
=
a
.
shading
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}
if
(
a
.
wireframe
!==
undefined
){
this
.
wireframe
=
a
.
wireframe
}
if
(
a
.
wireframe_linewidth
!==
undefined
){
this
.
wireframe_linewidth
=
a
.
wireframe_linewidth
}}
this
.
toString
=
function
(){
return
"
THREE.MeshLambertMaterial (<br/>id:
"
+
this
.
id
+
"
<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>shading:
"
+
this
.
shading
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>wireframe:
"
+
this
.
wireframe
+
"
<br/>wireframe_size:
"
+
this
.
wireframe_linewidth
+
"
<br/> )
"
}};
THREE
.
MeshLambertMaterialCounter
=
{
value
:
0
};
THREE
.
MeshPhongMaterial
=
function
(
a
){
this
.
id
=
THREE
.
MeshPhongMaterialCounter
.
value
++
;
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
ambient
=
new
THREE
.
Color
(
328965
);
this
.
specular
=
new
THREE
.
Color
(
1118481
);
this
.
specular_map
=
null
;
this
.
shininess
=
30
;
this
.
opacity
=
1
;
this
.
shading
=
THREE
.
GouraudShading
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
wireframe
=
false
;
this
.
wireframe_linewidth
=
1
;
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
=
new
THREE
.
Color
(
a
.
color
)}
if
(
a
.
map
!==
undefined
){
this
.
map
=
a
.
map
}
if
(
a
.
ambient
!==
undefined
){
this
.
ambient
=
new
THREE
.
Color
(
a
.
ambient
)}
if
(
a
.
specular
!==
undefined
){
this
.
specular_color
=
new
THREE
.
Color
(
a
.
specular
)}
if
(
a
.
specular_map
!==
undefined
){
this
.
specular_map
=
a
.
specular_map
}
if
(
a
.
shininess
!==
undefined
){
this
.
shininess
=
a
.
shininess
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
shading
!==
undefined
){
this
.
shading
=
a
.
shading
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}
if
(
a
.
wireframe
!==
undefined
){
this
.
wireframe
=
a
.
wireframe
}
if
(
a
.
wireframe_linewidth
!==
undefined
){
this
.
wireframe_linewidth
=
a
.
wireframe_linewidth
}}
this
.
toString
=
function
(){
return
"
THREE.MeshPhongMaterial (<br/>id:
"
+
this
.
id
+
"
<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>ambient:
"
+
this
.
ambient
+
"
<br/>specular:
"
+
this
.
specular
+
"
<br/>specular_map:
"
+
this
.
specular_map
+
"
<br/>shininess:
"
+
this
.
shininess
+
"
<br/>alpha:
"
+
this
.
opacity
+
"
<br/>shading:
"
+
this
.
shading
+
"
<br/>wireframe:
"
+
this
.
wireframe
+
"
<br/>wireframe_linewidth:
"
+
this
.
wireframe_linewidth
+
"
<br/>
"
+
+
"
)
"
}};
THREE
.
MeshPhongMaterialCounter
=
{
value
:
0
};
THREE
.
MeshFaceMaterial
=
function
(){
this
.
toString
=
function
(){
return
"
THREE.MeshFaceMaterial
"
}};
THREE
.
ParticleBasicMaterial
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
offset
=
new
THREE
.
Vector2
();
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
.
setHex
(
a
.
color
)}
if
(
a
.
map
!==
undefined
){
this
.
map
=
a
.
map
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}}
this
.
toString
=
function
(){
return
"
THREE.ParticleBasicMaterial (<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>)
"
}};
THREE
.
ParticleCircleMaterial
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
.
setHex
(
a
.
color
)}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}}
this
.
toString
=
function
(){
return
"
THREE.ParticleCircleMaterial (<br/>color:
"
+
this
.
color
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>)
"
}};
THREE
.
ParticleDOMMaterial
=
function
(
a
){
this
.
domElement
=
a
;
this
.
toString
=
function
(){
return
"
THREE.ParticleDOMMaterial ( domElement:
"
+
this
.
domElement
+
"
)
"
}};
THREE
.
Texture
=
function
(
b
,
a
){
this
.
image
=
b
;
this
.
mapping
=
a
?
a
:
THREE
.
UVMapping
;
this
.
toString
=
function
(){
return
"
THREE.Texture (<br/>image:
"
+
this
.
image
+
"
<br/>mapping:
"
+
this
.
mapping
+
"
<br/>)
"
}};
THREE
.
UVMapping
=
0
;
THREE
.
ReflectionMap
=
1
;
THREE
.
CubeMap
=
2
;
THREE
.
Scene
=
function
(){
this
.
objects
=
[];
this
.
lights
=
[];
this
.
addObject
=
function
(
a
){
this
.
objects
.
push
(
a
)};
this
.
removeObject
=
function
(
a
){
var
b
=
this
.
objects
.
indexOf
(
a
);
if
(
b
!==-
1
){
this
.
objects
.
splice
(
b
,
1
)}};
this
.
addLight
=
function
(
a
){
this
.
lights
.
push
(
a
)};
this
.
removeLight
=
function
(
a
){
var
b
=
this
.
lights
.
indexOf
(
a
);
if
(
b
!==-
1
){
this
.
lights
.
splice
(
b
,
1
)}};
this
.
toString
=
function
(){
return
"
THREE.Scene (
"
+
this
.
objects
+
"
)
"
}};
THREE
.
Projector
=
function
(){
var
e
=
null
,
c
,
p
,
n
=
[],
b
,
f
,
l
=
[],
k
,
m
,
i
=
[],
j
,
h
,
a
=
[],
g
=
new
THREE
.
Vector4
(),
d
=
new
THREE
.
Matrix4
(),
o
=
new
THREE
.
Matrix4
();
this
.
projectScene
=
function
(
J
,
G
){
var
F
,
E
,
D
,
K
,
I
,
B
,
r
,
L
,
q
,
z
,
H
,
u
,
C
,
w
,
A
,
y
,
x
,
t
,
s
;
e
=
[];
p
=
0
,
f
=
0
,
m
=
0
,
h
=
0
;
if
(
G
.
autoUpdateMatrix
){
G
.
updateMatrix
()}
d
.
multiply
(
G
.
projectionMatrix
,
G
.
matrix
);
r
=
J
.
objects
;
for
(
F
=
0
,
E
=
r
.
length
;
F
<
E
;
F
++
){
L
=
r
[
F
];
q
=
L
.
matrix
;
if
(
L
.
autoUpdateMatrix
){
L
.
updateMatrix
()}
if
(
L
instanceof
THREE
.
Mesh
){
o
.
multiply
(
d
,
q
);
z
=
L
.
geometry
.
vertices
;
for
(
D
=
0
,
K
=
z
.
length
;
D
<
K
;
D
++
){
H
=
z
[
D
];
u
=
H
.
positionScreen
;
u
.
copy
(
H
.
position
);
o
.
transform
(
u
);
H
.
__visible
=
u
.
z
>
0
&&
u
.
z
<
1
}
w
=
L
.
geometry
.
faces
;
for
(
I
=
0
,
B
=
w
.
length
;
I
<
B
;
I
++
){
A
=
w
[
I
];
if
(
A
instanceof
THREE
.
Face3
){
y
=
z
[
A
.
a
];
x
=
z
[
A
.
b
];
t
=
z
[
A
.
c
];
if
(
y
.
__visible
&&
x
.
__visible
&&
t
.
__visible
){
if
((
L
.
doubleSided
||
(
L
.
flipSided
!=
(
t
.
positionScreen
.
x
-
y
.
positionScreen
.
x
)
*
(
x
.
positionScreen
.
y
-
y
.
positionScreen
.
y
)
-
(
t
.
positionScreen
.
y
-
y
.
positionScreen
.
y
)
*
(
x
.
positionScreen
.
x
-
y
.
positionScreen
.
x
)
<
0
))){
c
=
n
[
p
]
=
n
[
p
]
||
new
THREE
.
RenderableFace3
();
c
.
v1
.
copy
(
y
.
positionScreen
);
c
.
v2
.
copy
(
x
.
positionScreen
);
c
.
v3
.
copy
(
t
.
positionScreen
);
c
.
normalWorld
.
copy
(
A
.
normal
);
L
.
matrixRotation
.
transform
(
c
.
normalWorld
);
c
.
centroidWorld
.
copy
(
A
.
centroid
);
q
.
transform
(
c
.
centroidWorld
);
c
.
centroidScreen
.
copy
(
c
.
centroidWorld
);
d
.
transform
(
c
.
centroidScreen
);
c
.
z
=
c
.
centroidScreen
.
z
;
c
.
meshMaterial
=
L
.
material
;
c
.
faceMaterial
=
A
.
material
;
c
.
overdraw
=
L
.
overdraw
;
c
.
uvs
=
L
.
geometry
.
uvs
[
I
];
c
.
color
=
A
.
color
;
e
.
push
(
c
);
p
++
}}}
else
{
if
(
A
instanceof
THREE
.
Face4
){
y
=
z
[
A
.
a
];
x
=
z
[
A
.
b
];
t
=
z
[
A
.
c
];
s
=
z
[
A
.
d
];
if
(
y
.
__visible
&&
x
.
__visible
&&
t
.
__visible
&&
s
.
__visible
){
if
((
L
.
doubleSided
||
(
L
.
flipSided
!=
((
s
.
positionScreen
.
x
-
y
.
positionScreen
.
x
)
*
(
x
.
positionScreen
.
y
-
y
.
positionScreen
.
y
)
-
(
s
.
positionScreen
.
y
-
y
.
positionScreen
.
y
)
*
(
x
.
positionScreen
.
x
-
y
.
positionScreen
.
x
)
<
0
||
(
x
.
positionScreen
.
x
-
t
.
positionScreen
.
x
)
*
(
s
.
positionScreen
.
y
-
t
.
positionScreen
.
y
)
-
(
x
.
positionScreen
.
y
-
t
.
positionScreen
.
y
)
*
(
s
.
positionScreen
.
x
-
t
.
positionScreen
.
x
)
<
0
)))){
b
=
l
[
f
]
=
l
[
f
]
||
new
THREE
.
RenderableFace4
();
b
.
v1
.
copy
(
y
.
positionScreen
);
b
.
v2
.
copy
(
x
.
positionScreen
);
b
.
v3
.
copy
(
t
.
positionScreen
);
b
.
v4
.
copy
(
s
.
positionScreen
);
b
.
normalWorld
.
copy
(
A
.
normal
);
L
.
matrixRotation
.
transform
(
b
.
normalWorld
);
b
.
centroidWorld
.
copy
(
A
.
centroid
);
q
.
transform
(
b
.
centroidWorld
);
b
.
centroidScreen
.
copy
(
b
.
centroidWorld
);
d
.
transform
(
b
.
centroidScreen
);
b
.
z
=
b
.
centroidScreen
.
z
;
b
.
meshMaterial
=
L
.
material
;
b
.
faceMaterial
=
A
.
material
;
b
.
overdraw
=
L
.
overdraw
;
b
.
uvs
=
L
.
geometry
.
uvs
[
I
];
b
.
color
=
A
.
color
;
e
.
push
(
b
);
f
++
}}}}}}
else
{
if
(
L
instanceof
THREE
.
Line
){
o
.
multiply
(
d
,
q
);
z
=
L
.
geometry
.
vertices
;
for
(
D
=
0
,
K
=
z
.
length
;
D
<
K
;
D
++
){
H
=
z
[
D
];
u
=
H
.
positionScreen
;
u
.
copy
(
H
.
position
);
o
.
transform
(
u
);
H
.
__visible
=
u
.
z
>
0
&&
u
.
z
<
1
;
if
(
D
>
0
){
C
=
L
.
geometry
.
vertices
[
D
-
1
];
if
(
H
.
__visible
&&
C
.
__visible
){
k
=
i
[
m
]
=
i
[
m
]
||
new
THREE
.
RenderableLine
();
k
.
v1
.
copy
(
H
.
positionScreen
);
k
.
v2
.
copy
(
C
.
positionScreen
);
k
.
z
=
Math
.
max
(
H
.
positionScreen
.
z
,
C
.
positionScreen
.
z
);
k
.
material
=
L
.
material
;
e
.
push
(
k
);
m
++
}}}}
else
{
if
(
L
instanceof
THREE
.
Particle
){
g
.
set
(
L
.
position
.
x
,
L
.
position
.
y
,
L
.
position
.
z
,
1
);
d
.
transform
(
g
);
g
.
z
/=
g
.
w
;
if
(
g
.
z
>
0
&&
g
.
z
<
1
){
j
=
a
[
h
]
=
a
[
h
]
||
new
THREE
.
RenderableParticle
();
j
.
x
=
g
.
x
/
g
.
w
;
j
.
y
=
g
.
y
/
g
.
w
;
j
.
z
=
g
.
z
;
j
.
rotation
=
L
.
rotation
.
z
;
j
.
scale
.
x
=
L
.
scale
.
x
*
Math
.
abs
(
j
.
x
-
(
g
.
x
+
G
.
projectionMatrix
.
n11
)
/
(
g
.
w
+
G
.
projectionMatrix
.
n14
));
j
.
scale
.
y
=
L
.
scale
.
y
*
Math
.
abs
(
j
.
y
-
(
g
.
y
+
G
.
projectionMatrix
.
n22
)
/
(
g
.
w
+
G
.
projectionMatrix
.
n24
));
j
.
material
=
L
.
material
;
e
.
push
(
j
);
h
++
}}}}}
e
.
sort
(
function
(
M
,
v
){
return
v
.
z
-
M
.
z
});
return
e
};
this
.
unprojectVector
=
function
(
q
,
s
){
var
r
=
new
THREE
.
Matrix4
();
r
.
multiply
(
THREE
.
Matrix4
.
makeInvert
(
s
.
matrix
),
THREE
.
Matrix4
.
makeInvert
(
s
.
projectionMatrix
));
r
.
transform
(
q
);
return
q
}};
THREE
.
DOMRenderer
=
function
(){
THREE
.
Renderer
.
call
(
this
);
var
e
=
null
,
g
=
new
THREE
.
Projector
(),
b
=
document
.
createElement
(
"
div
"
),
a
,
c
,
f
,
d
;
this
.
domElement
=
b
;
this
.
setSize
=
function
(
i
,
h
){
a
=
i
;
c
=
h
;
f
=
a
/
2
;
d
=
c
/
2
};
this
.
render
=
function
(
p
,
r
){
var
q
,
h
,
i
,
n
,
o
,
s
,
l
,
k
,
j
;
e
=
g
.
projectScene
(
p
,
r
);
for
(
q
=
0
,
h
=
e
.
length
;
q
<
h
;
q
++
){
o
=
e
[
q
];
if
(
o
instanceof
THREE
.
RenderableParticle
){
k
=
o
.
x
*
f
+
f
;
j
=
o
.
y
*
d
+
d
;
for
(
i
=
0
,
n
=
o
.
material
.
length
;
i
<
n
;
i
++
){
s
=
o
.
material
[
i
];
if
(
s
instanceof
THREE
.
ParticleDOMMaterial
){
l
=
s
.
domElement
;
l
.
style
.
left
=
k
+
"
px
"
;
l
.
style
.
top
=
j
+
"
px
"
}}}}}};
THREE
.
CanvasRenderer
=
function
(){
var
n
=
null
,
x
=
new
THREE
.
Projector
(),
s
=
document
.
createElement
(
"
canvas
"
),
a
,
F
,
v
,
h
,
r
=
s
.
getContext
(
"
2d
"
),
B
=
1
,
i
=
"
#000000
"
,
L
=
"
#000000
"
,
f
=
1
,
w
=
new
THREE
.
Rectangle
(),
I
=
new
THREE
.
Rectangle
(),
m
=
new
THREE
.
Rectangle
(),
D
=
false
,
A
=
new
THREE
.
Color
(
4294967295
),
y
=
new
THREE
.
Color
(
4294967295
),
H
=
new
THREE
.
Color
(
4278190080
),
k
=
Math
.
PI
*
2
,
C
,
G
=
new
THREE
.
Vector2
(),
E
=
new
THREE
.
Vector3
(),
u
=
new
THREE
.
UV
(),
t
=
new
THREE
.
UV
(),
q
=
new
THREE
.
UV
(),
p
=
new
THREE
.
UV
(),
K
=
new
THREE
.
Vector2
(),
J
=
new
THREE
.
Vector2
();
this
.
domElement
=
s
;
this
.
autoClear
=
true
;
this
.
setSize
=
function
(
N
,
M
){
a
=
N
;
F
=
M
;
v
=
a
/
2
;
h
=
F
/
2
;
s
.
width
=
a
;
s
.
height
=
F
;
r
.
lineJoin
=
"
round
"
;
r
.
lineCap
=
"
round
"
;
w
.
set
(
-
v
,
-
h
,
v
,
h
)};
this
.
clear
=
function
(){
if
(
!
I
.
isEmpty
()){
I
.
inflate
(
1
);
I
.
minSelf
(
w
);
r
.
setTransform
(
1
,
0
,
0
,
-
1
,
v
,
h
);
r
.
clearRect
(
I
.
getX
(),
I
.
getY
(),
I
.
getWidth
(),
I
.
getHeight
());
I
.
empty
()}};
this
.
render
=
function
(
ah
,
ae
){
var
ag
,
P
,
R
,
Z
,
af
,
V
,
S
,
Y
,
W
,
T
,
ac
,
aa
,
O
,
M
,
X
,
U
,
ad
,
ab
,
Q
,
N
;
if
(
this
.
autoClear
){
this
.
clear
()}
n
=
x
.
projectScene
(
ah
,
ae
);
r
.
setTransform
(
1
,
0
,
0
,
-
1
,
v
,
h
);
r
.
fillStyle
=
"
rgba(0, 255, 255, 0.5)
"
;
r
.
fillRect
(
w
.
getX
(),
w
.
getY
(),
w
.
getWidth
(),
w
.
getHeight
());
D
=
ah
.
lights
.
length
>
0
;
if
(
D
){
e
(
ah
,
H
)}
for
(
ag
=
0
,
P
=
n
.
length
;
ag
<
P
;
ag
++
){
R
=
n
[
ag
];
m
.
empty
();
if
(
R
instanceof
THREE
.
RenderableParticle
){
W
=
R
.
x
*
v
;
T
=
R
.
y
*
h
;
for
(
Z
=
0
,
af
=
R
.
material
.
length
;
Z
<
af
;
Z
++
){
Y
=
R
.
material
[
Z
];
Y
&&
o
(
W
,
T
,
R
,
Y
,
ah
)}}
else
{
if
(
R
instanceof
THREE
.
RenderableLine
){
W
=
R
.
v1
.
x
*
v
;
T
=
R
.
v1
.
y
*
h
;
ac
=
R
.
v2
.
x
*
v
;
aa
=
R
.
v2
.
y
*
h
;
m
.
addPoint
(
W
,
T
);
m
.
addPoint
(
ac
,
aa
);
if
(
!
w
.
instersects
(
m
)){
continue
}
Z
=
0
;
af
=
R
.
material
.
length
;
while
(
Z
<
af
){
Y
=
R
.
material
[
Z
++
];
Y
&&
z
(
W
,
T
,
ac
,
aa
,
R
,
Y
,
ah
)}}
else
{
if
(
R
instanceof
THREE
.
RenderableFace3
){
R
.
v1
.
x
*=
v
;
R
.
v1
.
y
*=
h
;
R
.
v2
.
x
*=
v
;
R
.
v2
.
y
*=
h
;
R
.
v3
.
x
*=
v
;
R
.
v3
.
y
*=
h
;
if
(
R
.
overdraw
){
b
(
R
.
v1
,
R
.
v2
);
b
(
R
.
v2
,
R
.
v3
);
b
(
R
.
v3
,
R
.
v1
)}
W
=
R
.
v1
.
x
;
T
=
R
.
v1
.
y
;
ac
=
R
.
v2
.
x
;
aa
=
R
.
v2
.
y
;
O
=
R
.
v3
.
x
;
M
=
R
.
v3
.
y
;
m
.
addPoint
(
W
,
T
);
m
.
addPoint
(
ac
,
aa
);
m
.
addPoint
(
O
,
M
);
if
(
!
w
.
instersects
(
m
)){
continue
}
Z
=
0
;
af
=
R
.
meshMaterial
.
length
;
while
(
Z
<
af
){
Y
=
R
.
meshMaterial
[
Z
++
];
if
(
Y
instanceof
THREE
.
MeshFaceMaterial
){
V
=
0
;
S
=
R
.
faceMaterial
.
length
;
while
(
V
<
S
){
Y
=
R
.
faceMaterial
[
V
++
];
Y
&&
l
(
W
,
T
,
ac
,
aa
,
O
,
M
,
R
,
Y
,
ah
)}
continue
}
l
(
W
,
T
,
ac
,
aa
,
O
,
M
,
R
,
Y
,
ah
)}}
else
{
if
(
R
instanceof
THREE
.
RenderableFace4
){
R
.
v1
.
x
*=
v
;
R
.
v1
.
y
*=
h
;
R
.
v2
.
x
*=
v
;
R
.
v2
.
y
*=
h
;
R
.
v3
.
x
*=
v
;
R
.
v3
.
y
*=
h
;
R
.
v4
.
x
*=
v
;
R
.
v4
.
y
*=
h
;
K
.
copy
(
R
.
v2
);
J
.
copy
(
R
.
v4
);
if
(
R
.
overdraw
){
b
(
R
.
v1
,
R
.
v2
);
b
(
R
.
v2
,
R
.
v4
);
b
(
R
.
v4
,
R
.
v1
)}
W
=
R
.
v1
.
x
;
T
=
R
.
v1
.
y
;
ac
=
R
.
v2
.
x
;
aa
=
R
.
v2
.
y
;
X
=
R
.
v4
.
x
;
U
=
R
.
v4
.
y
;
if
(
R
.
overdraw
){
b
(
R
.
v3
,
K
);
b
(
R
.
v3
,
J
)}
O
=
R
.
v3
.
x
;
M
=
R
.
v3
.
y
;
ad
=
K
.
x
;
ab
=
K
.
y
;
Q
=
J
.
x
;
N
=
J
.
y
;
m
.
addPoint
(
W
,
T
);
m
.
addPoint
(
ac
,
aa
);
m
.
addPoint
(
O
,
M
);
m
.
addPoint
(
X
,
U
);
if
(
!
w
.
instersects
(
m
)){
continue
}
Z
=
0
;
af
=
R
.
meshMaterial
.
length
;
while
(
Z
<
af
){
Y
=
R
.
meshMaterial
[
Z
++
];
if
(
Y
instanceof
THREE
.
MeshFaceMaterial
){
V
=
0
;
S
=
R
.
faceMaterial
.
length
;
while
(
V
<
S
){
Y
=
R
.
faceMaterial
[
V
++
];
Y
&&
j
(
W
,
T
,
ac
,
aa
,
O
,
M
,
X
,
U
,
ad
,
ab
,
Q
,
N
,
R
,
Y
,
ah
)}
continue
}
j
(
W
,
T
,
ac
,
aa
,
O
,
M
,
X
,
U
,
ad
,
ab
,
Q
,
N
,
R
,
Y
,
ah
)}}}}}
I
.
addRectangle
(
m
)}
r
.
lineWidth
=
1
;
r
.
strokeStyle
=
"
rgba( 255, 0, 0, 0.5 )
"
;
r
.
strokeRect
(
I
.
getX
(),
I
.
getY
(),
I
.
getWidth
(),
I
.
getHeight
());
r
.
setTransform
(
1
,
0
,
0
,
1
,
0
,
0
)};
function
e
(
S
,
P
){
var
O
,
R
,
N
,
M
,
Q
=
S
.
lights
;
P
.
setRGBA
(
0
,
0
,
0
,
1
);
for
(
O
=
0
,
R
=
Q
.
length
;
O
<
R
;
O
++
){
N
=
Q
[
O
];
M
=
N
.
color
;
if
(
N
instanceof
THREE
.
AmbientLight
){
P
.
r
+=
M
.
r
;
P
.
g
+=
M
.
g
;
P
.
b
+=
M
.
b
}}}
function
g
(
T
,
R
,
P
){
var
O
,
S
,
N
,
M
,
Q
=
T
.
lights
;
for
(
O
=
0
,
S
=
Q
.
length
;
O
<
S
;
O
++
){
N
=
Q
[
O
];
M
=
N
.
color
;
if
(
N
instanceof
THREE
.
DirectionalLight
){
P
.
r
+=
M
.
r
;
P
.
g
+=
M
.
g
;
P
.
b
+=
M
.
b
}
else
{
if
(
N
instanceof
THREE
.
PointLight
){
P
.
r
+=
M
.
r
;
P
.
g
+=
M
.
g
;
P
.
b
+=
M
.
b
}}}}
function
d
(
T
,
R
,
P
){
var
O
,
S
,
N
,
M
,
Q
;
lights
=
T
.
lights
;
for
(
O
=
0
,
S
=
lights
.
length
;
O
<
S
;
O
++
){
N
=
lights
[
O
];
M
=
N
.
color
;
if
(
N
instanceof
THREE
.
DirectionalLight
){
Q
=
R
.
normalWorld
.
dot
(
N
.
position
)
*
N
.
intensity
;
if
(
Q
>
0
){
P
.
r
+=
M
.
r
*
Q
;
P
.
g
+=
M
.
g
*
Q
;
P
.
b
+=
M
.
b
*
Q
}}
else
{
if
(
N
instanceof
THREE
.
PointLight
){
E
.
sub
(
N
.
position
,
R
.
centroidWorld
);
E
.
normalize
();
Q
=
R
.
normalWorld
.
dot
(
E
)
*
N
.
intensity
;
if
(
Q
>
0
){
P
.
r
+=
M
.
r
*
Q
;
P
.
g
+=
M
.
g
*
Q
;
P
.
b
+=
M
.
b
*
Q
}}}}}
function
o
(
O
,
N
,
R
,
U
,
T
){
var
M
,
Z
,
X
,
W
,
S
,
Q
,
V
,
Y
,
P
;
if
(
B
!=
U
.
opacity
){
r
.
globalAlpha
=
B
=
U
.
opacity
}
if
(
U
instanceof
THREE
.
ParticleBasicMaterial
){
V
=
U
.
bitmap
;
Y
=
V
.
width
/
2
;
P
=
V
.
height
/
2
;
X
=
R
.
scale
.
x
*
v
;
W
=
R
.
scale
.
y
*
h
;
M
=
X
*
Y
;
Z
=
W
*
P
;
S
=
U
.
offset
.
x
*
X
;
Q
=
U
.
offset
.
y
*
W
;
m
.
set
(
O
+
S
-
M
,
N
+
Q
-
Z
,
O
+
S
+
M
,
N
+
Q
+
Z
);
if
(
!
w
.
instersects
(
m
)){
return
}
r
.
save
();
r
.
translate
(
O
,
N
);
r
.
rotate
(
-
R
.
rotation
);
r
.
scale
(
X
,
-
W
);
r
.
translate
(
-
Y
+
U
.
offset
.
x
,
-
P
-
U
.
offset
.
y
);
r
.
drawImage
(
V
,
0
,
0
);
r
.
restore
();
r
.
beginPath
();
r
.
moveTo
(
O
-
10
,
N
);
r
.
lineTo
(
O
+
10
,
N
);
r
.
moveTo
(
O
,
N
-
10
);
r
.
lineTo
(
O
,
N
+
10
);
r
.
closePath
();
r
.
strokeStyle
=
"
rgb(255,255,0)
"
;
r
.
stroke
()}
else
{
if
(
U
instanceof
THREE
.
ParticleCircleMaterial
){
if
(
D
){
y
.
copyRGB
(
H
);
g
(
T
,
R
,
y
);
A
.
copyRGBA
(
U
.
color
);
A
.
multiplySelfRGB
(
y
);
A
.
updateStyleString
()}
else
{
A
.
__styleString
=
U
.
color
.
__styleString
}
M
=
R
.
scale
.
x
*
v
;
Z
=
R
.
scale
.
y
*
h
;
m
.
set
(
O
-
M
,
N
-
Z
,
O
+
M
,
N
+
Z
);
if
(
!
w
.
instersects
(
m
)){
return
}
r
.
save
();
r
.
translate
(
O
,
N
);
r
.
rotate
(
-
R
.
rotation
);
r
.
scale
(
M
,
Z
);
r
.
beginPath
();
r
.
arc
(
0
,
0
,
1
,
0
,
k
,
true
);
r
.
closePath
();
r
.
fillStyle
=
A
.
__styleString
;
r
.
fill
();
r
.
restore
()}}}
function
z
(
M
,
S
,
O
,
N
,
P
,
Q
,
R
){
if
(
B
!=
Q
.
opacity
){
r
.
globalAlpha
=
B
=
Q
.
opacity
}
if
(
Q
instanceof
THREE
.
LineBasicMaterial
){
r
.
beginPath
();
r
.
moveTo
(
M
,
S
);
r
.
lineTo
(
O
,
N
);
r
.
closePath
();
A
.
__styleString
=
Q
.
color
.
__styleString
;
if
(
f
!=
Q
.
linewidth
){
r
.
lineWidth
=
f
=
Q
.
linewidth
}
if
(
i
!=
A
.
__styleString
){
r
.
strokeStyle
=
i
=
A
.
__styleString
}
r
.
stroke
();
m
.
inflate
(
Q
.
linewidth
*
2
)}}
function
l
(
O
,
N
,
M
,
X
,
U
,
T
,
Q
,
S
,
R
){
var
V
,
W
,
P
;
if
(
B
!=
S
.
opacity
){
r
.
globalAlpha
=
B
=
S
.
opacity
}
if
(
S
.
map
){
V
=
S
.
map
.
image
;
W
=
V
.
width
-
1
;
P
=
V
.
height
-
1
;
u
.
copy
(
Q
.
uvs
[
0
]);
t
.
copy
(
Q
.
uvs
[
1
]);
q
.
copy
(
Q
.
uvs
[
2
]);
u
.
u
*=
W
;
u
.
v
*=
P
;
t
.
u
*=
W
;
t
.
v
*=
P
;
q
.
u
*=
W
;
q
.
v
*=
P
;
c
(
V
,
O
,
N
,
M
,
X
,
U
,
T
,
u
.
u
,
u
.
v
,
t
.
u
,
t
.
v
,
q
.
u
,
q
.
v
);
return
}
r
.
beginPath
();
r
.
moveTo
(
O
,
N
);
r
.
lineTo
(
M
,
X
);
r
.
lineTo
(
U
,
T
);
r
.
lineTo
(
O
,
N
);
r
.
closePath
();
if
(
S
instanceof
THREE
.
MeshBasicMaterial
){
A
.
__styleString
=
S
.
color
.
__styleString
}
else
{
if
(
S
instanceof
THREE
.
MeshDepthMaterial
){
C
=
1
-
(
S
.
__2near
/
(
S
.
__farPlusNear
-
Q
.
z
*
S
.
__farMinusNear
));
A
.
setRGBA
(
C
,
C
,
C
,
1
)}
else
{
if
(
S
instanceof
THREE
.
MeshLambertMaterial
){
if
(
D
){
y
.
copyRGB
(
H
);
d
(
R
,
Q
,
y
);
A
.
copyRGBA
(
S
.
color
);
A
.
multiplySelfRGB
(
y
);
A
.
updateStyleString
()}
else
{
A
.
__styleString
=
S
.
color
.
__styleString
}}}}
if
(
S
.
wireframe
){
if
(
f
!=
S
.
wireframe_linewidth
){
r
.
lineWidth
=
f
=
S
.
wireframe_linewidth
}
if
(
i
!=
A
.
__styleString
){
r
.
strokeStyle
=
i
=
A
.
__styleString
}
r
.
stroke
();
m
.
inflate
(
S
.
wireframe_linewidth
*
2
)}
else
{
if
(
L
!=
A
.
__styleString
){
r
.
fillStyle
=
L
=
A
.
__styleString
}
r
.
fill
()}}
function
j
(
S
,
R
,
aa
,
Y
,
N
,
M
,
U
,
T
,
ab
,
Z
,
P
,
O
,
Q
,
W
,
ac
){
var
ad
,
V
,
X
;
if
(
B
!=
W
.
opacity
){
r
.
globalAlpha
=
B
=
W
.
opacity
}
if
(
W
.
map
){
ad
=
W
.
map
.
image
;
V
=
ad
.
width
-
1
;
X
=
ad
.
height
-
1
;
u
.
copy
(
Q
.
uvs
[
0
]);
t
.
copy
(
Q
.
uvs
[
1
]);
q
.
copy
(
Q
.
uvs
[
2
]);
p
.
copy
(
Q
.
uvs
[
3
]);
u
.
u
*=
V
;
u
.
v
*=
X
;
t
.
u
*=
V
;
t
.
v
*=
X
;
q
.
u
*=
V
;
q
.
v
*=
X
;
p
.
u
*=
V
;
p
.
v
*=
X
;
c
(
ad
,
S
,
R
,
aa
,
Y
,
U
,
T
,
u
.
u
,
u
.
v
,
t
.
u
,
t
.
v
,
p
.
u
,
p
.
v
);
c
(
ad
,
ab
,
Z
,
N
,
M
,
P
,
O
,
t
.
u
,
t
.
v
,
q
.
u
,
q
.
v
,
p
.
u
,
p
.
v
);
return
}
r
.
beginPath
();
r
.
moveTo
(
S
,
R
);
r
.
lineTo
(
aa
,
Y
);
r
.
lineTo
(
N
,
M
);
r
.
lineTo
(
U
,
T
);
r
.
lineTo
(
S
,
R
);
r
.
closePath
();
if
(
W
instanceof
THREE
.
MeshBasicMaterial
){
A
.
__styleString
=
W
.
color
.
__styleString
}
else
{
if
(
W
instanceof
THREE
.
MeshDepthMaterial
){
C
=
1
-
(
W
.
__2near
/
(
W
.
__farPlusNear
-
Q
.
z
*
W
.
__farMinusNear
));
A
.
setRGBA
(
C
,
C
,
C
,
1
)}
else
{
if
(
W
instanceof
THREE
.
MeshLambertMaterial
){
if
(
D
){
y
.
copyRGB
(
H
);
d
(
ac
,
Q
,
y
);
A
.
copyRGBA
(
W
.
color
);
A
.
multiplySelfRGB
(
y
);
A
.
updateStyleString
()}
else
{
A
.
__styleString
=
W
.
color
.
__styleString
}}}}
if
(
W
.
wireframe
){
if
(
f
!=
W
.
wireframe_linewidth
){
r
.
lineWidth
=
f
=
W
.
wireframe_linewidth
}
if
(
i
!=
A
.
__styleString
){
r
.
strokeStyle
=
i
=
A
.
__styleString
}
r
.
stroke
();
m
.
inflate
(
W
.
wireframe_linewidth
*
2
)}
else
{
if
(
L
!=
A
.
__styleString
){
r
.
fillStyle
=
L
=
A
.
__styleString
}
r
.
fill
()}}
function
c
(
af
,
Z
,
R
,
X
,
Q
,
V
,
O
,
W
,
P
,
U
,
N
,
T
,
M
){
r
.
beginPath
();
r
.
moveTo
(
Z
,
R
);
r
.
lineTo
(
X
,
Q
);
r
.
lineTo
(
V
,
O
);
r
.
closePath
();
X
-=
Z
;
Q
-=
R
;
V
-=
Z
;
O
-=
R
;
U
-=
W
;
N
-=
P
;
T
-=
W
;
M
-=
P
;
var
S
=
1
/
(
U
*
M
-
T
*
N
),
ae
=
(
M
*
X
-
N
*
V
)
*
S
,
ad
=
(
M
*
Q
-
N
*
O
)
*
S
,
ac
=
(
U
*
V
-
T
*
X
)
*
S
,
ab
=
(
U
*
O
-
T
*
Q
)
*
S
,
aa
=
Z
-
ae
*
W
-
ac
*
P
,
Y
=
R
-
ad
*
W
-
ab
*
P
;
r
.
save
();
r
.
transform
(
ae
,
ad
,
ac
,
ab
,
aa
,
Y
);
r
.
clip
();
r
.
drawImage
(
af
,
0
,
0
);
r
.
restore
()}
function
b
(
N
,
M
){
G
.
sub
(
M
,
N
);
G
.
unit
();
G
.
multiplyScalar
(
0.75
);
M
.
addSelf
(
G
);
N
.
subSelf
(
G
)}};
THREE
.
SVGRenderer
=
function
(){
var
y
=
null
,
r
=
new
THREE
.
Projector
(),
t
=
document
.
createElementNS
(
"
http://www.w3.org/2000/svg
"
,
"
svg
"
),
b
,
o
,
p
,
s
,
A
=
new
THREE
.
Rectangle
(),
w
=
new
THREE
.
Rectangle
(),
i
=
false
,
k
=
new
THREE
.
Color
(
4294967295
),
v
=
new
THREE
.
Color
(
4294967295
),
c
=
new
THREE
.
Color
(
4294967295
),
x
,
g
=
new
THREE
.
Vector3
(),
d
=
[],
l
=
[],
C
,
n
,
f
,
B
=
1
;
this
.
domElement
=
t
;
this
.
autoClear
=
true
;
this
.
setQuality
=
function
(
D
){
switch
(
D
){
case
"
high
"
:
B
=
1
;
break
;
case
"
low
"
:
B
=
0
;
break
}};
this
.
setSize
=
function
(
E
,
D
){
b
=
E
;
o
=
D
;
p
=
b
/
2
;
s
=
o
/
2
;
t
.
setAttribute
(
"
viewBox
"
,(
-
p
)
+
"
"
+
(
-
s
)
+
"
"
+
b
+
"
"
+
o
);
t
.
setAttribute
(
"
width
"
,
b
);
t
.
setAttribute
(
"
height
"
,
o
);
A
.
set
(
-
p
,
-
s
,
p
,
s
)};
this
.
clear
=
function
(){
while
(
t
.
childNodes
.
length
>
0
){
t
.
removeChild
(
t
.
childNodes
[
0
])}};
this
.
render
=
function
(
U
,
R
){
var
T
,
F
,
O
,
S
,
K
,
H
,
G
,
N
,
L
,
I
,
Q
,
P
,
E
,
D
,
M
,
J
;
if
(
this
.
autoClear
){
this
.
clear
()}
y
=
r
.
projectScene
(
U
,
R
);
n
=
0
;
f
=
0
;
i
=
U
.
lights
.
length
>
0
;
if
(
i
){
z
(
U
,
c
)}
for
(
T
=
0
,
F
=
y
.
length
;
T
<
F
;
T
++
){
G
=
y
[
T
];
w
.
empty
();
if
(
G
instanceof
THREE
.
RenderableParticle
){
L
=
G
.
x
*
p
;
I
=
G
.
y
*-
s
;
for
(
O
=
0
,
S
=
G
.
material
.
length
;
O
<
S
;
O
++
){
N
=
G
.
material
[
O
];
N
&&
j
(
L
,
I
,
G
,
N
,
U
)}}
else
{
if
(
G
instanceof
THREE
.
RenderableFace3
){
L
=
G
.
v1
.
x
*
p
;
I
=
G
.
v1
.
y
*-
s
;
Q
=
G
.
v2
.
x
*
p
;
P
=
G
.
v2
.
y
*-
s
;
E
=
G
.
v3
.
x
*
p
;
D
=
G
.
v3
.
y
*-
s
;
w
.
addPoint
(
L
,
I
);
w
.
addPoint
(
Q
,
P
);
w
.
addPoint
(
E
,
D
);
if
(
!
A
.
instersects
(
w
)){
continue
}
O
=
0
;
S
=
G
.
meshMaterial
.
length
;
while
(
O
<
S
){
N
=
G
.
meshMaterial
[
O
++
];
if
(
N
instanceof
THREE
.
MeshFaceMaterial
){
K
=
0
;
H
=
G
.
faceMaterial
.
length
;
while
(
K
<
H
){
N
=
G
.
faceMaterial
[
K
++
];
N
&&
h
(
L
,
I
,
Q
,
P
,
E
,
D
,
G
,
N
,
U
)}
continue
}
N
&&
h
(
L
,
I
,
Q
,
P
,
E
,
D
,
G
,
N
,
U
)}}
else
{
if
(
G
instanceof
THREE
.
RenderableFace4
){
L
=
G
.
v1
.
x
*
p
;
I
=
G
.
v1
.
y
*-
s
;
Q
=
G
.
v2
.
x
*
p
;
P
=
G
.
v2
.
y
*-
s
;
E
=
G
.
v3
.
x
*
p
;
D
=
G
.
v3
.
y
*-
s
;
M
=
G
.
v4
.
x
*
p
;
J
=
G
.
v4
.
y
*-
s
;
w
.
addPoint
(
L
,
I
);
w
.
addPoint
(
Q
,
P
);
w
.
addPoint
(
E
,
D
);
w
.
addPoint
(
M
,
J
);
if
(
!
A
.
instersects
(
w
)){
continue
}
O
=
0
;
S
=
G
.
meshMaterial
.
length
;
while
(
O
<
S
){
N
=
G
.
meshMaterial
[
O
++
];
if
(
N
instanceof
THREE
.
MeshFaceMaterial
){
K
=
0
;
H
=
G
.
faceMaterial
.
length
;
while
(
K
<
H
){
N
=
G
.
faceMaterial
[
K
++
];
N
&&
e
(
L
,
I
,
Q
,
P
,
E
,
D
,
M
,
J
,
G
,
N
,
U
)}
continue
}
N
&&
e
(
L
,
I
,
Q
,
P
,
E
,
D
,
M
,
J
,
G
,
N
,
U
)}}}}}};
function
z
(
H
,
F
){
var
E
,
G
,
D
;
F
.
setRGBA
(
0
,
0
,
0
,
1
);
for
(
E
=
0
,
G
=
H
.
lights
.
length
;
E
<
G
;
E
++
){
D
=
H
.
lights
[
E
];
if
(
D
instanceof
THREE
.
AmbientLight
){
F
.
r
+=
D
.
color
.
r
;
F
.
g
+=
D
.
color
.
g
;
F
.
b
+=
D
.
color
.
b
}}}
function
q
(
I
,
G
,
F
){
var
E
,
H
,
D
;
for
(
E
=
0
,
H
=
I
.
lights
.
length
;
E
<
H
;
E
++
){
D
=
I
.
lights
[
E
];
if
(
D
instanceof
THREE
.
DirectionalLight
){
F
.
r
+=
D
.
color
.
r
;
F
.
g
+=
D
.
color
.
g
;
F
.
b
+=
D
.
color
.
b
}
else
{
if
(
D
instanceof
THREE
.
PointLight
){
F
.
r
+=
D
.
color
.
r
;
F
.
g
+=
D
.
color
.
g
;
F
.
b
+=
D
.
color
.
b
}}}}
function
a
(
J
,
H
,
F
){
var
E
,
I
,
D
,
G
;
for
(
E
=
0
,
I
=
J
.
lights
.
length
;
E
<
I
;
E
++
){
D
=
J
.
lights
[
E
];
if
(
D
instanceof
THREE
.
DirectionalLight
){
G
=
H
.
normalWorld
.
dot
(
D
.
position
)
*
D
.
intensity
;
if
(
G
>
0
){
F
.
r
+=
D
.
color
.
r
*
G
;
F
.
g
+=
D
.
color
.
g
*
G
;
F
.
b
+=
D
.
color
.
b
*
G
}}
else
{
if
(
D
instanceof
THREE
.
PointLight
){
g
.
sub
(
D
.
position
,
H
.
centroidWorld
);
g
.
normalize
();
G
=
H
.
normalWorld
.
dot
(
g
)
*
D
.
intensity
;
if
(
G
>
0
){
F
.
r
+=
D
.
color
.
r
*
G
;
F
.
g
+=
D
.
color
.
g
*
G
;
F
.
b
+=
D
.
color
.
b
*
G
}}}}}
function
j
(
D
,
H
,
E
,
F
,
G
){
C
=
u
(
f
++
);
C
.
setAttribute
(
"
cx
"
,
D
);
C
.
setAttribute
(
"
cy
"
,
H
);
C
.
setAttribute
(
"
r
"
,
E
.
scale
.
x
*
p
);
if
(
F
instanceof
THREE
.
ParticleCircleMaterial
){
if
(
i
){
v
.
copyRGB
(
c
);
q
(
G
,
E
,
v
);
k
.
copyRGBA
(
F
.
color
);
k
.
multiplySelfRGB
(
v
);
k
.
updateStyleString
()}
else
{
k
=
F
.
color
}
C
.
setAttribute
(
"
style
"
,
"
fill:
"
+
k
.
__styleString
)}
t
.
appendChild
(
C
)}
function
h
(
F
,
E
,
D
,
L
,
K
,
J
,
G
,
I
,
H
){
C
=
m
(
n
++
);
C
.
setAttribute
(
"
d
"
,
"
M
"
+
F
+
"
"
+
E
+
"
L
"
+
D
+
"
"
+
L
+
"
L
"
+
K
+
"
,
"
+
J
+
"
z
"
);
if
(
I
instanceof
THREE
.
MeshBasicMaterial
){
k
.
__styleString
=
I
.
color
.
__styleString
}
else
{
if
(
I
instanceof
THREE
.
MeshDepthMaterial
){
x
=
1
-
(
I
.
__2near
/
(
I
.
__farPlusNear
-
G
.
z
*
I
.
__farMinusNear
));
k
.
setRGBA
(
x
,
x
,
x
,
1
)}
else
{
if
(
I
instanceof
THREE
.
MeshLambertMaterial
){
if
(
i
){
v
.
copyRGB
(
c
);
a
(
H
,
G
,
v
);
k
.
copyRGBA
(
I
.
color
);
k
.
multiplySelfRGB
(
v
);
k
.
updateStyleString
()}
else
{
k
.
__styleString
=
I
.
color
.
__styleString
}}}}
if
(
I
.
wireframe
){
C
.
setAttribute
(
"
style
"
,
"
fill: none; stroke:
"
+
k
.
__styleString
+
"
; stroke-width:
"
+
I
.
wireframe_linewidth
+
"
; stroke-opacity:
"
+
I
.
opacity
+
"
; stroke-linecap: round; stroke-linejoin: round
"
)}
else
{
C
.
setAttribute
(
"
style
"
,
"
fill:
"
+
k
.
__styleString
+
"
; fill-opacity:
"
+
I
.
opacity
)}
t
.
appendChild
(
C
)}
function
e
(
H
,
F
,
D
,
N
,
M
,
L
,
G
,
E
,
I
,
K
,
J
){
C
=
m
(
n
++
);
C
.
setAttribute
(
"
d
"
,
"
M
"
+
H
+
"
"
+
F
+
"
L
"
+
D
+
"
"
+
N
+
"
L
"
+
M
+
"
,
"
+
L
+
"
L
"
+
G
+
"
,
"
+
E
+
"
z
"
);
if
(
K
instanceof
THREE
.
MeshBasicMaterial
){
k
.
__styleString
=
K
.
color
.
__styleString
}
else
{
if
(
K
instanceof
THREE
.
MeshLambertMaterial
){
if
(
i
){
v
.
copyRGB
(
c
);
a
(
J
,
I
,
v
);
k
.
copyRGBA
(
K
.
color
);
k
.
multiplySelfRGB
(
v
);
k
.
updateStyleString
()}
else
{
k
.
__styleString
=
K
.
color
.
__styleString
}}}
if
(
K
.
wireframe
){
C
.
setAttribute
(
"
style
"
,
"
fill: none; stroke:
"
+
k
.
__styleString
+
"
; stroke-width:
"
+
K
.
wireframe_linewidth
+
"
; stroke-opacity:
"
+
K
.
opacity
+
"
; stroke-linecap: round; stroke-linejoin: round
"
)}
else
{
C
.
setAttribute
(
"
style
"
,
"
fill:
"
+
k
.
__styleString
+
"
; fill-opacity:
"
+
K
.
opacity
)}
t
.
appendChild
(
C
)}
function
m
(
D
){
if
(
d
[
D
]
==
null
){
d
[
D
]
=
document
.
createElementNS
(
"
http://www.w3.org/2000/svg
"
,
"
path
"
);
if
(
B
==
0
){
d
[
D
].
setAttribute
(
"
shape-rendering
"
,
"
crispEdges
"
)}
return
d
[
D
]}
return
d
[
D
]}
function
u
(
D
){
if
(
l
[
D
]
==
null
){
l
[
D
]
=
document
.
createElementNS
(
"
http://www.w3.org/2000/svg
"
,
"
circle
"
);
if
(
B
==
0
){
l
[
D
].
setAttribute
(
"
shape-rendering
"
,
"
crispEdges
"
)}
return
l
[
D
]}
return
l
[
D
]}};
THREE
.
WebGLRenderer
=
function
(
q
){
var
h
=
document
.
createElement
(
"
canvas
"
),
f
,
n
,
k
=
new
THREE
.
Matrix4
(),
d
,
g
=
0
,
c
=
1
,
s
=
2
,
o
=
3
,
l
=
b
(
q
,
5
);
this
.
domElement
=
h
;
this
.
autoClear
=
true
;
a
();
i
(
l
.
directional
,
l
.
point
);
function
b
(
x
,
y
){
if
(
x
){
var
u
,
w
,
t
,
v
=
pointLights
=
maxDirLights
=
maxPointLights
=
0
;
for
(
u
=
0
,
w
=
x
.
lights
.
length
;
u
<
w
;
u
++
){
t
=
x
.
lights
[
u
];
if
(
t
instanceof
THREE
.
DirectionalLight
){
v
++
}
if
(
t
instanceof
THREE
.
PointLight
){
pointLights
++
}}
if
((
pointLights
+
v
)
<=
y
){
maxDirLights
=
v
;
maxPointLights
=
pointLights
}
else
{
maxDirLights
=
Math
.
ceil
(
y
*
v
/
(
pointLights
+
v
));
maxPointLights
=
y
-
maxDirLights
}
return
{
directional
:
maxDirLights
,
point
:
maxPointLights
}}
return
{
directional
:
1
,
point
:
y
-
1
}}
this
.
setSize
=
function
(
u
,
t
){
h
.
width
=
u
;
h
.
height
=
t
;
f
.
viewport
(
0
,
0
,
h
.
width
,
h
.
height
)};
this
.
clear
=
function
(){
f
.
clear
(
f
.
COLOR_BUFFER_BIT
|
f
.
DEPTH_BUFFER_BIT
)};
this
.
setupLights
=
function
(
z
){
var
w
,
D
,
x
,
u
,
A
,
E
,
v
=
[],
B
=
[],
C
=
[],
t
=
[],
y
=
[];
f
.
uniform1i
(
n
.
enableLighting
,
z
.
lights
.
length
);
for
(
w
=
0
,
D
=
z
.
lights
.
length
;
w
<
D
;
w
++
){
x
=
z
.
lights
[
w
];
if
(
x
instanceof
THREE
.
AmbientLight
){
v
.
push
(
x
)}
else
{
if
(
x
instanceof
THREE
.
DirectionalLight
){
C
.
push
(
x
)}
else
{
if
(
x
instanceof
THREE
.
PointLight
){
B
.
push
(
x
)}}}}
u
=
A
=
E
=
0
;
for
(
w
=
0
,
D
=
v
.
length
;
w
<
D
;
w
++
){
u
+=
v
[
w
].
color
.
r
;
A
+=
v
[
w
].
color
.
g
;
E
+=
v
[
w
].
color
.
b
}
f
.
uniform3f
(
n
.
ambientLightColor
,
u
,
A
,
E
);
t
=
[];
y
=
[];
for
(
w
=
0
,
D
=
C
.
length
;
w
<
D
;
w
++
){
x
=
C
[
w
];
t
.
push
(
x
.
color
.
r
*
x
.
intensity
);
t
.
push
(
x
.
color
.
g
*
x
.
intensity
);
t
.
push
(
x
.
color
.
b
*
x
.
intensity
);
y
.
push
(
x
.
position
.
x
);
y
.
push
(
x
.
position
.
y
);
y
.
push
(
x
.
position
.
z
)}
if
(
C
.
length
){
f
.
uniform1i
(
n
.
directionalLightNumber
,
C
.
length
);
f
.
uniform3fv
(
n
.
directionalLightDirection
,
y
);
f
.
uniform3fv
(
n
.
directionalLightColor
,
t
)}
t
=
[];
y
=
[];
for
(
w
=
0
,
D
=
B
.
length
;
w
<
D
;
w
++
){
x
=
B
[
w
];
t
.
push
(
x
.
color
.
r
*
x
.
intensity
);
t
.
push
(
x
.
color
.
g
*
x
.
intensity
);
t
.
push
(
x
.
color
.
b
*
x
.
intensity
);
y
.
push
(
x
.
position
.
x
);
y
.
push
(
x
.
position
.
y
);
y
.
push
(
x
.
position
.
z
)}
if
(
B
.
length
){
f
.
uniform1i
(
n
.
pointLightNumber
,
B
.
length
);
f
.
uniform3fv
(
n
.
pointLightPosition
,
y
);
f
.
uniform3fv
(
n
.
pointLightColor
,
t
)}};
this
.
createBuffers
=
function
(
M
,
K
){
var
I
,
A
,
C
,
z
,
H
,
L
,
y
,
w
,
v
,
u
,
t
,
x
=
M
.
materialFaceGroup
[
K
],
E
=
[],
G
=
[],
D
=
[],
J
=
[],
F
=
[],
B
=
0
;
for
(
I
=
0
,
A
=
x
.
faces
.
length
;
I
<
A
;
I
++
){
C
=
x
.
faces
[
I
];
z
=
M
.
geometry
.
faces
[
C
];
H
=
z
.
vertexNormals
;
L
=
z
.
normal
;
y
=
M
.
geometry
.
uvs
[
C
];
if
(
z
instanceof
THREE
.
Face3
){
w
=
M
.
geometry
.
vertices
[
z
.
a
].
position
;
v
=
M
.
geometry
.
vertices
[
z
.
b
].
position
;
u
=
M
.
geometry
.
vertices
[
z
.
c
].
position
;
D
.
push
(
w
.
x
,
w
.
y
,
w
.
z
);
D
.
push
(
v
.
x
,
v
.
y
,
v
.
z
);
D
.
push
(
u
.
x
,
u
.
y
,
u
.
z
);
if
(
H
.
length
==
3
){
J
.
push
(
H
[
0
].
x
,
H
[
0
].
y
,
H
[
0
].
z
);
J
.
push
(
H
[
1
].
x
,
H
[
1
].
y
,
H
[
1
].
z
);
J
.
push
(
H
[
2
].
x
,
H
[
2
].
y
,
H
[
2
].
z
)}
else
{
J
.
push
(
L
.
x
,
L
.
y
,
L
.
z
);
J
.
push
(
L
.
x
,
L
.
y
,
L
.
z
);
J
.
push
(
L
.
x
,
L
.
y
,
L
.
z
)}
if
(
y
){
F
.
push
(
y
[
0
].
u
,
y
[
0
].
v
);
F
.
push
(
y
[
1
].
u
,
y
[
1
].
v
);
F
.
push
(
y
[
2
].
u
,
y
[
2
].
v
)}
E
.
push
(
B
,
B
+
1
,
B
+
2
);
G
.
push
(
B
,
B
+
1
);
G
.
push
(
B
,
B
+
2
);
G
.
push
(
B
+
1
,
B
+
2
);
B
+=
3
}
else
{
if
(
z
instanceof
THREE
.
Face4
){
w
=
M
.
geometry
.
vertices
[
z
.
a
].
position
;
v
=
M
.
geometry
.
vertices
[
z
.
b
].
position
;
u
=
M
.
geometry
.
vertices
[
z
.
c
].
position
;
t
=
M
.
geometry
.
vertices
[
z
.
d
].
position
;
D
.
push
(
w
.
x
,
w
.
y
,
w
.
z
);
D
.
push
(
v
.
x
,
v
.
y
,
v
.
z
);
D
.
push
(
u
.
x
,
u
.
y
,
u
.
z
);
D
.
push
(
t
.
x
,
t
.
y
,
t
.
z
);
if
(
H
.
length
==
4
){
J
.
push
(
H
[
0
].
x
,
H
[
0
].
y
,
H
[
0
].
z
);
J
.
push
(
H
[
1
].
x
,
H
[
1
].
y
,
H
[
1
].
z
);
J
.
push
(
H
[
2
].
x
,
H
[
2
].
y
,
H
[
2
].
z
);
J
.
push
(
H
[
3
].
x
,
H
[
3
].
y
,
H
[
3
].
z
)}
else
{
J
.
push
(
L
.
x
,
L
.
y
,
L
.
z
);
J
.
push
(
L
.
x
,
L
.
y
,
L
.
z
);
J
.
push
(
L
.
x
,
L
.
y
,
L
.
z
);
J
.
push
(
L
.
x
,
L
.
y
,
L
.
z
)}
if
(
y
){
F
.
push
(
y
[
0
].
u
,
y
[
0
].
v
);
F
.
push
(
y
[
1
].
u
,
y
[
1
].
v
);
F
.
push
(
y
[
2
].
u
,
y
[
2
].
v
);
F
.
push
(
y
[
3
].
u
,
y
[
3
].
v
)}
E
.
push
(
B
,
B
+
1
,
B
+
2
);
E
.
push
(
B
,
B
+
2
,
B
+
3
);
G
.
push
(
B
,
B
+
1
);
G
.
push
(
B
,
B
+
2
);
G
.
push
(
B
,
B
+
3
);
G
.
push
(
B
+
1
,
B
+
2
);
G
.
push
(
B
+
2
,
B
+
3
);
B
+=
4
}}}
if
(
!
D
.
length
){
return
}
x
.
__webGLVertexBuffer
=
f
.
createBuffer
();
f
.
bindBuffer
(
f
.
ARRAY_BUFFER
,
x
.
__webGLVertexBuffer
);
f
.
bufferData
(
f
.
ARRAY_BUFFER
,
new
Float32Array
(
D
),
f
.
STATIC_DRAW
);
x
.
__webGLNormalBuffer
=
f
.
createBuffer
();
f
.
bindBuffer
(
f
.
ARRAY_BUFFER
,
x
.
__webGLNormalBuffer
);
f
.
bufferData
(
f
.
ARRAY_BUFFER
,
new
Float32Array
(
J
),
f
.
STATIC_DRAW
);
x
.
__webGLUVBuffer
=
f
.
createBuffer
();
f
.
bindBuffer
(
f
.
ARRAY_BUFFER
,
x
.
__webGLUVBuffer
);
f
.
bufferData
(
f
.
ARRAY_BUFFER
,
new
Float32Array
(
F
),
f
.
STATIC_DRAW
);
x
.
__webGLFaceBuffer
=
f
.
createBuffer
();
f
.
bindBuffer
(
f
.
ELEMENT_ARRAY_BUFFER
,
x
.
__webGLFaceBuffer
);
f
.
bufferData
(
f
.
ELEMENT_ARRAY_BUFFER
,
new
Uint16Array
(
E
),
f
.
STATIC_DRAW
);
x
.
__webGLLineBuffer
=
f
.
createBuffer
();
f
.
bindBuffer
(
f
.
ELEMENT_ARRAY_BUFFER
,
x
.
__webGLLineBuffer
);
f
.
bufferData
(
f
.
ELEMENT_ARRAY_BUFFER
,
new
Uint16Array
(
G
),
f
.
STATIC_DRAW
);
x
.
__webGLFaceCount
=
E
.
length
;
x
.
__webGLLineCount
=
G
.
length
};
this
.
renderBuffer
=
function
(
u
,
t
){
if
(
u
instanceof
THREE
.
MeshPhongMaterial
){
mAmbient
=
u
.
ambient
;
mDiffuse
=
u
.
diffuse
;
mSpecular
=
u
.
specular
;
f
.
uniform4f
(
n
.
mAmbient
,
mAmbient
.
r
,
mAmbient
.
g
,
mAmbient
.
b
,
u
.
opacity
);
f
.
uniform4f
(
n
.
mDiffuse
,
mDiffuse
.
r
,
mDiffuse
.
g
,
mDiffuse
.
b
,
u
.
opacity
);
f
.
uniform4f
(
n
.
mSpecular
,
mSpecular
.
r
,
mSpecular
.
g
,
mSpecular
.
b
,
u
.
opacity
);
f
.
uniform1f
(
n
.
mShininess
,
u
.
shininess
);
f
.
uniform1i
(
n
.
material
,
o
)}
else
{
if
(
u
instanceof
THREE
.
MeshColorFillMaterial
){
color
=
u
.
color
;
f
.
uniform4f
(
n
.
mColor
,
color
.
r
*
color
.
a
,
color
.
g
*
color
.
a
,
color
.
b
*
color
.
a
,
color
.
a
);
f
.
uniform1i
(
n
.
material
,
g
)}
else
{
if
(
u
instanceof
THREE
.
MeshColorStrokeMaterial
){
lineWidth
=
u
.
lineWidth
;
color
=
u
.
color
;
f
.
uniform4f
(
n
.
mColor
,
color
.
r
*
color
.
a
,
color
.
g
*
color
.
a
,
color
.
b
*
color
.
a
,
color
.
a
);
f
.
uniform1i
(
n
.
material
,
c
)}
else
{
if
(
u
instanceof
THREE
.
MeshBitmapMaterial
){
if
(
!
u
.
__webGLTexture
&&
u
.
loaded
){
u
.
__webGLTexture
=
f
.
createTexture
();
f
.
bindTexture
(
f
.
TEXTURE_2D
,
u
.
__webGLTexture
);
f
.
texImage2D
(
f
.
TEXTURE_2D
,
0
,
f
.
RGBA
,
f
.
RGBA
,
f
.
UNSIGNED_BYTE
,
u
.
bitmap
);
f
.
texParameteri
(
f
.
TEXTURE_2D
,
f
.
TEXTURE_MAG_FILTER
,
f
.
LINEAR
);
f
.
texParameteri
(
f
.
TEXTURE_2D
,
f
.
TEXTURE_MIN_FILTER
,
f
.
LINEAR_MIPMAP_LINEAR
);
f
.
generateMipmap
(
f
.
TEXTURE_2D
);
f
.
bindTexture
(
f
.
TEXTURE_2D
,
null
)}
f
.
activeTexture
(
f
.
TEXTURE0
);
f
.
bindTexture
(
f
.
TEXTURE_2D
,
u
.
__webGLTexture
);
f
.
uniform1i
(
n
.
tDiffuse
,
0
);
f
.
uniform1i
(
n
.
material
,
s
)}}}}
f
.
bindBuffer
(
f
.
ARRAY_BUFFER
,
t
.
__webGLVertexBuffer
);
f
.
vertexAttribPointer
(
n
.
position
,
3
,
f
.
FLOAT
,
false
,
0
,
0
);
f
.
bindBuffer
(
f
.
ARRAY_BUFFER
,
t
.
__webGLNormalBuffer
);
f
.
vertexAttribPointer
(
n
.
normal
,
3
,
f
.
FLOAT
,
false
,
0
,
0
);
if
(
u
instanceof
THREE
.
MeshBitmapMaterial
){
f
.
bindBuffer
(
f
.
ARRAY_BUFFER
,
t
.
__webGLUVBuffer
);
f
.
enableVertexAttribArray
(
n
.
uv
);
f
.
vertexAttribPointer
(
n
.
uv
,
2
,
f
.
FLOAT
,
false
,
0
,
0
)}
else
{
f
.
disableVertexAttribArray
(
n
.
uv
)}
if
(
u
instanceof
THREE
.
MeshBitmapMaterial
||
u
instanceof
THREE
.
MeshColorFillMaterial
||
u
instanceof
THREE
.
MeshPhongMaterial
){
f
.
bindBuffer
(
f
.
ELEMENT_ARRAY_BUFFER
,
t
.
__webGLFaceBuffer
);
f
.
drawElements
(
f
.
TRIANGLES
,
t
.
__webGLFaceCount
,
f
.
UNSIGNED_SHORT
,
0
)}
else
{
if
(
u
instanceof
THREE
.
MeshColorStrokeMaterial
){
f
.
lineWidth
(
lineWidth
);
f
.
bindBuffer
(
f
.
ELEMENT_ARRAY_BUFFER
,
t
.
__webGLLineBuffer
);
f
.
drawElements
(
f
.
LINES
,
t
.
__webGLLineCount
,
f
.
UNSIGNED_SHORT
,
0
)}}};
this
.
renderMesh
=
function
(
v
,
y
){
var
x
,
u
,
t
,
w
,
B
,
z
,
A
,
C
;
for
(
B
in
v
.
materialFaceGroup
){
C
=
v
.
materialFaceGroup
[
B
];
if
(
!
C
.
__webGLVertexBuffer
){
this
.
createBuffers
(
v
,
B
)}
for
(
t
=
0
,
w
=
v
.
material
.
length
;
t
<
w
;
t
++
){
A
=
v
.
material
[
t
];
if
(
A
instanceof
THREE
.
MeshFaceMaterial
){
for
(
x
=
0
,
u
=
C
.
material
.
length
;
x
<
u
;
x
++
){
z
=
C
.
material
[
x
];
this
.
renderBuffer
(
z
,
C
)}}
else
{
z
=
A
;
this
.
renderBuffer
(
z
,
C
)}}}};
this
.
setupMatrices
=
function
(
t
,
u
){
t
.
autoUpdateMatrix
&&
t
.
updateMatrix
();
k
.
multiply
(
u
.
matrix
,
t
.
matrix
);
n
.
viewMatrixArray
=
new
Float32Array
(
u
.
matrix
.
flatten
());
n
.
modelViewMatrixArray
=
new
Float32Array
(
k
.
flatten
());
n
.
projectionMatrixArray
=
new
Float32Array
(
u
.
projectionMatrix
.
flatten
());
d
=
THREE
.
Matrix4
.
makeInvert3x3
(
k
).
transpose
();
n
.
normalMatrixArray
=
new
Float32Array
(
d
.
m
);
f
.
uniformMatrix4fv
(
n
.
viewMatrix
,
false
,
n
.
viewMatrixArray
);
f
.
uniformMatrix4fv
(
n
.
modelViewMatrix
,
false
,
n
.
modelViewMatrixArray
);
f
.
uniformMatrix4fv
(
n
.
projectionMatrix
,
false
,
n
.
projectionMatrixArray
);
f
.
uniformMatrix3fv
(
n
.
normalMatrix
,
false
,
n
.
normalMatrixArray
);
f
.
uniformMatrix4fv
(
n
.
objMatrix
,
false
,
new
Float32Array
(
t
.
matrix
.
flatten
()))};
this
.
render
=
function
(
w
,
v
){
var
x
,
u
,
t
;
if
(
this
.
autoClear
){
this
.
clear
()}
v
.
autoUpdateMatrix
&&
v
.
updateMatrix
();
f
.
uniform3f
(
n
.
cameraPosition
,
v
.
position
.
x
,
v
.
position
.
y
,
v
.
position
.
z
);
this
.
setupLights
(
w
);
for
(
x
=
0
,
u
=
w
.
objects
.
length
;
x
<
u
;
x
++
){
t
=
w
.
objects
[
x
];
this
.
setupMatrices
(
t
,
v
);
if
(
t
instanceof
THREE
.
Mesh
){
this
.
renderMesh
(
t
,
v
)}
else
{
if
(
t
instanceof
THREE
.
Line
){}
else
{
if
(
t
instanceof
THREE
.
Particle
){}}}}};
this
.
setFaceCulling
=
function
(
u
,
t
){
if
(
u
){
if
(
!
t
||
t
==
"
ccw
"
){
f
.
frontFace
(
f
.
CCW
)}
else
{
f
.
frontFace
(
f
.
CW
)}
if
(
u
==
"
back
"
){
f
.
cullFace
(
f
.
BACK
)}
else
{
if
(
u
==
"
front
"
){
f
.
cullFace
(
f
.
FRONT
)}
else
{
f
.
cullFace
(
f
.
FRONT_AND_BACK
)}}
f
.
enable
(
f
.
CULL_FACE
)}
else
{
f
.
disable
(
f
.
CULL_FACE
)}};
function
a
(){
try
{
f
=
h
.
getContext
(
"
experimental-webgl
"
,{
antialias
:
true
})}
catch
(
t
){}
if
(
!
f
){
alert
(
"
WebGL not supported
"
);
throw
"
cannot create webgl context
"
}
f
.
clearColor
(
0
,
0
,
0
,
1
);
f
.
clearDepth
(
1
);
f
.
enable
(
f
.
DEPTH_TEST
);
f
.
depthFunc
(
f
.
LEQUAL
);
f
.
frontFace
(
f
.
CCW
);
f
.
cullFace
(
f
.
BACK
);
f
.
enable
(
f
.
CULL_FACE
);
f
.
enable
(
f
.
BLEND
);
f
.
blendFunc
(
f
.
ONE
,
f
.
ONE_MINUS_SRC_ALPHA
);
f
.
clearColor
(
0
,
0
,
0
,
0
)}
function
p
(
t
,
u
){
var
v
=
[
"
#ifdef GL_ES
"
,
"
precision highp float;
"
,
"
#endif
"
,
t
?
"
#define MAX_DIR_LIGHTS
"
+
t
:
""
,
u
?
"
#define MAX_POINT_LIGHTS
"
+
u
:
""
,
"
uniform int material;
"
,
"
uniform sampler2D tDiffuse;
"
,
"
uniform vec4 mColor;
"
,
"
uniform vec4 mAmbient;
"
,
"
uniform vec4 mDiffuse;
"
,
"
uniform vec4 mSpecular;
"
,
"
uniform float mShininess;
"
,
"
uniform int pointLightNumber;
"
,
"
uniform int directionalLightNumber;
"
,
t
?
"
uniform mat4 viewMatrix;
"
:
""
,
t
?
"
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
"
:
""
,
"
varying vec3 vNormal;
"
,
"
varying vec2 vUv;
"
,
"
varying vec3 vLightWeighting;
"
,
u
?
"
varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];
"
:
""
,
"
varying vec3 vViewPosition;
"
,
"
void main() {
"
,
"
if ( material == 3 ) {
"
,
"
vec3 normal = normalize( vNormal );
"
,
"
vec3 viewPosition = normalize( vViewPosition );
"
,
u
?
"
vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
u
?
"
vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
u
?
"
for( int i = 0; i < pointLightNumber; i++ ) {
"
:
""
,
u
?
"
vec3 pointVector = normalize( vPointLightVector[ i ] );
"
:
""
,
u
?
"
vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );
"
:
""
,
u
?
"
float pointDotNormalHalf = dot( normal, pointHalfVector );
"
:
""
,
u
?
"
float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );
"
:
""
,
u
?
"
float pointSpecularWeight = 0.0;
"
:
""
,
u
?
"
if ( pointDotNormalHalf >= 0.0 )
"
:
""
,
u
?
"
pointSpecularWeight = pow( pointDotNormalHalf, mShininess );
"
:
""
,
u
?
"
pointDiffuse += mDiffuse * pointDiffuseWeight;
"
:
""
,
u
?
"
pointSpecular += mSpecular * pointSpecularWeight;
"
:
""
,
u
?
"
}
"
:
""
,
t
?
"
vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
t
?
"
vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
t
?
"
for( int i = 0; i < directionalLightNumber; i++ ) {
"
:
""
,
t
?
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
:
""
,
t
?
"
vec3 dirVector = normalize( lDirection.xyz );
"
:
""
,
t
?
"
vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );
"
:
""
,
t
?
"
float dirDotNormalHalf = dot( normal, dirHalfVector );
"
:
""
,
t
?
"
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
"
:
""
,
t
?
"
float dirSpecularWeight = 0.0;
"
:
""
,
t
?
"
if ( dirDotNormalHalf >= 0.0 )
"
:
""
,
t
?
"
dirSpecularWeight = pow( dirDotNormalHalf, mShininess );
"
:
""
,
t
?
"
dirDiffuse += mDiffuse * dirDiffuseWeight;
"
:
""
,
t
?
"
dirSpecular += mSpecular * dirSpecularWeight;
"
:
""
,
t
?
"
}
"
:
""
,
"
vec4 totalLight = mAmbient;
"
,
t
?
"
totalLight += dirDiffuse + dirSpecular;
"
:
""
,
u
?
"
totalLight += pointDiffuse + pointSpecular;
"
:
""
,
"
gl_FragColor = vec4( totalLight.xyz * vLightWeighting, 1.0 );
"
,
"
} else if ( material == 2 ) {
"
,
"
vec4 texelColor = texture2D( tDiffuse, vUv );
"
,
"
gl_FragColor = vec4( texelColor.rgb * vLightWeighting, texelColor.a );
"
,
"
} else if ( material == 1 ) {
"
,
"
gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );
"
,
"
} else {
"
,
"
gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );
"
,
"
}
"
,
"
}
"
];
return
v
.
join
(
"
\n
"
)}
function
j
(
t
,
u
){
var
v
=
[
t
?
"
#define MAX_DIR_LIGHTS
"
+
t
:
""
,
u
?
"
#define MAX_POINT_LIGHTS
"
+
u
:
""
,
"
attribute vec3 position;
"
,
"
attribute vec3 normal;
"
,
"
attribute vec2 uv;
"
,
"
uniform vec3 cameraPosition;
"
,
"
uniform bool enableLighting;
"
,
"
uniform int pointLightNumber;
"
,
"
uniform int directionalLightNumber;
"
,
"
uniform vec3 ambientLightColor;
"
,
t
?
"
uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
"
:
""
,
t
?
"
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
"
:
""
,
u
?
"
uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
"
:
""
,
u
?
"
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
"
:
""
,
"
uniform mat4 objMatrix;
"
,
"
uniform mat4 viewMatrix;
"
,
"
uniform mat4 modelViewMatrix;
"
,
"
uniform mat4 projectionMatrix;
"
,
"
uniform mat3 normalMatrix;
"
,
"
varying vec3 vNormal;
"
,
"
varying vec2 vUv;
"
,
"
varying vec3 vLightWeighting;
"
,
u
?
"
varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];
"
:
""
,
"
varying vec3 vViewPosition;
"
,
"
void main(void) {
"
,
"
vec4 mPosition = objMatrix * vec4( position, 1.0 );
"
,
"
vViewPosition = cameraPosition - mPosition.xyz;
"
,
"
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
"
vec3 transformedNormal = normalize( normalMatrix * normal );
"
,
"
if ( !enableLighting ) {
"
,
"
vLightWeighting = vec3( 1.0, 1.0, 1.0 );
"
,
"
} else {
"
,
"
vLightWeighting = ambientLightColor;
"
,
t
?
"
for( int i = 0; i < directionalLightNumber; i++ ) {
"
:
""
,
t
?
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
:
""
,
t
?
"
float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );
"
:
""
,
t
?
"
vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;
"
:
""
,
t
?
"
}
"
:
""
,
u
?
"
for( int i = 0; i < pointLightNumber; i++ ) {
"
:
""
,
u
?
"
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
"
:
""
,
u
?
"
vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );
"
:
""
,
u
?
"
float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );
"
:
""
,
u
?
"
vLightWeighting += pointLightColor[ i ] * pointLightWeighting;
"
:
""
,
u
?
"
}
"
:
""
,
"
}
"
,
"
vNormal = transformedNormal;
"
,
"
vUv = uv;
"
,
"
gl_Position = projectionMatrix * mvPosition;
"
,
"
}
"
];
return
v
.
join
(
"
\n
"
)}
function
i
(
t
,
u
){
n
=
f
.
createProgram
();
f
.
attachShader
(
n
,
r
(
"
fragment
"
,
p
(
t
,
u
)));
f
.
attachShader
(
n
,
r
(
"
vertex
"
,
j
(
t
,
u
)));
f
.
linkProgram
(
n
);
if
(
!
f
.
getProgramParameter
(
n
,
f
.
LINK_STATUS
)){
alert
(
"
Could not initialise shaders
"
)}
f
.
useProgram
(
n
);
n
.
viewMatrix
=
f
.
getUniformLocation
(
n
,
"
viewMatrix
"
);
n
.
modelViewMatrix
=
f
.
getUniformLocation
(
n
,
"
modelViewMatrix
"
);
n
.
projectionMatrix
=
f
.
getUniformLocation
(
n
,
"
projectionMatrix
"
);
n
.
normalMatrix
=
f
.
getUniformLocation
(
n
,
"
normalMatrix
"
);
n
.
objMatrix
=
f
.
getUniformLocation
(
n
,
"
objMatrix
"
);
n
.
cameraPosition
=
f
.
getUniformLocation
(
n
,
"
cameraPosition
"
);
n
.
enableLighting
=
f
.
getUniformLocation
(
n
,
"
enableLighting
"
);
n
.
ambientLightColor
=
f
.
getUniformLocation
(
n
,
"
ambientLightColor
"
);
if
(
t
){
n
.
directionalLightNumber
=
f
.
getUniformLocation
(
n
,
"
directionalLightNumber
"
);
n
.
directionalLightColor
=
f
.
getUniformLocation
(
n
,
"
directionalLightColor
"
);
n
.
directionalLightDirection
=
f
.
getUniformLocation
(
n
,
"
directionalLightDirection
"
)}
if
(
u
){
n
.
pointLightNumber
=
f
.
getUniformLocation
(
n
,
"
pointLightNumber
"
);
n
.
pointLightColor
=
f
.
getUniformLocation
(
n
,
"
pointLightColor
"
);
n
.
pointLightPosition
=
f
.
getUniformLocation
(
n
,
"
pointLightPosition
"
)}
n
.
material
=
f
.
getUniformLocation
(
n
,
"
material
"
);
n
.
mColor
=
f
.
getUniformLocation
(
n
,
"
mColor
"
);
n
.
mAmbient
=
f
.
getUniformLocation
(
n
,
"
mAmbient
"
);
n
.
mDiffuse
=
f
.
getUniformLocation
(
n
,
"
mDiffuse
"
);
n
.
mSpecular
=
f
.
getUniformLocation
(
n
,
"
mSpecular
"
);
n
.
mShininess
=
f
.
getUniformLocation
(
n
,
"
mShininess
"
);
n
.
tDiffuse
=
f
.
getUniformLocation
(
n
,
"
tDiffuse
"
);
f
.
uniform1i
(
n
.
tDiffuse
,
0
);
n
.
position
=
f
.
getAttribLocation
(
n
,
"
position
"
);
f
.
enableVertexAttribArray
(
n
.
position
);
n
.
normal
=
f
.
getAttribLocation
(
n
,
"
normal
"
);
f
.
enableVertexAttribArray
(
n
.
normal
);
n
.
uv
=
f
.
getAttribLocation
(
n
,
"
uv
"
);
f
.
enableVertexAttribArray
(
n
.
uv
);
n
.
viewMatrixArray
=
new
Float32Array
(
16
);
n
.
modelViewMatrixArray
=
new
Float32Array
(
16
);
n
.
projectionMatrixArray
=
new
Float32Array
(
16
)}
function
r
(
u
,
t
){
var
v
;
if
(
u
==
"
fragment
"
){
v
=
f
.
createShader
(
f
.
FRAGMENT_SHADER
)}
else
{
if
(
u
==
"
vertex
"
){
v
=
f
.
createShader
(
f
.
VERTEX_SHADER
)}}
f
.
shaderSource
(
v
,
t
);
f
.
compileShader
(
v
);
if
(
!
f
.
getShaderParameter
(
v
,
f
.
COMPILE_STATUS
)){
alert
(
f
.
getShaderInfoLog
(
v
));
return
null
}
return
v
}
function
e
(){
var
t
=
{
MAX_VARYING_VECTORS
:
f
.
getParameter
(
f
.
MAX_VARYING_VECTORS
),
MAX_VERTEX_ATTRIBS
:
f
.
getParameter
(
f
.
MAX_VERTEX_ATTRIBS
),
MAX_TEXTURE_IMAGE_UNITS
:
f
.
getParameter
(
f
.
MAX_TEXTURE_IMAGE_UNITS
),
MAX_VERTEX_TEXTURE_IMAGE_UNITS
:
f
.
getParameter
(
f
.
MAX_VERTEX_TEXTURE_IMAGE_UNITS
),
MAX_COMBINED_TEXTURE_IMAGE_UNITS
:
f
.
getParameter
(
f
.
MAX_COMBINED_TEXTURE_IMAGE_UNITS
),
MAX_VERTEX_UNIFORM_VECTORS
:
f
.
getParameter
(
f
.
MAX_VERTEX_UNIFORM_VECTORS
),
MAX_FRAGMENT_UNIFORM_VECTORS
:
f
.
getParameter
(
f
.
MAX_FRAGMENT_UNIFORM_VECTORS
)};
return
t
}
function
m
(
u
){
var
t
,
v
=
""
;
for
(
t
in
u
){
v
+=
t
+
"
:
"
+
u
[
t
]
+
"
\n
"
}
return
v
}};
THREE
.
RenderableFace3
=
function
(){
this
.
v1
=
new
THREE
.
Vector2
();
this
.
v2
=
new
THREE
.
Vector2
();
this
.
v3
=
new
THREE
.
Vector2
();
this
.
centroidWorld
=
new
THREE
.
Vector3
();
this
.
centroidScreen
=
new
THREE
.
Vector3
();
this
.
normalWorld
=
new
THREE
.
Vector3
();
this
.
z
=
null
;
this
.
color
=
null
;
this
.
material
=
null
};
THREE
.
RenderableFace4
=
function
(){
this
.
v1
=
new
THREE
.
Vector2
();
this
.
v2
=
new
THREE
.
Vector2
();
this
.
v3
=
new
THREE
.
Vector2
();
this
.
v4
=
new
THREE
.
Vector2
();
this
.
centroidWorld
=
new
THREE
.
Vector3
();
this
.
centroidScreen
=
new
THREE
.
Vector3
();
this
.
normalWorld
=
new
THREE
.
Vector3
();
this
.
z
=
null
;
this
.
color
=
null
;
this
.
material
=
null
};
THREE
.
RenderableParticle
=
function
(){
this
.
x
=
null
;
this
.
y
=
null
;
this
.
z
=
null
;
this
.
rotation
=
null
;
this
.
scale
=
new
THREE
.
Vector2
();
this
.
color
=
null
;
this
.
material
=
null
};
THREE
.
RenderableLine
=
function
(){
this
.
v1
=
new
THREE
.
Vector2
();
this
.
v2
=
new
THREE
.
Vector2
();
this
.
z
=
null
;
this
.
color
=
null
;
this
.
material
=
null
};
\ No newline at end of file
var
THREE
=
THREE
||
{};
THREE
.
Color
=
function
(
a
){
this
.
autoUpdate
=
true
;
this
.
setHex
(
a
)};
THREE
.
Color
.
prototype
=
{
setRGBA
:
function
(
f
,
e
,
c
,
d
){
this
.
r
=
f
;
this
.
g
=
e
;
this
.
b
=
c
;
this
.
a
=
d
;
if
(
this
.
autoUpdate
){
this
.
updateHex
();
this
.
updateStyleString
()}},
setHex
:
function
(
a
){
this
.
hex
=
(
~~
a
).
toString
(
16
).
length
<
8
?
255
<<
24
^
a
:
a
;
if
(
this
.
autoUpdate
){
this
.
updateRGBA
();
this
.
updateStyleString
()}},
copyRGB
:
function
(
a
){
this
.
r
=
a
.
r
;
this
.
g
=
a
.
g
;
this
.
b
=
a
.
b
},
copyRGBA
:
function
(
a
){
this
.
r
=
a
.
r
;
this
.
g
=
a
.
g
;
this
.
b
=
a
.
b
;
this
.
a
=
a
.
a
},
multiplySelfRGB
:
function
(
a
){
this
.
r
*=
a
.
r
;
this
.
g
*=
a
.
g
;
this
.
b
*=
a
.
b
},
updateHex
:
function
(){
this
.
hex
=~~
(
this
.
a
*
255
)
<<
24
^~~
(
this
.
r
*
255
)
<<
16
^~~
(
this
.
g
*
255
)
<<
8
^~~
(
this
.
b
*
255
)},
updateRGBA
:
function
(){
this
.
a
=
(
this
.
hex
>>
24
&
255
)
/
255
;
this
.
r
=
(
this
.
hex
>>
16
&
255
)
/
255
;
this
.
g
=
(
this
.
hex
>>
8
&
255
)
/
255
;
this
.
b
=
(
this
.
hex
&
255
)
/
255
},
updateStyleString
:
function
(){
this
.
__styleString
=
"
rgba(
"
+~~
(
this
.
r
*
255
)
+
"
,
"
+~~
(
this
.
g
*
255
)
+
"
,
"
+~~
(
this
.
b
*
255
)
+
"
,
"
+
this
.
a
+
"
)
"
},
toString
:
function
(){
return
"
THREE.Color ( r:
"
+
this
.
r
+
"
, g:
"
+
this
.
g
+
"
, b:
"
+
this
.
b
+
"
, a:
"
+
this
.
a
+
"
, hex:
"
+
this
.
hex
+
"
)
"
}};
THREE
.
Vector2
=
function
(
a
,
b
){
this
.
x
=
a
||
0
;
this
.
y
=
b
||
0
};
THREE
.
Vector2
.
prototype
=
{
set
:
function
(
a
,
b
){
this
.
x
=
a
;
this
.
y
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
x
=
a
.
x
;
this
.
y
=
a
.
y
;
return
this
},
addSelf
:
function
(
a
){
this
.
x
+=
a
.
x
;
this
.
y
+=
a
.
y
;
return
this
},
add
:
function
(
b
,
a
){
this
.
x
=
b
.
x
+
a
.
x
;
this
.
y
=
b
.
y
+
a
.
y
;
return
this
},
subSelf
:
function
(
a
){
this
.
x
-=
a
.
x
;
this
.
y
-=
a
.
y
;
return
this
},
sub
:
function
(
b
,
a
){
this
.
x
=
b
.
x
-
a
.
x
;
this
.
y
=
b
.
y
-
a
.
y
;
return
this
},
multiplyScalar
:
function
(
a
){
this
.
x
*=
a
;
this
.
y
*=
a
;
return
this
},
unit
:
function
(){
this
.
multiplyScalar
(
1
/
this
.
length
());
return
this
},
length
:
function
(){
return
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
)},
lengthSq
:
function
(){
return
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
},
negate
:
function
(){
this
.
x
=-
this
.
x
;
this
.
y
=-
this
.
y
;
return
this
},
clone
:
function
(){
return
new
THREE
.
Vector2
(
this
.
x
,
this
.
y
)},
toString
:
function
(){
return
"
THREE.Vector2 (
"
+
this
.
x
+
"
,
"
+
this
.
y
+
"
)
"
}};
THREE
.
Vector3
=
function
(
a
,
c
,
b
){
this
.
x
=
a
||
0
;
this
.
y
=
c
||
0
;
this
.
z
=
b
||
0
};
THREE
.
Vector3
.
prototype
=
{
set
:
function
(
a
,
c
,
b
){
this
.
x
=
a
;
this
.
y
=
c
;
this
.
z
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
x
=
a
.
x
;
this
.
y
=
a
.
y
;
this
.
z
=
a
.
z
;
return
this
},
add
:
function
(
b
,
a
){
this
.
x
=
b
.
x
+
a
.
x
;
this
.
y
=
b
.
y
+
a
.
y
;
this
.
z
=
b
.
z
+
a
.
z
;
return
this
},
addSelf
:
function
(
a
){
this
.
x
+=
a
.
x
;
this
.
y
+=
a
.
y
;
this
.
z
+=
a
.
z
;
return
this
},
addScalar
:
function
(
a
){
this
.
x
+=
a
;
this
.
y
+=
a
;
this
.
z
+=
a
;
return
this
},
sub
:
function
(
b
,
a
){
this
.
x
=
b
.
x
-
a
.
x
;
this
.
y
=
b
.
y
-
a
.
y
;
this
.
z
=
b
.
z
-
a
.
z
;
return
this
},
subSelf
:
function
(
a
){
this
.
x
-=
a
.
x
;
this
.
y
-=
a
.
y
;
this
.
z
-=
a
.
z
;
return
this
},
cross
:
function
(
b
,
a
){
this
.
x
=
b
.
y
*
a
.
z
-
b
.
z
*
a
.
y
;
this
.
y
=
b
.
z
*
a
.
x
-
b
.
x
*
a
.
z
;
this
.
z
=
b
.
x
*
a
.
y
-
b
.
y
*
a
.
x
;
return
this
},
crossSelf
:
function
(
c
){
var
b
=
this
.
x
,
a
=
this
.
y
,
d
=
this
.
z
;
this
.
x
=
a
*
c
.
z
-
d
*
c
.
y
;
this
.
y
=
d
*
c
.
x
-
b
*
c
.
z
;
this
.
z
=
b
*
c
.
y
-
a
*
c
.
x
;
return
this
},
multiplySelf
:
function
(
a
){
this
.
x
*=
a
.
x
;
this
.
y
*=
a
.
y
;
this
.
z
*=
a
.
z
;
return
this
},
multiplyScalar
:
function
(
a
){
this
.
x
*=
a
;
this
.
y
*=
a
;
this
.
z
*=
a
;
return
this
},
divideScalar
:
function
(
a
){
this
.
x
/=
a
;
this
.
y
/=
a
;
this
.
z
/=
a
;
return
this
},
dot
:
function
(
a
){
return
this
.
x
*
a
.
x
+
this
.
y
*
a
.
y
+
this
.
z
*
a
.
z
},
distanceTo
:
function
(
a
){
return
Math
.
sqrt
(
this
.
distanceToSquared
(
a
))},
distanceToSquared
:
function
(
d
){
var
c
=
this
.
x
-
d
.
x
,
b
=
this
.
y
-
d
.
y
,
a
=
this
.
z
-
d
.
z
;
return
c
*
c
+
b
*
b
+
a
*
a
},
length
:
function
(){
return
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
)},
lengthSq
:
function
(){
return
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
},
negate
:
function
(){
this
.
x
=-
this
.
x
;
this
.
y
=-
this
.
y
;
this
.
z
=-
this
.
z
;
return
this
},
normalize
:
function
(){
if
(
this
.
length
()
>
0
){
this
.
multiplyScalar
(
1
/
this
.
length
())}
else
{
this
.
multiplyScalar
(
0
)}
return
this
},
setLength
:
function
(
a
){
return
this
.
normalize
().
multiplyScalar
(
a
)},
isZero
:
function
(){
var
a
=
0.0001
;
return
(
Math
.
abs
(
this
.
x
)
<
a
)
&&
(
Math
.
abs
(
this
.
y
)
<
a
)
&&
(
Math
.
abs
(
this
.
z
)
<
a
)},
clone
:
function
(){
return
new
THREE
.
Vector3
(
this
.
x
,
this
.
y
,
this
.
z
)},
toString
:
function
(){
return
"
THREE.Vector3 (
"
+
this
.
x
+
"
,
"
+
this
.
y
+
"
,
"
+
this
.
z
+
"
)
"
}};
THREE
.
Vector4
=
function
(
a
,
d
,
c
,
b
){
this
.
x
=
a
||
0
;
this
.
y
=
d
||
0
;
this
.
z
=
c
||
0
;
this
.
w
=
b
||
1
};
THREE
.
Vector4
.
prototype
=
{
set
:
function
(
a
,
d
,
c
,
b
){
this
.
x
=
a
;
this
.
y
=
d
;
this
.
z
=
c
;
this
.
w
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
x
=
a
.
x
;
this
.
y
=
a
.
y
;
this
.
z
=
a
.
z
;
this
.
w
=
a
.
w
;
return
this
},
add
:
function
(
b
,
a
){
this
.
x
=
b
.
x
+
a
.
x
;
this
.
y
=
b
.
y
+
a
.
y
;
this
.
z
=
b
.
z
+
a
.
z
;
this
.
w
=
b
.
w
+
a
.
w
;
return
this
},
addSelf
:
function
(
a
){
this
.
x
+=
a
.
x
;
this
.
y
+=
a
.
y
;
this
.
z
+=
a
.
z
;
this
.
w
+=
a
.
w
;
return
this
},
sub
:
function
(
b
,
a
){
this
.
x
=
b
.
x
-
a
.
x
;
this
.
y
=
b
.
y
-
a
.
y
;
this
.
z
=
b
.
z
-
a
.
z
;
this
.
w
=
b
.
w
-
a
.
w
;
return
this
},
subSelf
:
function
(
a
){
this
.
x
-=
a
.
x
;
this
.
y
-=
a
.
y
;
this
.
z
-=
a
.
z
;
this
.
w
-=
a
.
w
;
return
this
},
clone
:
function
(){
return
new
THREE
.
Vector4
(
this
.
x
,
this
.
y
,
this
.
z
,
this
.
w
)},
toString
:
function
(){
return
"
THREE.Vector4 (
"
+
this
.
x
+
"
,
"
+
this
.
y
+
"
,
"
+
this
.
z
+
"
,
"
+
this
.
w
+
"
)
"
}};
THREE
.
Ray
=
function
(
a
,
b
){
this
.
origin
=
a
||
new
THREE
.
Vector3
();
this
.
direction
=
b
||
new
THREE
.
Vector3
()};
THREE
.
Ray
.
prototype
=
{
intersectScene
:
function
(
f
){
var
c
,
a
,
b
,
e
=
f
.
objects
,
d
=
[];
for
(
c
=
0
,
a
=
e
.
length
;
c
<
a
;
c
++
){
b
=
e
[
c
];
if
(
b
instanceof
THREE
.
Mesh
){
d
=
d
.
concat
(
this
.
intersectObject
(
b
))}}
d
.
sort
(
function
(
h
,
g
){
return
h
.
distance
-
g
.
distance
});
return
d
},
intersectObject
:
function
(
w
){
var
n
,
j
,
i
,
t
,
s
,
q
,
p
,
v
,
k
,
x
,
u
,
r
,
g
=
w
.
geometry
,
h
=
g
.
vertices
,
o
,
e
=
[],
m
;
for
(
n
=
0
,
j
=
g
.
faces
.
length
;
n
<
j
;
n
++
){
i
=
g
.
faces
[
n
];
u
=
this
.
origin
.
clone
();
r
=
this
.
direction
.
clone
();
t
=
w
.
matrix
.
transform
(
h
[
i
.
a
].
position
.
clone
());
s
=
w
.
matrix
.
transform
(
h
[
i
.
b
].
position
.
clone
());
q
=
w
.
matrix
.
transform
(
h
[
i
.
c
].
position
.
clone
());
p
=
i
instanceof
THREE
.
Face4
?
w
.
matrix
.
transform
(
h
[
i
.
d
].
position
.
clone
()):
null
;
v
=
w
.
matrixRotation
.
transform
(
i
.
normal
.
clone
());
k
=
r
.
dot
(
v
);
if
(
k
<
0
){
x
=
v
.
dot
(
new
THREE
.
Vector3
().
sub
(
t
,
u
))
/
k
;
m
=
u
.
addSelf
(
r
.
multiplyScalar
(
x
));
if
(
i
instanceof
THREE
.
Face3
){
if
(
l
(
m
,
t
,
s
,
q
)){
o
=
{
distance
:
this
.
origin
.
distanceTo
(
m
),
point
:
m
,
face
:
i
,
object
:
w
};
e
.
push
(
o
)}}
else
{
if
(
i
instanceof
THREE
.
Face4
){
if
(
l
(
m
,
t
,
s
,
p
)
||
l
(
m
,
s
,
q
,
p
)){
o
=
{
distance
:
this
.
origin
.
distanceTo
(
m
),
point
:
m
,
face
:
i
,
object
:
w
};
e
.
push
(
o
)}}}}}
return
e
;
function
l
(
d
,
G
,
D
,
B
){
var
J
=
B
.
clone
().
subSelf
(
G
),
H
=
D
.
clone
().
subSelf
(
G
),
E
=
d
.
clone
().
subSelf
(
G
),
F
=
J
.
dot
(
J
),
C
=
J
.
dot
(
H
),
A
=
J
.
dot
(
E
),
z
=
H
.
dot
(
H
),
f
=
H
.
dot
(
E
),
y
=
1
/
(
F
*
z
-
C
*
C
),
K
=
(
z
*
A
-
C
*
f
)
*
y
,
I
=
(
F
*
f
-
C
*
A
)
*
y
;
return
(
K
>
0
)
&&
(
I
>
0
)
&&
(
K
+
I
<
1
)}}};
THREE
.
Rectangle
=
function
(){
var
e
,
g
,
h
,
d
,
a
,
c
,
f
=
true
;
function
b
(){
a
=
h
-
e
;
c
=
d
-
g
}
this
.
getX
=
function
(){
return
e
};
this
.
getY
=
function
(){
return
g
};
this
.
getWidth
=
function
(){
return
a
};
this
.
getHeight
=
function
(){
return
c
};
this
.
getLeft
=
function
(){
return
e
};
this
.
getTop
=
function
(){
return
g
};
this
.
getRight
=
function
(){
return
h
};
this
.
getBottom
=
function
(){
return
d
};
this
.
set
=
function
(
l
,
k
,
j
,
i
){
f
=
false
;
e
=
l
;
g
=
k
;
h
=
j
;
d
=
i
;
b
()};
this
.
addPoint
=
function
(
i
,
j
){
if
(
f
){
f
=
false
;
e
=
i
;
g
=
j
;
h
=
i
;
d
=
j
}
else
{
e
=
Math
.
min
(
e
,
i
);
g
=
Math
.
min
(
g
,
j
);
h
=
Math
.
max
(
h
,
i
);
d
=
Math
.
max
(
d
,
j
)}
b
()};
this
.
addRectangle
=
function
(
i
){
if
(
f
){
f
=
false
;
e
=
i
.
getLeft
();
g
=
i
.
getTop
();
h
=
i
.
getRight
();
d
=
i
.
getBottom
()}
else
{
e
=
Math
.
min
(
e
,
i
.
getLeft
());
g
=
Math
.
min
(
g
,
i
.
getTop
());
h
=
Math
.
max
(
h
,
i
.
getRight
());
d
=
Math
.
max
(
d
,
i
.
getBottom
())}
b
()};
this
.
inflate
=
function
(
i
){
e
-=
i
;
g
-=
i
;
h
+=
i
;
d
+=
i
;
b
()};
this
.
minSelf
=
function
(
i
){
e
=
Math
.
max
(
e
,
i
.
getLeft
());
g
=
Math
.
max
(
g
,
i
.
getTop
());
h
=
Math
.
min
(
h
,
i
.
getRight
());
d
=
Math
.
min
(
d
,
i
.
getBottom
());
b
()};
this
.
instersects
=
function
(
i
){
return
Math
.
min
(
h
,
i
.
getRight
())
-
Math
.
max
(
e
,
i
.
getLeft
())
>=
0
&&
Math
.
min
(
d
,
i
.
getBottom
())
-
Math
.
max
(
g
,
i
.
getTop
())
>=
0
};
this
.
empty
=
function
(){
f
=
true
;
e
=
0
;
g
=
0
;
h
=
0
;
d
=
0
;
b
()};
this
.
isEmpty
=
function
(){
return
f
};
this
.
toString
=
function
(){
return
"
THREE.Rectangle ( left:
"
+
e
+
"
, right:
"
+
h
+
"
, top:
"
+
g
+
"
, bottom:
"
+
d
+
"
, width:
"
+
a
+
"
, height:
"
+
c
+
"
)
"
}};
THREE
.
Matrix3
=
function
(){
this
.
m
=
[]};
THREE
.
Matrix3
.
prototype
=
{
transpose
:
function
(){
var
a
;
a
=
this
.
m
[
1
];
this
.
m
[
1
]
=
this
.
m
[
3
];
this
.
m
[
3
]
=
a
;
a
=
this
.
m
[
2
];
this
.
m
[
2
]
=
this
.
m
[
6
];
this
.
m
[
6
]
=
a
;
a
=
this
.
m
[
5
];
this
.
m
[
5
]
=
this
.
m
[
7
];
this
.
m
[
7
]
=
a
;
return
this
}};
THREE
.
Matrix4
=
function
(){
this
.
_x
=
new
THREE
.
Vector3
();
this
.
_y
=
new
THREE
.
Vector3
();
this
.
_z
=
new
THREE
.
Vector3
()};
THREE
.
Matrix4
.
prototype
=
{
n11
:
1
,
n12
:
0
,
n13
:
0
,
n14
:
0
,
n21
:
0
,
n22
:
1
,
n23
:
0
,
n24
:
0
,
n31
:
0
,
n32
:
0
,
n33
:
1
,
n34
:
0
,
n41
:
0
,
n42
:
0
,
n43
:
0
,
n44
:
1
,
identity
:
function
(){
this
.
n11
=
1
;
this
.
n12
=
0
;
this
.
n13
=
0
;
this
.
n14
=
0
;
this
.
n21
=
0
;
this
.
n22
=
1
;
this
.
n23
=
0
;
this
.
n24
=
0
;
this
.
n31
=
0
;
this
.
n32
=
0
;
this
.
n33
=
1
;
this
.
n34
=
0
;
this
.
n41
=
0
;
this
.
n42
=
0
;
this
.
n43
=
0
;
this
.
n44
=
1
},
copy
:
function
(
a
){
this
.
n11
=
a
.
n11
;
this
.
n12
=
a
.
n12
;
this
.
n13
=
a
.
n13
;
this
.
n14
=
a
.
n14
;
this
.
n21
=
a
.
n21
;
this
.
n22
=
a
.
n22
;
this
.
n23
=
a
.
n23
;
this
.
n24
=
a
.
n24
;
this
.
n31
=
a
.
n31
;
this
.
n32
=
a
.
n32
;
this
.
n33
=
a
.
n33
;
this
.
n34
=
a
.
n34
;
this
.
n41
=
a
.
n41
;
this
.
n42
=
a
.
n42
;
this
.
n43
=
a
.
n43
;
this
.
n44
=
a
.
n44
},
lookAt
:
function
(
d
,
c
,
b
){
var
a
=
this
.
_x
,
f
=
this
.
_y
,
e
=
this
.
_z
;
e
.
sub
(
d
,
c
);
e
.
normalize
();
a
.
cross
(
b
,
e
);
a
.
normalize
();
f
.
cross
(
e
,
a
);
f
.
normalize
();
this
.
n11
=
a
.
x
;
this
.
n12
=
a
.
y
;
this
.
n13
=
a
.
z
;
this
.
n14
=-
a
.
dot
(
d
);
this
.
n21
=
f
.
x
;
this
.
n22
=
f
.
y
;
this
.
n23
=
f
.
z
;
this
.
n24
=-
f
.
dot
(
d
);
this
.
n31
=
e
.
x
;
this
.
n32
=
e
.
y
;
this
.
n33
=
e
.
z
;
this
.
n34
=-
e
.
dot
(
d
);
this
.
n41
=
0
;
this
.
n42
=
0
;
this
.
n43
=
0
;
this
.
n44
=
1
},
transform
:
function
(
a
){
var
d
=
a
.
x
,
c
=
a
.
y
,
b
=
a
.
z
,
e
=
a
.
w
?
a
.
w
:
1
;
a
.
x
=
this
.
n11
*
d
+
this
.
n12
*
c
+
this
.
n13
*
b
+
this
.
n14
*
e
;
a
.
y
=
this
.
n21
*
d
+
this
.
n22
*
c
+
this
.
n23
*
b
+
this
.
n24
*
e
;
a
.
z
=
this
.
n31
*
d
+
this
.
n32
*
c
+
this
.
n33
*
b
+
this
.
n34
*
e
;
e
=
this
.
n41
*
d
+
this
.
n42
*
c
+
this
.
n43
*
b
+
this
.
n44
*
e
;
if
(
a
.
w
){
a
.
w
=
e
}
else
{
a
.
x
=
a
.
x
/
e
;
a
.
y
=
a
.
y
/
e
;
a
.
z
=
a
.
z
/
e
}
return
a
},
crossVector
:
function
(
b
){
var
c
=
new
THREE
.
Vector4
();
c
.
x
=
this
.
n11
*
b
.
x
+
this
.
n12
*
b
.
y
+
this
.
n13
*
b
.
z
+
this
.
n14
*
b
.
w
;
c
.
y
=
this
.
n21
*
b
.
x
+
this
.
n22
*
b
.
y
+
this
.
n23
*
b
.
z
+
this
.
n24
*
b
.
w
;
c
.
z
=
this
.
n31
*
b
.
x
+
this
.
n32
*
b
.
y
+
this
.
n33
*
b
.
z
+
this
.
n34
*
b
.
w
;
c
.
w
=
(
b
.
w
)?
this
.
n41
*
b
.
x
+
this
.
n42
*
b
.
y
+
this
.
n43
*
b
.
z
+
this
.
n44
*
b
.
w
:
1
;
return
c
},
multiply
:
function
(
d
,
c
){
this
.
n11
=
d
.
n11
*
c
.
n11
+
d
.
n12
*
c
.
n21
+
d
.
n13
*
c
.
n31
+
d
.
n14
*
c
.
n41
;
this
.
n12
=
d
.
n11
*
c
.
n12
+
d
.
n12
*
c
.
n22
+
d
.
n13
*
c
.
n32
+
d
.
n14
*
c
.
n42
;
this
.
n13
=
d
.
n11
*
c
.
n13
+
d
.
n12
*
c
.
n23
+
d
.
n13
*
c
.
n33
+
d
.
n14
*
c
.
n43
;
this
.
n14
=
d
.
n11
*
c
.
n14
+
d
.
n12
*
c
.
n24
+
d
.
n13
*
c
.
n34
+
d
.
n14
*
c
.
n44
;
this
.
n21
=
d
.
n21
*
c
.
n11
+
d
.
n22
*
c
.
n21
+
d
.
n23
*
c
.
n31
+
d
.
n24
*
c
.
n41
;
this
.
n22
=
d
.
n21
*
c
.
n12
+
d
.
n22
*
c
.
n22
+
d
.
n23
*
c
.
n32
+
d
.
n24
*
c
.
n42
;
this
.
n23
=
d
.
n21
*
c
.
n13
+
d
.
n22
*
c
.
n23
+
d
.
n23
*
c
.
n33
+
d
.
n24
*
c
.
n43
;
this
.
n24
=
d
.
n21
*
c
.
n14
+
d
.
n22
*
c
.
n24
+
d
.
n23
*
c
.
n34
+
d
.
n24
*
c
.
n44
;
this
.
n31
=
d
.
n31
*
c
.
n11
+
d
.
n32
*
c
.
n21
+
d
.
n33
*
c
.
n31
+
d
.
n34
*
c
.
n41
;
this
.
n32
=
d
.
n31
*
c
.
n12
+
d
.
n32
*
c
.
n22
+
d
.
n33
*
c
.
n32
+
d
.
n34
*
c
.
n42
;
this
.
n33
=
d
.
n31
*
c
.
n13
+
d
.
n32
*
c
.
n23
+
d
.
n33
*
c
.
n33
+
d
.
n34
*
c
.
n43
;
this
.
n34
=
d
.
n31
*
c
.
n14
+
d
.
n32
*
c
.
n24
+
d
.
n33
*
c
.
n34
+
d
.
n34
*
c
.
n44
;
this
.
n41
=
d
.
n41
*
c
.
n11
+
d
.
n42
*
c
.
n21
+
d
.
n43
*
c
.
n31
+
d
.
n44
*
c
.
n41
;
this
.
n42
=
d
.
n41
*
c
.
n12
+
d
.
n42
*
c
.
n22
+
d
.
n43
*
c
.
n32
+
d
.
n44
*
c
.
n42
;
this
.
n43
=
d
.
n41
*
c
.
n13
+
d
.
n42
*
c
.
n23
+
d
.
n43
*
c
.
n33
+
d
.
n44
*
c
.
n43
;
this
.
n44
=
d
.
n41
*
c
.
n14
+
d
.
n42
*
c
.
n24
+
d
.
n43
*
c
.
n34
+
d
.
n44
*
c
.
n44
},
multiplySelf
:
function
(
c
){
var
o
=
this
.
n11
,
n
=
this
.
n12
,
k
=
this
.
n13
,
i
=
this
.
n14
,
f
=
this
.
n21
,
e
=
this
.
n22
,
d
=
this
.
n23
,
b
=
this
.
n24
,
a
=
this
.
n31
,
r
=
this
.
n32
,
q
=
this
.
n33
,
p
=
this
.
n34
,
l
=
this
.
n41
,
j
=
this
.
n42
,
h
=
this
.
n43
,
g
=
this
.
n44
;
this
.
n11
=
o
*
c
.
n11
+
n
*
c
.
n21
+
k
*
c
.
n31
+
i
*
c
.
n41
;
this
.
n12
=
o
*
c
.
n12
+
n
*
c
.
n22
+
k
*
c
.
n32
+
i
*
c
.
n42
;
this
.
n13
=
o
*
c
.
n13
+
n
*
c
.
n23
+
k
*
c
.
n33
+
i
*
c
.
n43
;
this
.
n14
=
o
*
c
.
n14
+
n
*
c
.
n24
+
k
*
c
.
n34
+
i
*
c
.
n44
;
this
.
n21
=
f
*
c
.
n11
+
e
*
c
.
n21
+
d
*
c
.
n31
+
b
*
c
.
n41
;
this
.
n22
=
f
*
c
.
n12
+
e
*
c
.
n22
+
d
*
c
.
n32
+
b
*
c
.
n42
;
this
.
n23
=
f
*
c
.
n13
+
e
*
c
.
n23
+
d
*
c
.
n33
+
b
*
c
.
n43
;
this
.
n24
=
f
*
c
.
n14
+
e
*
c
.
n24
+
d
*
c
.
n34
+
b
*
c
.
n44
;
this
.
n31
=
a
*
c
.
n11
+
r
*
c
.
n21
+
q
*
c
.
n31
+
p
*
c
.
n41
;
this
.
n32
=
a
*
c
.
n12
+
r
*
c
.
n22
+
q
*
c
.
n32
+
p
*
c
.
n42
;
this
.
n33
=
a
*
c
.
n13
+
r
*
c
.
n23
+
q
*
c
.
n33
+
p
*
c
.
n43
;
this
.
n34
=
a
*
c
.
n14
+
r
*
c
.
n24
+
q
*
c
.
n34
+
p
*
c
.
n44
;
this
.
n41
=
l
*
c
.
n11
+
j
*
c
.
n21
+
h
*
c
.
n31
+
g
*
c
.
n41
;
this
.
n42
=
l
*
c
.
n12
+
j
*
c
.
n22
+
h
*
c
.
n32
+
g
*
c
.
n42
;
this
.
n43
=
l
*
c
.
n13
+
j
*
c
.
n23
+
h
*
c
.
n33
+
g
*
c
.
n43
;
this
.
n44
=
l
*
c
.
n14
+
j
*
c
.
n24
+
h
*
c
.
n34
+
g
*
c
.
n44
},
multiplyScalar
:
function
(
a
){
this
.
n11
*=
a
;
this
.
n12
*=
a
;
this
.
n13
*=
a
;
this
.
n14
*=
a
;
this
.
n21
*=
a
;
this
.
n22
*=
a
;
this
.
n23
*=
a
;
this
.
n24
*=
a
;
this
.
n31
*=
a
;
this
.
n32
*=
a
;
this
.
n33
*=
a
;
this
.
n34
*=
a
;
this
.
n41
*=
a
;
this
.
n42
*=
a
;
this
.
n43
*=
a
;
this
.
n44
*=
a
},
determinant
:
function
(){
return
(
this
.
n14
*
this
.
n23
*
this
.
n32
*
this
.
n41
-
this
.
n13
*
this
.
n24
*
this
.
n32
*
this
.
n41
-
this
.
n14
*
this
.
n22
*
this
.
n33
*
this
.
n41
+
this
.
n12
*
this
.
n24
*
this
.
n33
*
this
.
n41
+
this
.
n13
*
this
.
n22
*
this
.
n34
*
this
.
n41
-
this
.
n12
*
this
.
n23
*
this
.
n34
*
this
.
n41
-
this
.
n14
*
this
.
n23
*
this
.
n31
*
this
.
n42
+
this
.
n13
*
this
.
n24
*
this
.
n31
*
this
.
n42
+
this
.
n14
*
this
.
n21
*
this
.
n33
*
this
.
n42
-
this
.
n11
*
this
.
n24
*
this
.
n33
*
this
.
n42
-
this
.
n13
*
this
.
n21
*
this
.
n34
*
this
.
n42
+
this
.
n11
*
this
.
n23
*
this
.
n34
*
this
.
n42
+
this
.
n14
*
this
.
n22
*
this
.
n31
*
this
.
n43
-
this
.
n12
*
this
.
n24
*
this
.
n31
*
this
.
n43
-
this
.
n14
*
this
.
n21
*
this
.
n32
*
this
.
n43
+
this
.
n11
*
this
.
n24
*
this
.
n32
*
this
.
n43
+
this
.
n12
*
this
.
n21
*
this
.
n34
*
this
.
n43
-
this
.
n11
*
this
.
n22
*
this
.
n34
*
this
.
n43
-
this
.
n13
*
this
.
n22
*
this
.
n31
*
this
.
n44
+
this
.
n12
*
this
.
n23
*
this
.
n31
*
this
.
n44
+
this
.
n13
*
this
.
n21
*
this
.
n32
*
this
.
n44
-
this
.
n11
*
this
.
n23
*
this
.
n32
*
this
.
n44
-
this
.
n12
*
this
.
n21
*
this
.
n33
*
this
.
n44
+
this
.
n11
*
this
.
n22
*
this
.
n33
*
this
.
n44
)},
transpose
:
function
(){
function
a
(
d
,
e
,
c
){
var
b
=
d
[
e
];
d
[
e
]
=
d
[
c
];
d
[
c
]
=
b
}
a
(
this
,
"
n21
"
,
"
n12
"
);
a
(
this
,
"
n31
"
,
"
n13
"
);
a
(
this
,
"
n32
"
,
"
n23
"
);
a
(
this
,
"
n41
"
,
"
n14
"
);
a
(
this
,
"
n42
"
,
"
n24
"
);
a
(
this
,
"
n43
"
,
"
n34
"
);
return
this
},
clone
:
function
(){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
this
.
n11
;
a
.
n12
=
this
.
n12
;
a
.
n13
=
this
.
n13
;
a
.
n14
=
this
.
n14
;
a
.
n21
=
this
.
n21
;
a
.
n22
=
this
.
n22
;
a
.
n23
=
this
.
n23
;
a
.
n24
=
this
.
n24
;
a
.
n31
=
this
.
n31
;
a
.
n32
=
this
.
n32
;
a
.
n33
=
this
.
n33
;
a
.
n34
=
this
.
n34
;
a
.
n41
=
this
.
n41
;
a
.
n42
=
this
.
n42
;
a
.
n43
=
this
.
n43
;
a
.
n44
=
this
.
n44
;
return
a
},
flatten
:
function
(){
return
[
this
.
n11
,
this
.
n21
,
this
.
n31
,
this
.
n41
,
this
.
n12
,
this
.
n22
,
this
.
n32
,
this
.
n42
,
this
.
n13
,
this
.
n23
,
this
.
n33
,
this
.
n43
,
this
.
n14
,
this
.
n24
,
this
.
n34
,
this
.
n44
]},
toString
:
function
(){
return
"
|
"
+
this
.
n11
+
"
"
+
this
.
n12
+
"
"
+
this
.
n13
+
"
"
+
this
.
n14
+
"
|
\n
|
"
+
this
.
n21
+
"
"
+
this
.
n22
+
"
"
+
this
.
n23
+
"
"
+
this
.
n24
+
"
|
\n
|
"
+
this
.
n31
+
"
"
+
this
.
n32
+
"
"
+
this
.
n33
+
"
"
+
this
.
n34
+
"
|
\n
|
"
+
this
.
n41
+
"
"
+
this
.
n42
+
"
"
+
this
.
n43
+
"
"
+
this
.
n44
+
"
|
"
}};
THREE
.
Matrix4
.
translationMatrix
=
function
(
b
,
d
,
c
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n14
=
b
;
a
.
n24
=
d
;
a
.
n34
=
c
;
return
a
};
THREE
.
Matrix4
.
scaleMatrix
=
function
(
b
,
d
,
c
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
b
;
a
.
n22
=
d
;
a
.
n33
=
c
;
return
a
};
THREE
.
Matrix4
.
rotationXMatrix
=
function
(
b
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n22
=
a
.
n33
=
Math
.
cos
(
b
);
a
.
n32
=
Math
.
sin
(
b
);
a
.
n23
=-
a
.
n32
;
return
a
};
THREE
.
Matrix4
.
rotationYMatrix
=
function
(
b
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
a
.
n33
=
Math
.
cos
(
b
);
a
.
n13
=
Math
.
sin
(
b
);
a
.
n31
=-
a
.
n13
;
return
a
};
THREE
.
Matrix4
.
rotationZMatrix
=
function
(
b
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
a
.
n22
=
Math
.
cos
(
b
);
a
.
n21
=
Math
.
sin
(
b
);
a
.
n12
=-
a
.
n21
;
return
a
};
THREE
.
Matrix4
.
rotationAxisAngleMatrix
=
function
(
b
,
d
){
var
a
=
new
THREE
.
Matrix4
(),
f
=
Math
.
cos
(
d
),
j
=
Math
.
sin
(
d
),
i
=
1
-
f
,
h
=
b
.
x
,
g
=
b
.
y
,
e
=
b
.
z
;
a
.
n11
=
i
*
h
*
h
+
f
;
a
.
n12
=
i
*
h
*
g
-
j
*
e
;
a
.
n13
=
i
*
h
*
e
+
j
*
g
;
a
.
n21
=
i
*
h
*
g
+
j
*
e
;
a
.
n22
=
i
*
g
*
g
+
f
;
a
.
n23
=
i
*
g
*
e
-
j
*
h
;
a
.
n31
=
i
*
h
*
e
-
j
*
g
;
a
.
n32
=
i
*
g
*
e
+
j
*
h
;
a
.
n33
=
i
*
e
*
e
+
f
;
return
a
};
THREE
.
Matrix4
.
makeInvert
=
function
(
b
){
var
a
=
new
THREE
.
Matrix4
();
a
.
n11
=
b
.
n23
*
b
.
n34
*
b
.
n42
-
b
.
n24
*
b
.
n33
*
b
.
n42
+
b
.
n24
*
b
.
n32
*
b
.
n43
-
b
.
n22
*
b
.
n34
*
b
.
n43
-
b
.
n23
*
b
.
n32
*
b
.
n44
+
b
.
n22
*
b
.
n33
*
b
.
n44
;
a
.
n12
=
b
.
n14
*
b
.
n33
*
b
.
n42
-
b
.
n13
*
b
.
n34
*
b
.
n42
-
b
.
n14
*
b
.
n32
*
b
.
n43
+
b
.
n12
*
b
.
n34
*
b
.
n43
+
b
.
n13
*
b
.
n32
*
b
.
n44
-
b
.
n12
*
b
.
n33
*
b
.
n44
;
a
.
n13
=
b
.
n13
*
b
.
n24
*
b
.
n42
-
b
.
n14
*
b
.
n23
*
b
.
n42
+
b
.
n14
*
b
.
n22
*
b
.
n43
-
b
.
n12
*
b
.
n24
*
b
.
n43
-
b
.
n13
*
b
.
n22
*
b
.
n44
+
b
.
n12
*
b
.
n23
*
b
.
n44
;
a
.
n14
=
b
.
n14
*
b
.
n23
*
b
.
n32
-
b
.
n13
*
b
.
n24
*
b
.
n32
-
b
.
n14
*
b
.
n22
*
b
.
n33
+
b
.
n12
*
b
.
n24
*
b
.
n33
+
b
.
n13
*
b
.
n22
*
b
.
n34
-
b
.
n12
*
b
.
n23
*
b
.
n34
;
a
.
n21
=
b
.
n24
*
b
.
n33
*
b
.
n41
-
b
.
n23
*
b
.
n34
*
b
.
n41
-
b
.
n24
*
b
.
n31
*
b
.
n43
+
b
.
n21
*
b
.
n34
*
b
.
n43
+
b
.
n23
*
b
.
n31
*
b
.
n44
-
b
.
n21
*
b
.
n33
*
b
.
n44
;
a
.
n22
=
b
.
n13
*
b
.
n34
*
b
.
n41
-
b
.
n14
*
b
.
n33
*
b
.
n41
+
b
.
n14
*
b
.
n31
*
b
.
n43
-
b
.
n11
*
b
.
n34
*
b
.
n43
-
b
.
n13
*
b
.
n31
*
b
.
n44
+
b
.
n11
*
b
.
n33
*
b
.
n44
;
a
.
n23
=
b
.
n14
*
b
.
n23
*
b
.
n41
-
b
.
n13
*
b
.
n24
*
b
.
n41
-
b
.
n14
*
b
.
n21
*
b
.
n43
+
b
.
n11
*
b
.
n24
*
b
.
n43
+
b
.
n13
*
b
.
n21
*
b
.
n44
-
b
.
n11
*
b
.
n23
*
b
.
n44
;
a
.
n24
=
b
.
n13
*
b
.
n24
*
b
.
n31
-
b
.
n14
*
b
.
n23
*
b
.
n31
+
b
.
n14
*
b
.
n21
*
b
.
n33
-
b
.
n11
*
b
.
n24
*
b
.
n33
-
b
.
n13
*
b
.
n21
*
b
.
n34
+
b
.
n11
*
b
.
n23
*
b
.
n34
;
a
.
n31
=
b
.
n22
*
b
.
n34
*
b
.
n41
-
b
.
n24
*
b
.
n32
*
b
.
n41
+
b
.
n24
*
b
.
n31
*
b
.
n42
-
b
.
n21
*
b
.
n34
*
b
.
n42
-
b
.
n22
*
b
.
n31
*
b
.
n44
+
b
.
n21
*
b
.
n32
*
b
.
n44
;
a
.
n32
=
b
.
n14
*
b
.
n32
*
b
.
n41
-
b
.
n12
*
b
.
n34
*
b
.
n41
-
b
.
n14
*
b
.
n31
*
b
.
n42
+
b
.
n11
*
b
.
n34
*
b
.
n42
+
b
.
n12
*
b
.
n31
*
b
.
n44
-
b
.
n11
*
b
.
n32
*
b
.
n44
;
a
.
n33
=
b
.
n13
*
b
.
n24
*
b
.
n41
-
b
.
n14
*
b
.
n22
*
b
.
n41
+
b
.
n14
*
b
.
n21
*
b
.
n42
-
b
.
n11
*
b
.
n24
*
b
.
n42
-
b
.
n12
*
b
.
n21
*
b
.
n44
+
b
.
n11
*
b
.
n22
*
b
.
n44
;
a
.
n34
=
b
.
n14
*
b
.
n22
*
b
.
n31
-
b
.
n12
*
b
.
n24
*
b
.
n31
-
b
.
n14
*
b
.
n21
*
b
.
n32
+
b
.
n11
*
b
.
n24
*
b
.
n32
+
b
.
n12
*
b
.
n21
*
b
.
n34
-
b
.
n11
*
b
.
n22
*
b
.
n34
;
a
.
n41
=
b
.
n23
*
b
.
n32
*
b
.
n41
-
b
.
n22
*
b
.
n33
*
b
.
n41
-
b
.
n23
*
b
.
n31
*
b
.
n42
+
b
.
n21
*
b
.
n33
*
b
.
n42
+
b
.
n22
*
b
.
n31
*
b
.
n43
-
b
.
n21
*
b
.
n32
*
b
.
n43
;
a
.
n42
=
b
.
n12
*
b
.
n33
*
b
.
n41
-
b
.
n13
*
b
.
n32
*
b
.
n41
+
b
.
n13
*
b
.
n31
*
b
.
n42
-
b
.
n11
*
b
.
n33
*
b
.
n42
-
b
.
n12
*
b
.
n31
*
b
.
n43
+
b
.
n11
*
b
.
n32
*
b
.
n43
;
a
.
n43
=
b
.
n13
*
b
.
n22
*
b
.
n41
-
b
.
n12
*
b
.
n23
*
b
.
n41
-
b
.
n13
*
b
.
n21
*
b
.
n42
+
b
.
n11
*
b
.
n23
*
b
.
n42
+
b
.
n12
*
b
.
n21
*
b
.
n43
-
b
.
n11
*
b
.
n22
*
b
.
n43
;
a
.
n44
=
b
.
n12
*
b
.
n23
*
b
.
n31
-
b
.
n13
*
b
.
n22
*
b
.
n31
+
b
.
n13
*
b
.
n21
*
b
.
n32
-
b
.
n11
*
b
.
n23
*
b
.
n32
-
b
.
n12
*
b
.
n21
*
b
.
n33
+
b
.
n11
*
b
.
n22
*
b
.
n33
;
a
.
multiplyScalar
(
1
/
b
.
determinant
());
return
a
};
THREE
.
Matrix4
.
makeInvert3x3
=
function
(
o
){
var
e
=
o
.
flatten
(),
l
=
new
THREE
.
Matrix3
(),
n
=
e
[
10
]
*
e
[
5
]
-
e
[
6
]
*
e
[
9
],
i
=-
e
[
10
]
*
e
[
1
]
+
e
[
2
]
*
e
[
9
],
d
=
e
[
6
]
*
e
[
1
]
-
e
[
2
]
*
e
[
5
],
k
=-
e
[
10
]
*
e
[
4
]
+
e
[
6
]
*
e
[
8
],
g
=
e
[
10
]
*
e
[
0
]
-
e
[
2
]
*
e
[
8
],
c
=-
e
[
6
]
*
e
[
0
]
+
e
[
2
]
*
e
[
4
],
j
=
e
[
9
]
*
e
[
4
]
-
e
[
5
]
*
e
[
8
],
f
=-
e
[
9
]
*
e
[
0
]
+
e
[
1
]
*
e
[
8
],
a
=
e
[
5
]
*
e
[
0
]
-
e
[
1
]
*
e
[
4
],
h
=
e
[
0
]
*
(
n
)
+
e
[
1
]
*
(
k
)
+
e
[
2
]
*
(
j
),
b
;
if
(
h
==
0
){
throw
"
matrix not invertible
"
}
b
=
1
/
h
;
l
.
m
[
0
]
=
b
*
n
;
l
.
m
[
1
]
=
b
*
i
;
l
.
m
[
2
]
=
b
*
d
;
l
.
m
[
3
]
=
b
*
k
;
l
.
m
[
4
]
=
b
*
g
;
l
.
m
[
5
]
=
b
*
c
;
l
.
m
[
6
]
=
b
*
j
;
l
.
m
[
7
]
=
b
*
f
;
l
.
m
[
8
]
=
b
*
a
;
return
l
};
THREE
.
Matrix4
.
makeFrustum
=
function
(
f
,
r
,
e
,
o
,
i
,
h
){
var
g
,
q
,
n
,
p
,
l
,
k
,
j
;
g
=
new
THREE
.
Matrix4
();
q
=
2
*
i
/
(
r
-
f
);
n
=
2
*
i
/
(
o
-
e
);
p
=
(
r
+
f
)
/
(
r
-
f
);
l
=
(
o
+
e
)
/
(
o
-
e
);
k
=-
(
h
+
i
)
/
(
h
-
i
);
j
=-
2
*
h
*
i
/
(
h
-
i
);
g
.
n11
=
q
;
g
.
n12
=
0
;
g
.
n13
=
p
;
g
.
n14
=
0
;
g
.
n21
=
0
;
g
.
n22
=
n
;
g
.
n23
=
l
;
g
.
n24
=
0
;
g
.
n31
=
0
;
g
.
n32
=
0
;
g
.
n33
=
k
;
g
.
n34
=
j
;
g
.
n41
=
0
;
g
.
n42
=
0
;
g
.
n43
=-
1
;
g
.
n44
=
0
;
return
g
};
THREE
.
Matrix4
.
makePerspective
=
function
(
e
,
c
,
g
,
b
){
var
a
,
f
,
h
,
d
;
a
=
g
*
Math
.
tan
(
e
*
Math
.
PI
/
360
);
f
=-
a
;
h
=
f
*
c
;
d
=
a
*
c
;
return
THREE
.
Matrix4
.
makeFrustum
(
h
,
d
,
f
,
a
,
g
,
b
)};
THREE
.
Matrix4
.
makeOrtho
=
function
(
c
,
o
,
k
,
a
,
g
,
f
){
var
d
,
l
,
j
,
i
,
n
,
e
,
b
;
d
=
new
THREE
.
Matrix4
();
n
=
o
-
c
;
e
=
k
-
a
;
b
=
f
-
g
;
l
=
(
o
+
c
)
/
n
;
j
=
(
k
+
a
)
/
e
;
i
=
(
f
+
g
)
/
b
;
d
.
n11
=
2
/
n
;
d
.
n12
=
0
;
d
.
n13
=
0
;
d
.
n14
=-
l
;
d
.
n21
=
0
;
d
.
n22
=
2
/
e
;
d
.
n23
=
0
;
d
.
n24
=-
j
;
d
.
n31
=
0
;
d
.
n32
=
0
;
d
.
n33
=-
2
/
b
;
d
.
n34
=-
i
;
d
.
n41
=
0
;
d
.
n42
=
0
;
d
.
n43
=
0
;
d
.
n44
=
1
;
return
d
};
THREE
.
Vertex
=
function
(
a
,
b
){
this
.
position
=
a
||
new
THREE
.
Vector3
();
this
.
positionWorld
=
new
THREE
.
Vector3
();
this
.
positionScreen
=
new
THREE
.
Vector3
();
this
.
normal
=
b
||
new
THREE
.
Vector3
();
this
.
normalWorld
=
new
THREE
.
Vector3
();
this
.
normalScreen
=
new
THREE
.
Vector3
();
this
.
__visible
=
true
};
THREE
.
Vertex
.
prototype
=
{
toString
:
function
(){
return
"
THREE.Vertex ( position:
"
+
this
.
position
+
"
, normal:
"
+
this
.
normal
+
"
)
"
}};
THREE
.
Face3
=
function
(
e
,
d
,
h
,
g
,
f
){
this
.
a
=
e
;
this
.
b
=
d
;
this
.
c
=
h
;
this
.
centroid
=
new
THREE
.
Vector3
();
this
.
normal
=
g
instanceof
THREE
.
Vector3
?
g
:
new
THREE
.
Vector3
();
this
.
vertexNormals
=
g
instanceof
Array
?
g
:[];
this
.
material
=
f
instanceof
Array
?
f
:[
f
]};
THREE
.
Face3
.
prototype
=
{
toString
:
function
(){
return
"
THREE.Face3 (
"
+
this
.
a
+
"
,
"
+
this
.
b
+
"
,
"
+
this
.
c
+
"
)
"
}};
THREE
.
Face4
=
function
(
f
,
e
,
j
,
i
,
h
,
g
){
this
.
a
=
f
;
this
.
b
=
e
;
this
.
c
=
j
;
this
.
d
=
i
;
this
.
centroid
=
new
THREE
.
Vector3
();
this
.
normal
=
h
instanceof
THREE
.
Vector3
?
h
:
new
THREE
.
Vector3
();
this
.
vertexNormals
=
h
instanceof
Array
?
h
:[];
this
.
material
=
g
instanceof
Array
?
g
:[
g
]};
THREE
.
Face4
.
prototype
=
{
toString
:
function
(){
return
"
THREE.Face4 (
"
+
this
.
a
+
"
,
"
+
this
.
b
+
"
,
"
+
this
.
c
+
"
"
+
this
.
d
+
"
)
"
}};
THREE
.
UV
=
function
(
b
,
a
){
this
.
u
=
b
||
0
;
this
.
v
=
a
||
0
};
THREE
.
UV
.
prototype
=
{
copy
:
function
(
a
){
this
.
u
=
a
.
u
;
this
.
v
=
a
.
v
},
toString
:
function
(){
return
"
THREE.UV (
"
+
this
.
u
+
"
,
"
+
this
.
v
+
"
)
"
}};
THREE
.
Geometry
=
function
(){
this
.
vertices
=
[];
this
.
faces
=
[];
this
.
uvs
=
[]};
THREE
.
Geometry
.
prototype
=
{
computeCentroids
:
function
(){
var
c
,
b
,
a
;
for
(
c
=
0
,
b
=
this
.
faces
.
length
;
c
<
b
;
c
++
){
a
=
this
.
faces
[
c
];
a
.
centroid
.
set
(
0
,
0
,
0
);
if
(
a
instanceof
THREE
.
Face3
){
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
a
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
b
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
c
].
position
);
a
.
centroid
.
divideScalar
(
3
)}
else
{
if
(
a
instanceof
THREE
.
Face4
){
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
a
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
b
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
c
].
position
);
a
.
centroid
.
addSelf
(
this
.
vertices
[
a
.
d
].
position
);
a
.
centroid
.
divideScalar
(
4
)}}}},
computeNormals
:
function
(
m
){
var
e
,
b
,
o
,
g
,
i
,
j
,
l
,
k
,
d
,
c
,
a
,
h
=
new
THREE
.
Vector3
(),
p
=
new
THREE
.
Vector3
();
for
(
o
=
0
,
g
=
this
.
vertices
.
length
;
o
<
g
;
o
++
){
i
=
this
.
vertices
[
o
];
i
.
normal
.
set
(
0
,
0
,
0
)}
for
(
j
=
0
,
l
=
this
.
faces
.
length
;
j
<
l
;
j
++
){
k
=
this
.
faces
[
j
];
if
(
m
&&
k
.
vertexNormals
.
length
){
h
.
set
(
0
,
0
,
0
);
for
(
e
=
0
,
b
=
k
.
normal
.
length
;
e
<
b
;
e
++
){
h
.
addSelf
(
k
.
vertexNormals
[
e
])}
h
.
divideScalar
(
3
);
if
(
!
h
.
isZero
()){
h
.
normalize
()}
k
.
normal
.
copy
(
h
)}
else
{
d
=
this
.
vertices
[
k
.
a
];
c
=
this
.
vertices
[
k
.
b
];
a
=
this
.
vertices
[
k
.
c
];
h
.
sub
(
a
.
position
,
c
.
position
);
p
.
sub
(
d
.
position
,
c
.
position
);
h
.
crossSelf
(
p
);
if
(
!
h
.
isZero
()){
h
.
normalize
()}
k
.
normal
.
copy
(
h
)}}},
computeBoundingBox
:
function
(){
if
(
this
.
vertices
.
length
>
0
){
this
.
bbox
=
{
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
a
=
1
,
b
=
this
.
vertices
.
length
;
a
<
b
;
a
++
){
vertex
=
this
.
vertices
[
a
];
if
(
vertex
.
position
.
x
<
this
.
bbox
.
x
[
0
]){
this
.
bbox
.
x
[
0
]
=
vertex
.
position
.
x
}
else
{
if
(
vertex
.
position
.
x
>
this
.
bbox
.
x
[
1
]){
this
.
bbox
.
x
[
1
]
=
vertex
.
position
.
x
}}
if
(
vertex
.
position
.
y
<
this
.
bbox
.
y
[
0
]){
this
.
bbox
.
y
[
0
]
=
vertex
.
position
.
y
}
else
{
if
(
vertex
.
position
.
y
>
this
.
bbox
.
y
[
1
]){
this
.
bbox
.
y
[
1
]
=
vertex
.
position
.
y
}}
if
(
vertex
.
position
.
z
<
this
.
bbox
.
z
[
0
]){
this
.
bbox
.
z
[
0
]
=
vertex
.
position
.
z
}
else
{
if
(
vertex
.
position
.
z
>
this
.
bbox
.
z
[
1
]){
this
.
bbox
.
z
[
1
]
=
vertex
.
position
.
z
}}}}},
toString
:
function
(){
return
"
THREE.Geometry ( vertices:
"
+
this
.
vertices
+
"
, faces:
"
+
this
.
faces
+
"
)
"
}};
THREE
.
Camera
=
function
(
c
,
b
,
d
,
a
){
this
.
position
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
this
.
target
=
{
position
:
new
THREE
.
Vector3
(
0
,
0
,
0
)};
this
.
up
=
new
THREE
.
Vector3
(
0
,
1
,
0
);
this
.
matrix
=
new
THREE
.
Matrix4
();
this
.
projectionMatrix
=
THREE
.
Matrix4
.
makePerspective
(
c
,
b
,
d
,
a
);
this
.
autoUpdateMatrix
=
true
;
this
.
updateMatrix
=
function
(){
this
.
matrix
.
lookAt
(
this
.
position
,
this
.
target
.
position
,
this
.
up
)};
this
.
toString
=
function
(){
return
"
THREE.Camera (
"
+
this
.
position
+
"
,
"
+
this
.
target
.
position
+
"
)
"
}};
THREE
.
Loader
=
function
(){};
THREE
.
Loader
.
prototype
=
{
loadAsciiOld
:
function
(
a
,
c
){
var
b
=
document
.
createElement
(
"
script
"
);
b
.
type
=
"
text/javascript
"
;
b
.
onload
=
c
;
b
.
src
=
a
;
document
.
getElementsByTagName
(
"
head
"
)[
0
].
appendChild
(
b
)},
loadAscii
:
function
(
a
,
e
,
b
){
var
c
=
(
new
Date
).
getTime
(),
d
=
new
Worker
(
a
);
d
.
onmessage
=
function
(
f
){
THREE
.
Loader
.
prototype
.
createModel
(
f
.
data
,
e
,
b
)};
d
.
postMessage
(
c
)},
loadBinary
:
function
(
a
,
e
,
b
){
var
c
=
(
new
Date
).
getTime
(),
d
=
new
Worker
(
a
);
d
.
onmessage
=
function
(
h
){
var
g
=
h
.
data
.
materials
,
f
=
h
.
data
.
buffers
;
THREE
.
Loader
.
prototype
.
loadAjaxBuffers
(
f
,
g
,
e
,
b
)};
d
.
onerror
=
function
(
f
){
alert
(
"
worker.onerror:
"
+
f
.
message
+
"
\n
"
+
f
.
data
);
f
.
preventDefault
()};
d
.
postMessage
(
c
)},
loadAjaxBuffers
:
function
(
b
,
a
,
f
,
d
){
var
e
=
new
XMLHttpRequest
(),
c
=
d
+
"
/
"
+
b
;
e
.
onreadystatechange
=
function
(){
if
(
e
.
readyState
==
4
){
if
(
e
.
status
==
200
||
e
.
status
==
0
){
THREE
.
Loader
.
prototype
.
createBinModel
(
e
.
responseText
,
f
,
d
,
a
)}
else
{
alert
(
"
Couldn't load [
"
+
c
+
"
] [
"
+
e
.
status
+
"
]
"
)}}};
e
.
open
(
"
GET
"
,
c
,
true
);
e
.
overrideMimeType
(
"
text/plain; charset=x-user-defined
"
);
e
.
setRequestHeader
(
"
Content-Type
"
,
"
text/plain
"
);
e
.
send
(
null
)},
createBinModel
:
function
(
c
,
e
,
b
,
a
){
var
d
=
function
(
aa
){
var
I
=
this
,
h
=
0
,
x
,
A
=
[],
L
=
[],
V
,
T
,
O
,
U
,
R
,
P
,
D
,
C
,
B
,
y
,
r
,
q
,
p
,
o
,
u
,
t
,
N
,
K
,
J
;
THREE
.
Geometry
.
call
(
this
);
THREE
.
Loader
.
prototype
.
init_materials
(
I
,
a
,
aa
);
x
=
W
(
c
,
h
);
h
+=
x
.
header_bytes
;
V
=
x
.
vertex_index_bytes
,
T
=
x
.
vertex_index_bytes
*
2
,
O
=
x
.
vertex_index_bytes
*
3
,
U
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
,
R
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
,
P
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
2
,
D
=
x
.
vertex_index_bytes
,
C
=
x
.
vertex_index_bytes
*
2
,
B
=
x
.
vertex_index_bytes
*
3
,
y
=
x
.
vertex_index_bytes
*
4
,
r
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
,
q
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
,
p
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
2
,
o
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
3
,
u
=
x
.
uv_index_bytes
,
t
=
x
.
uv_index_bytes
*
2
,
N
=
x
.
uv_index_bytes
,
K
=
x
.
uv_index_bytes
*
2
,
J
=
x
.
uv_index_bytes
*
3
;
h
+=
w
(
h
);
h
+=
H
(
h
);
h
+=
G
(
h
);
h
+=
Q
(
h
);
h
+=
S
(
h
);
h
+=
ab
(
h
);
h
+=
n
(
h
);
h
+=
g
(
h
);
h
+=
k
(
h
);
h
+=
s
(
h
);
h
+=
z
(
h
);
this
.
computeCentroids
();
this
.
computeNormals
();
function
W
(
ad
,
ae
){
var
ac
=
{
signature
:
F
(
ad
,
ae
,
8
),
header_bytes
:
j
(
ad
,
ae
+
8
),
vertex_coordinate_bytes
:
j
(
ad
,
ae
+
9
),
normal_coordinate_bytes
:
j
(
ad
,
ae
+
10
),
uv_coordinate_bytes
:
j
(
ad
,
ae
+
11
),
vertex_index_bytes
:
j
(
ad
,
ae
+
12
),
normal_index_bytes
:
j
(
ad
,
ae
+
13
),
uv_index_bytes
:
j
(
ad
,
ae
+
14
),
material_index_bytes
:
j
(
ad
,
ae
+
15
),
nvertices
:
v
(
ad
,
ae
+
16
),
nnormals
:
v
(
ad
,
ae
+
16
+
4
*
1
),
nuvs
:
v
(
ad
,
ae
+
16
+
4
*
2
),
ntri_flat
:
v
(
ad
,
ae
+
16
+
4
*
3
),
ntri_smooth
:
v
(
ad
,
ae
+
16
+
4
*
4
),
ntri_flat_uv
:
v
(
ad
,
ae
+
16
+
4
*
5
),
ntri_smooth_uv
:
v
(
ad
,
ae
+
16
+
4
*
6
),
nquad_flat
:
v
(
ad
,
ae
+
16
+
4
*
7
),
nquad_smooth
:
v
(
ad
,
ae
+
16
+
4
*
8
),
nquad_flat_uv
:
v
(
ad
,
ae
+
16
+
4
*
9
),
nquad_smooth_uv
:
v
(
ad
,
ae
+
16
+
4
*
10
)};
return
ac
}
function
F
(
ad
,
ae
,
ac
){
return
ad
.
substr
(
ae
,
ac
)}
function
f
(
af
,
ae
){
var
ag
=
j
(
af
,
ae
),
ai
=
j
(
af
,
ae
+
1
),
aj
=
j
(
af
,
ae
+
2
),
ak
=
j
(
af
,
ae
+
3
),
ad
=
1
-
(
2
*
(
ak
>>
7
)),
ah
=
(((
ak
<<
1
)
&
255
)
|
(
aj
>>
7
))
-
127
,
ac
=
((
aj
&
127
)
<<
16
)
|
(
ai
<<
8
)
|
ag
;
if
(
ac
==
0
&&
ah
==-
127
){
return
0
}
return
ad
*
(
1
+
ac
*
Math
.
pow
(
2
,
-
23
))
*
Math
.
pow
(
2
,
ah
)}
function
v
(
ag
,
ah
){
var
af
=
j
(
ag
,
ah
),
ae
=
j
(
ag
,
ah
+
1
),
ad
=
j
(
ag
,
ah
+
2
),
ac
=
j
(
ag
,
ah
+
3
);
return
(
ac
<<
24
)
+
(
ad
<<
16
)
+
(
ae
<<
8
)
+
af
}
function
Z
(
ae
,
af
){
var
ad
=
j
(
ae
,
af
),
ac
=
j
(
ae
,
af
+
1
);
return
(
ac
<<
8
)
+
ad
}
function
i
(
ad
,
ae
){
var
ac
=
j
(
ad
,
ae
);
return
ac
>
127
?
ac
-
256
:
ac
}
function
j
(
ac
,
ad
){
return
ac
.
charCodeAt
(
ad
)
&
255
}
function
w
(
ai
){
var
ae
,
ac
,
ah
,
ag
,
af
=
x
.
vertex_coordinate_bytes
*
3
,
ad
=
ai
+
x
.
nvertices
*
af
;
for
(
ae
=
ai
;
ae
<
ad
;
ae
+=
af
){
ac
=
f
(
c
,
ae
);
ah
=
f
(
c
,
ae
+
x
.
vertex_coordinate_bytes
);
ag
=
f
(
c
,
ae
+
x
.
vertex_coordinate_bytes
*
2
);
THREE
.
Loader
.
prototype
.
v
(
I
,
ac
,
ah
,
ag
)}
return
x
.
nvertices
*
af
}
function
H
(
ai
){
var
ae
,
ac
,
ah
,
ag
,
af
=
x
.
normal_coordinate_bytes
*
3
,
ad
=
ai
+
x
.
nnormals
*
af
;
for
(
ae
=
ai
;
ae
<
ad
;
ae
+=
af
){
ac
=
i
(
c
,
ae
);
ah
=
i
(
c
,
ae
+
x
.
normal_coordinate_bytes
);
ag
=
i
(
c
,
ae
+
x
.
normal_coordinate_bytes
*
2
);
A
.
push
(
ac
/
127
,
ah
/
127
,
ag
/
127
)}
return
x
.
nnormals
*
af
}
function
G
(
ah
){
var
af
,
ae
,
ad
,
ag
=
x
.
uv_coordinate_bytes
*
2
,
ac
=
ah
+
x
.
nuvs
*
ag
;
for
(
af
=
ah
;
af
<
ac
;
af
+=
ag
){
ae
=
f
(
c
,
af
);
ad
=
f
(
c
,
af
+
x
.
uv_coordinate_bytes
);
L
.
push
(
ae
,
ad
)}
return
x
.
nuvs
*
ag
}
function
M
(
af
){
var
ae
,
ad
,
ag
,
ac
;
ae
=
v
(
c
,
af
);
ad
=
v
(
c
,
af
+
V
);
ag
=
v
(
c
,
af
+
T
);
ac
=
Z
(
c
,
af
+
O
);
THREE
.
Loader
.
prototype
.
f3
(
I
,
ae
,
ad
,
ag
,
ac
)}
function
m
(
ah
){
var
ag
,
ae
,
aj
,
ad
,
af
,
ac
,
ai
;
ag
=
v
(
c
,
ah
);
ae
=
v
(
c
,
ah
+
V
);
aj
=
v
(
c
,
ah
+
T
);
ad
=
Z
(
c
,
ah
+
O
);
af
=
v
(
c
,
ah
+
U
);
ac
=
v
(
c
,
ah
+
R
);
ai
=
v
(
c
,
ah
+
P
);
THREE
.
Loader
.
prototype
.
f3n
(
I
,
A
,
ag
,
ae
,
aj
,
ad
,
af
,
ac
,
ai
)}
function
E
(
af
){
var
ae
,
ad
,
ah
,
ag
,
ac
;
ae
=
v
(
c
,
af
);
ad
=
v
(
c
,
af
+
D
);
ah
=
v
(
c
,
af
+
C
);
ag
=
v
(
c
,
af
+
B
);
ac
=
Z
(
c
,
af
+
y
);
THREE
.
Loader
.
prototype
.
f4
(
I
,
ae
,
ad
,
ah
,
ag
,
ac
)}
function
l
(
af
){
var
al
,
ak
,
aj
,
ai
,
ac
,
ah
,
ag
,
ae
,
ad
;
al
=
v
(
c
,
af
);
ak
=
v
(
c
,
af
+
D
);
aj
=
v
(
c
,
af
+
C
);
ai
=
v
(
c
,
af
+
B
);
ac
=
Z
(
c
,
af
+
y
);
ah
=
v
(
c
,
af
+
r
);
ag
=
v
(
c
,
af
+
q
);
ae
=
v
(
c
,
af
+
p
);
ad
=
v
(
c
,
af
+
o
);
THREE
.
Loader
.
prototype
.
f4n
(
I
,
A
,
al
,
ak
,
aj
,
ai
,
ac
,
ah
,
ag
,
ae
,
ad
)}
function
Y
(
ai
){
var
ah
,
ae
,
ac
,
ag
,
af
,
ad
,
al
,
ak
,
aj
;
ah
=
v
(
c
,
ai
);
ae
=
v
(
c
,
ai
+
u
);
ac
=
v
(
c
,
ai
+
t
);
ag
=
L
[
ah
*
2
];
al
=
L
[
ah
*
2
+
1
];
af
=
L
[
ae
*
2
];
ak
=
L
[
ae
*
2
+
1
];
ad
=
L
[
ac
*
2
];
aj
=
L
[
ac
*
2
+
1
];
THREE
.
Loader
.
prototype
.
uv
(
I
,
ag
,
al
,
af
,
ak
,
ad
,
aj
)}
function
X
(
ak
){
var
aj
,
ag
,
ae
,
ad
,
ai
,
ah
,
af
,
ac
,
ao
,
an
,
am
,
al
;
aj
=
v
(
c
,
ak
);
ag
=
v
(
c
,
ak
+
N
);
ae
=
v
(
c
,
ak
+
K
);
ad
=
v
(
c
,
ak
+
J
);
ai
=
L
[
aj
*
2
];
ao
=
L
[
aj
*
2
+
1
];
ah
=
L
[
ag
*
2
];
an
=
L
[
ag
*
2
+
1
];
af
=
L
[
ae
*
2
];
am
=
L
[
ae
*
2
+
1
];
ac
=
L
[
ad
*
2
];
al
=
L
[
ad
*
2
+
1
];
THREE
.
Loader
.
prototype
.
uv
(
I
,
ai
,
ao
,
ah
,
an
,
af
,
am
,
ac
,
al
)}
function
Q
(
af
){
var
ad
,
ae
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
,
ac
=
af
+
x
.
ntri_flat
*
ae
;
for
(
ad
=
af
;
ad
<
ac
;
ad
+=
ae
){
M
(
ad
)}
return
ac
-
af
}
function
ab
(
ag
){
var
ad
,
af
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
,
ae
=
af
+
x
.
uv_index_bytes
*
3
,
ac
=
ag
+
x
.
ntri_flat_uv
*
ae
;
for
(
ad
=
ag
;
ad
<
ac
;
ad
+=
ae
){
M
(
ad
);
Y
(
ad
+
af
)}
return
ac
-
ag
}
function
S
(
af
){
var
ad
,
ae
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
3
,
ac
=
af
+
x
.
ntri_smooth
*
ae
;
for
(
ad
=
af
;
ad
<
ac
;
ad
+=
ae
){
m
(
ad
)}
return
ac
-
af
}
function
n
(
ag
){
var
ad
,
af
=
x
.
vertex_index_bytes
*
3
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
3
,
ae
=
af
+
x
.
uv_index_bytes
*
3
,
ac
=
ag
+
x
.
ntri_smooth_uv
*
ae
;
for
(
ad
=
ag
;
ad
<
ac
;
ad
+=
ae
){
m
(
ad
);
Y
(
ad
+
af
)}
return
ac
-
ag
}
function
g
(
af
){
var
ad
,
ae
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
,
ac
=
af
+
x
.
nquad_flat
*
ae
;
for
(
ad
=
af
;
ad
<
ac
;
ad
+=
ae
){
E
(
ad
)}
return
ac
-
af
}
function
s
(
ag
){
var
ad
,
af
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
,
ae
=
af
+
x
.
uv_index_bytes
*
4
,
ac
=
ag
+
x
.
nquad_flat_uv
*
ae
;
for
(
ad
=
ag
;
ad
<
ac
;
ad
+=
ae
){
E
(
ad
);
X
(
ad
+
af
)}
return
ac
-
ag
}
function
k
(
af
){
var
ad
,
ae
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
4
,
ac
=
af
+
x
.
nquad_smooth
*
ae
;
for
(
ad
=
af
;
ad
<
ac
;
ad
+=
ae
){
l
(
ad
)}
return
ac
-
af
}
function
z
(
ag
){
var
ad
,
af
=
x
.
vertex_index_bytes
*
4
+
x
.
material_index_bytes
+
x
.
normal_index_bytes
*
4
,
ae
=
af
+
x
.
uv_index_bytes
*
4
,
ac
=
ag
+
x
.
nquad_smooth_uv
*
ae
;
for
(
ad
=
ag
;
ad
<
ac
;
ad
+=
ae
){
l
(
ad
);
X
(
ad
+
af
)}
return
ac
-
ag
}};
d
.
prototype
=
new
THREE
.
Geometry
();
d
.
prototype
.
constructor
=
d
;
e
(
new
d
(
b
))},
createModel
:
function
(
b
,
d
,
a
){
var
c
=
function
(
f
){
var
g
=
this
;
THREE
.
Geometry
.
call
(
this
);
THREE
.
Loader
.
prototype
.
init_materials
(
g
,
b
.
materials
,
f
);
e
();
h
();
this
.
computeCentroids
();
this
.
computeNormals
();
function
e
(){
var
m
,
k
,
j
,
o
,
n
;
for
(
m
=
0
,
k
=
b
.
vertices
.
length
;
m
<
k
;
m
+=
3
){
j
=
b
.
vertices
[
m
];
o
=
b
.
vertices
[
m
+
1
];
n
=
b
.
vertices
[
m
+
2
];
THREE
.
Loader
.
prototype
.
v
(
g
,
j
,
o
,
n
)}}
function
h
(){
function
p
(
v
,
u
){
var
t
,
s
,
w
,
l
;
t
=
v
[
u
];
s
=
v
[
u
+
1
];
w
=
v
[
u
+
2
];
l
=
v
[
u
+
3
];
THREE
.
Loader
.
prototype
.
f3
(
g
,
t
,
s
,
w
,
l
)}
function
k
(
l
,
u
){
var
z
,
y
,
x
,
s
,
w
,
v
,
t
;
z
=
l
[
u
];
y
=
l
[
u
+
1
];
x
=
l
[
u
+
2
];
s
=
l
[
u
+
3
];
w
=
l
[
u
+
4
];
v
=
l
[
u
+
5
];
t
=
l
[
u
+
6
];
THREE
.
Loader
.
prototype
.
f3n
(
g
,
b
.
normals
,
z
,
y
,
x
,
s
,
w
,
v
,
t
)}
function
o
(
w
,
u
){
var
t
,
s
,
x
,
v
,
l
;
t
=
w
[
u
];
s
=
w
[
u
+
1
];
x
=
w
[
u
+
2
];
v
=
w
[
u
+
3
];
l
=
w
[
u
+
4
];
THREE
.
Loader
.
prototype
.
f4
(
g
,
t
,
s
,
x
,
v
,
l
)}
function
j
(
l
,
v
){
var
B
,
A
,
z
,
y
,
s
,
x
,
w
,
u
,
t
;
B
=
l
[
v
];
A
=
l
[
v
+
1
];
z
=
l
[
v
+
2
];
y
=
l
[
v
+
3
];
s
=
l
[
v
+
4
];
x
=
l
[
v
+
5
];
w
=
l
[
v
+
6
];
u
=
l
[
v
+
7
];
t
=
l
[
v
+
8
];
THREE
.
Loader
.
prototype
.
f4n
(
g
,
b
.
normals
,
B
,
A
,
z
,
y
,
s
,
x
,
w
,
u
,
t
)}
function
r
(
l
,
y
){
var
x
,
u
,
s
,
w
,
v
,
t
,
B
,
A
,
z
;
x
=
l
[
y
];
u
=
l
[
y
+
1
];
s
=
l
[
y
+
2
];
w
=
b
.
uvs
[
x
*
2
];
B
=
b
.
uvs
[
x
*
2
+
1
];
v
=
b
.
uvs
[
u
*
2
];
A
=
b
.
uvs
[
u
*
2
+
1
];
t
=
b
.
uvs
[
s
*
2
];
z
=
b
.
uvs
[
s
*
2
+
1
];
THREE
.
Loader
.
prototype
.
uv
(
g
,
w
,
B
,
v
,
A
,
t
,
z
)}
function
q
(
s
,
A
){
var
z
,
w
,
v
,
t
,
y
,
x
,
u
,
l
,
E
,
D
,
C
,
B
;
z
=
s
[
A
];
w
=
s
[
A
+
1
];
v
=
s
[
A
+
2
];
t
=
s
[
A
+
3
];
y
=
b
.
uvs
[
z
*
2
];
E
=
b
.
uvs
[
z
*
2
+
1
];
x
=
b
.
uvs
[
w
*
2
];
D
=
b
.
uvs
[
w
*
2
+
1
];
u
=
b
.
uvs
[
v
*
2
];
C
=
b
.
uvs
[
v
*
2
+
1
];
l
=
b
.
uvs
[
t
*
2
];
B
=
b
.
uvs
[
t
*
2
+
1
];
THREE
.
Loader
.
prototype
.
uv
(
g
,
y
,
E
,
x
,
D
,
u
,
C
,
l
,
B
)}
var
n
,
m
;
for
(
n
=
0
,
m
=
b
.
triangles
.
length
;
n
<
m
;
n
+=
4
){
p
(
b
.
triangles
,
n
)}
for
(
n
=
0
,
m
=
b
.
triangles_uv
.
length
;
n
<
m
;
n
+=
7
){
p
(
b
.
triangles_uv
,
n
);
r
(
b
.
triangles_uv
,
n
+
4
)}
for
(
n
=
0
,
m
=
b
.
triangles_n
.
length
;
n
<
m
;
n
+=
7
){
k
(
b
.
triangles_n
,
n
)}
for
(
n
=
0
,
m
=
b
.
triangles_n_uv
.
length
;
n
<
m
;
n
+=
10
){
k
(
b
.
triangles_n_uv
,
n
);
r
(
b
.
triangles_n_uv
,
n
+
7
)}
for
(
n
=
0
,
m
=
b
.
quads
.
length
;
n
<
m
;
n
+=
5
){
o
(
b
.
quads
,
n
)}
for
(
n
=
0
,
m
=
b
.
quads_uv
.
length
;
n
<
m
;
n
+=
9
){
o
(
b
.
quads_uv
,
n
);
q
(
b
.
quads_uv
,
n
+
5
)}
for
(
n
=
0
,
m
=
b
.
quads_n
.
length
;
n
<
m
;
n
+=
9
){
j
(
b
.
quads_n
,
n
)}
for
(
n
=
0
,
m
=
b
.
quads_n_uv
.
length
;
n
<
m
;
n
+=
13
){
j
(
b
.
quads_n_uv
,
n
);
q
(
b
.
quads_n_uv
,
n
+
9
)}}};
c
.
prototype
=
new
THREE
.
Geometry
();
c
.
prototype
.
constructor
=
c
;
d
(
new
c
(
a
))},
v
:
function
(
b
,
a
,
d
,
c
){
b
.
vertices
.
push
(
new
THREE
.
Vertex
(
new
THREE
.
Vector3
(
a
,
d
,
c
)))},
f3
:
function
(
h
,
e
,
d
,
i
,
f
){
var
g
=
h
.
materials
[
f
];
h
.
faces
.
push
(
new
THREE
.
Face3
(
e
,
d
,
i
,
null
,
g
))},
f4
:
function
(
i
,
f
,
e
,
k
,
j
,
g
){
var
h
=
i
.
materials
[
g
];
i
.
faces
.
push
(
new
THREE
.
Face4
(
f
,
e
,
k
,
j
,
null
,
h
))},
f3n
:
function
(
d
,
l
,
s
,
r
,
q
,
p
,
j
,
i
,
h
){
var
k
=
d
.
materials
[
p
],
g
=
l
[
j
*
3
],
f
=
l
[
j
*
3
+
1
],
e
=
l
[
j
*
3
+
2
],
o
=
l
[
i
*
3
],
n
=
l
[
i
*
3
+
1
],
m
=
l
[
i
*
3
+
2
],
v
=
l
[
h
*
3
],
u
=
l
[
h
*
3
+
1
],
t
=
l
[
h
*
3
+
2
];
d
.
faces
.
push
(
new
THREE
.
Face3
(
s
,
r
,
q
,[
new
THREE
.
Vector3
(
g
,
f
,
e
),
new
THREE
.
Vector3
(
o
,
n
,
m
),
new
THREE
.
Vector3
(
v
,
u
,
t
)],
k
))},
f4n
:
function
(
e
,
q
,
y
,
x
,
w
,
u
,
v
,
o
,
n
,
m
,
k
){
var
p
=
e
.
materials
[
v
],
j
=
q
[
o
*
3
],
h
=
q
[
o
*
3
+
1
],
f
=
q
[
o
*
3
+
2
],
t
=
q
[
n
*
3
],
s
=
q
[
n
*
3
+
1
],
r
=
q
[
n
*
3
+
2
],
B
=
q
[
m
*
3
],
A
=
q
[
m
*
3
+
1
],
z
=
q
[
m
*
3
+
2
],
l
=
q
[
k
*
3
],
i
=
q
[
k
*
3
+
1
],
g
=
q
[
k
*
3
+
2
];
e
.
faces
.
push
(
new
THREE
.
Face4
(
y
,
x
,
w
,
u
,[
new
THREE
.
Vector3
(
j
,
h
,
f
),
new
THREE
.
Vector3
(
t
,
s
,
r
),
new
THREE
.
Vector3
(
B
,
A
,
z
),
new
THREE
.
Vector3
(
l
,
i
,
g
)],
p
))},
uv
:
function
(
j
,
e
,
i
,
c
,
h
,
b
,
g
,
a
,
f
){
var
d
=
[];
d
.
push
(
new
THREE
.
UV
(
e
,
i
));
d
.
push
(
new
THREE
.
UV
(
c
,
h
));
d
.
push
(
new
THREE
.
UV
(
b
,
g
));
if
(
a
&&
f
){
d
.
push
(
new
THREE
.
UV
(
a
,
f
))}
j
.
uvs
.
push
(
d
)},
init_materials
:
function
(
d
,
a
,
c
){
d
.
materials
=
[];
for
(
var
b
=
0
;
b
<
a
.
length
;
++
b
){
d
.
materials
[
b
]
=
[
THREE
.
Loader
.
prototype
.
createMaterial
(
a
[
b
],
c
)]}},
createMaterial
:
function
(
a
,
c
){
function
g
(
j
){
var
i
=
Math
.
log
(
j
)
/
Math
.
LN2
;
return
Math
.
floor
(
i
)
==
i
}
function
f
(
j
){
var
i
=
Math
.
log
(
j
)
/
Math
.
LN2
;
return
Math
.
pow
(
2
,
Math
.
round
(
i
))}
var
d
,
e
,
h
,
b
;
if
(
a
.
map_diffuse
&&
c
){
e
=
document
.
createElement
(
"
canvas
"
);
d
=
new
THREE
.
MeshBitmapMaterial
(
e
);
h
=
new
Image
();
h
.
onload
=
function
(){
if
(
!
g
(
this
.
width
)
||!
g
(
this
.
height
)){
var
i
=
f
(
this
.
width
),
j
=
f
(
this
.
height
);
d
.
bitmap
.
width
=
i
;
d
.
bitmap
.
height
=
j
;
d
.
bitmap
.
getContext
(
"
2d
"
).
drawImage
(
this
,
0
,
0
,
i
,
j
)}
else
{
d
.
bitmap
=
this
}
d
.
loaded
=
1
};
h
.
src
=
c
+
"
/
"
+
a
.
map_diffuse
}
else
{
if
(
a
.
col_diffuse
){
b
=
(
a
.
col_diffuse
[
0
]
*
255
<<
16
)
+
(
a
.
col_diffuse
[
1
]
*
255
<<
8
)
+
a
.
col_diffuse
[
2
]
*
255
;
d
=
new
THREE
.
MeshColorFillMaterial
(
b
,
a
.
transparency
)}
else
{
if
(
a
.
a_dbg_color
){
d
=
new
THREE
.
MeshColorFillMaterial
(
a
.
a_dbg_color
)}
else
{
d
=
new
THREE
.
MeshColorFillMaterial
(
15658734
)}}}
return
d
}};
THREE
.
Light
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
255
<<
24
|
a
)};
THREE
.
AmbientLight
=
function
(
a
){
THREE
.
Light
.
call
(
this
,
a
)};
THREE
.
AmbientLight
.
prototype
=
new
THREE
.
Light
();
THREE
.
AmbientLight
.
prototype
.
constructor
=
THREE
.
AmbientLight
;
THREE
.
DirectionalLight
=
function
(
b
,
a
){
THREE
.
Light
.
call
(
this
,
b
);
this
.
position
=
new
THREE
.
Vector3
(
0
,
1
,
0
);
this
.
intensity
=
a
||
1
};
THREE
.
DirectionalLight
.
prototype
=
new
THREE
.
Light
();
THREE
.
DirectionalLight
.
prototype
.
constructor
=
THREE
.
DirectionalLight
;
THREE
.
PointLight
=
function
(
b
,
a
){
THREE
.
Light
.
call
(
this
,
b
);
this
.
position
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
this
.
intensity
=
a
||
1
};
THREE
.
DirectionalLight
.
prototype
=
new
THREE
.
Light
();
THREE
.
DirectionalLight
.
prototype
.
constructor
=
THREE
.
PointLight
;
THREE
.
Object3D
=
function
(
a
){
this
.
position
=
new
THREE
.
Vector3
();
this
.
rotation
=
new
THREE
.
Vector3
();
this
.
scale
=
new
THREE
.
Vector3
(
1
,
1
,
1
);
this
.
matrix
=
new
THREE
.
Matrix4
();
this
.
matrixTranslation
=
new
THREE
.
Matrix4
();
this
.
matrixRotation
=
new
THREE
.
Matrix4
();
this
.
matrixScale
=
new
THREE
.
Matrix4
();
this
.
screen
=
new
THREE
.
Vector3
();
this
.
autoUpdateMatrix
=
true
;
this
.
updateMatrix
=
function
(){
this
.
matrixPosition
=
THREE
.
Matrix4
.
translationMatrix
(
this
.
position
.
x
,
this
.
position
.
y
,
this
.
position
.
z
);
this
.
matrixRotation
=
THREE
.
Matrix4
.
rotationXMatrix
(
this
.
rotation
.
x
);
this
.
matrixRotation
.
multiplySelf
(
THREE
.
Matrix4
.
rotationYMatrix
(
this
.
rotation
.
y
));
this
.
matrixRotation
.
multiplySelf
(
THREE
.
Matrix4
.
rotationZMatrix
(
this
.
rotation
.
z
));
this
.
matrixScale
=
THREE
.
Matrix4
.
scaleMatrix
(
this
.
scale
.
x
,
this
.
scale
.
y
,
this
.
scale
.
z
);
this
.
matrix
.
copy
(
this
.
matrixPosition
);
this
.
matrix
.
multiplySelf
(
this
.
matrixRotation
);
this
.
matrix
.
multiplySelf
(
this
.
matrixScale
)}};
THREE
.
Particle
=
function
(
a
){
THREE
.
Object3D
.
call
(
this
);
this
.
material
=
a
instanceof
Array
?
a
:[
a
];
this
.
autoUpdateMatrix
=
false
};
THREE
.
Particle
.
prototype
=
new
THREE
.
Object3D
();
THREE
.
Particle
.
prototype
.
constructor
=
THREE
.
Particle
;
THREE
.
Line
=
function
(
b
,
a
){
THREE
.
Object3D
.
call
(
this
);
this
.
geometry
=
b
;
this
.
material
=
a
instanceof
Array
?
a
:[
a
]};
THREE
.
Line
.
prototype
=
new
THREE
.
Object3D
();
THREE
.
Line
.
prototype
.
constructor
=
THREE
.
Line
;
THREE
.
Mesh
=
function
(
b
,
a
,
c
){
THREE
.
Object3D
.
call
(
this
);
this
.
geometry
=
b
;
this
.
material
=
a
instanceof
Array
?
a
:[
a
];
this
.
flipSided
=
false
;
this
.
doubleSided
=
false
;
this
.
overdraw
=
false
;
this
.
materialFaceGroup
=
{};
this
.
sortFacesByMaterial
();
if
(
c
){
this
.
normalizeUVs
()}
this
.
geometry
.
computeBoundingBox
()};
THREE
.
Mesh
.
prototype
=
new
THREE
.
Object3D
();
THREE
.
Mesh
.
prototype
.
constructor
=
THREE
.
Mesh
;
THREE
.
Mesh
.
prototype
.
sortFacesByMaterial
=
function
(){
var
c
,
b
,
e
,
m
,
k
,
h
,
j
,
n
,
d
,
g
=
{};
function
a
(
f
){
var
i
=
[];
for
(
c
=
0
,
b
=
f
.
length
;
c
<
b
;
c
++
){
if
(
f
[
c
]
==
undefined
){
i
.
push
(
"
undefined
"
)}
else
{
i
.
push
(
f
[
c
].
toString
())}}
return
i
.
join
(
"
_
"
)}
for
(
e
=
0
,
m
=
this
.
geometry
.
faces
.
length
;
e
<
m
;
e
++
){
k
=
this
.
geometry
.
faces
[
e
];
h
=
k
.
material
;
n
=
a
(
h
);
if
(
g
[
n
]
==
undefined
){
g
[
n
]
=
{
hash
:
n
,
counter
:
0
}}
d
=
g
[
n
].
hash
+
"
_
"
+
g
[
n
].
counter
;
if
(
this
.
materialFaceGroup
[
d
]
==
undefined
){
this
.
materialFaceGroup
[
d
]
=
{
faces
:[],
material
:
h
,
vertices
:
0
}}
j
=
k
instanceof
THREE
.
Face3
?
3
:
4
;
if
(
this
.
materialFaceGroup
[
d
].
vertices
+
j
>
65535
){
g
[
n
].
counter
+=
1
;
d
=
g
[
n
].
hash
+
"
_
"
+
g
[
n
].
counter
;
if
(
this
.
materialFaceGroup
[
d
]
==
undefined
){
this
.
materialFaceGroup
[
d
]
=
{
faces
:[],
material
:
h
,
vertices
:
0
}}}
this
.
materialFaceGroup
[
d
].
faces
.
push
(
e
);
this
.
materialFaceGroup
[
d
].
vertices
+=
j
}};
THREE
.
Mesh
.
prototype
.
normalizeUVs
=
function
(){
var
e
,
a
,
b
,
d
,
c
;
for
(
e
=
0
,
a
=
this
.
geometry
.
uvs
.
length
;
e
<
a
;
e
++
){
c
=
this
.
geometry
.
uvs
[
e
];
for
(
b
=
0
,
d
=
c
.
length
;
b
<
d
;
b
++
){
if
(
c
[
b
].
u
!=
1
){
c
[
b
].
u
=
c
[
b
].
u
-
Math
.
floor
(
c
[
b
].
u
)}
if
(
c
[
b
].
v
!=
1
){
c
[
b
].
v
=
c
[
b
].
v
-
Math
.
floor
(
c
[
b
].
v
)}}}};
THREE
.
FlatShading
=
0
;
THREE
.
GouraudShading
=
1
;
THREE
.
PhongShading
=
2
;
THREE
.
NormalBlending
=
0
;
THREE
.
AdditiveBlending
=
1
;
THREE
.
SubstractiveBlending
=
2
;
THREE
.
LineBasicMaterial
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
linewidth
=
1
;
if
(
a
){
if
(
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
.
linewidth
!==
undefined
){
this
.
linewidth
=
a
.
linewidth
}}
this
.
toString
=
function
(){
return
"
THREE.LineBasicMaterial (<br/>color:
"
+
this
.
color
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>linewidth:
"
+
this
.
linewidth
+
"
<br/>)
"
}};
THREE
.
MeshBasicMaterial
=
function
(
a
){
this
.
id
=
THREE
.
MeshBasicMaterialCounter
.
value
++
;
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
wireframe
=
false
;
this
.
wireframe_linewidth
=
1
;
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
.
setHex
(
a
.
color
)}
if
(
a
.
map
!==
undefined
){
this
.
map
=
a
.
map
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}
if
(
a
.
wireframe
!==
undefined
){
this
.
wireframe
=
a
.
wireframe
}
if
(
a
.
wireframe_linewidth
!==
undefined
){
this
.
wireframe_linewidth
=
a
.
wireframe_linewidth
}}
this
.
toString
=
function
(){
return
"
THREE.MeshBasicMaterial (<br/>id:
"
+
this
.
id
+
"
<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>wireframe:
"
+
this
.
wireframe
+
"
<br/>wireframe_linewidth:
"
+
this
.
wireframe_linewidth
+
"
<br/>)
"
}};
THREE
.
MeshBasicMaterialCounter
=
{
value
:
0
};
THREE
.
MeshDepthMaterial
=
function
(
a
){
this
.
near
=
1
;
this
.
far
=
1000
;
this
.
opacity
=
1
;
this
.
wireframe
=
false
;
this
.
wireframe_linewidth
=
1
;
if
(
a
){
if
(
a
.
near
!==
undefined
){
this
.
near
=
a
.
near
}
if
(
a
.
far
!==
undefined
){
this
.
far
=
a
.
far
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
wireframe
!==
undefined
){
this
.
wireframe
=
a
.
wireframe
}
if
(
a
.
wireframe_linewidth
!==
undefined
){
this
.
wireframe_linewidth
=
a
.
wireframe_linewidth
}}
this
.
__2near
=
2
*
this
.
near
;
this
.
__farPlusNear
=
this
.
far
+
this
.
near
;
this
.
__farMinusNear
=
this
.
far
-
this
.
near
;
this
.
toString
=
function
(){
return
"
THREE.MeshDepthMaterial
"
}};
THREE
.
MeshLambertMaterial
=
function
(
a
){
this
.
id
=
THREE
.
MeshLambertMaterialCounter
.
value
++
;
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
opacity
=
1
;
this
.
shading
=
THREE
.
GouraudShading
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
wireframe
=
false
;
this
.
wireframe_linewidth
=
1
;
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
.
setHex
(
a
.
color
)}
if
(
a
.
map
!==
undefined
){
this
.
map
=
a
.
map
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
shading
!==
undefined
){
this
.
shading
=
a
.
shading
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}
if
(
a
.
wireframe
!==
undefined
){
this
.
wireframe
=
a
.
wireframe
}
if
(
a
.
wireframe_linewidth
!==
undefined
){
this
.
wireframe_linewidth
=
a
.
wireframe_linewidth
}}
this
.
toString
=
function
(){
return
"
THREE.MeshLambertMaterial (<br/>id:
"
+
this
.
id
+
"
<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>shading:
"
+
this
.
shading
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>wireframe:
"
+
this
.
wireframe
+
"
<br/>wireframe_size:
"
+
this
.
wireframe_linewidth
+
"
<br/> )
"
}};
THREE
.
MeshLambertMaterialCounter
=
{
value
:
0
};
THREE
.
MeshPhongMaterial
=
function
(
a
){
this
.
id
=
THREE
.
MeshPhongMaterialCounter
.
value
++
;
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
ambient
=
new
THREE
.
Color
(
328965
);
this
.
specular
=
new
THREE
.
Color
(
1118481
);
this
.
specular_map
=
null
;
this
.
shininess
=
30
;
this
.
opacity
=
1
;
this
.
shading
=
THREE
.
GouraudShading
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
wireframe
=
false
;
this
.
wireframe_linewidth
=
1
;
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
=
new
THREE
.
Color
(
a
.
color
)}
if
(
a
.
map
!==
undefined
){
this
.
map
=
a
.
map
}
if
(
a
.
ambient
!==
undefined
){
this
.
ambient
=
new
THREE
.
Color
(
a
.
ambient
)}
if
(
a
.
specular
!==
undefined
){
this
.
specular_color
=
new
THREE
.
Color
(
a
.
specular
)}
if
(
a
.
specular_map
!==
undefined
){
this
.
specular_map
=
a
.
specular_map
}
if
(
a
.
shininess
!==
undefined
){
this
.
shininess
=
a
.
shininess
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
shading
!==
undefined
){
this
.
shading
=
a
.
shading
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}
if
(
a
.
wireframe
!==
undefined
){
this
.
wireframe
=
a
.
wireframe
}
if
(
a
.
wireframe_linewidth
!==
undefined
){
this
.
wireframe_linewidth
=
a
.
wireframe_linewidth
}}
this
.
toString
=
function
(){
return
"
THREE.MeshPhongMaterial (<br/>id:
"
+
this
.
id
+
"
<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>ambient:
"
+
this
.
ambient
+
"
<br/>specular:
"
+
this
.
specular
+
"
<br/>specular_map:
"
+
this
.
specular_map
+
"
<br/>shininess:
"
+
this
.
shininess
+
"
<br/>alpha:
"
+
this
.
opacity
+
"
<br/>shading:
"
+
this
.
shading
+
"
<br/>wireframe:
"
+
this
.
wireframe
+
"
<br/>wireframe_linewidth:
"
+
this
.
wireframe_linewidth
+
"
<br/>
"
+
+
"
)
"
}};
THREE
.
MeshPhongMaterialCounter
=
{
value
:
0
};
THREE
.
MeshFaceMaterial
=
function
(){
this
.
toString
=
function
(){
return
"
THREE.MeshFaceMaterial
"
}};
THREE
.
ParticleBasicMaterial
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
map
=
null
;
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
this
.
offset
=
new
THREE
.
Vector2
();
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
.
setHex
(
a
.
color
)}
if
(
a
.
map
!==
undefined
){
this
.
map
=
a
.
map
}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}}
this
.
toString
=
function
(){
return
"
THREE.ParticleBasicMaterial (<br/>color:
"
+
this
.
color
+
"
<br/>map:
"
+
this
.
map
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>)
"
}};
THREE
.
ParticleCircleMaterial
=
function
(
a
){
this
.
color
=
new
THREE
.
Color
(
16711680
);
this
.
opacity
=
1
;
this
.
blending
=
THREE
.
NormalBlending
;
if
(
a
){
if
(
a
.
color
!==
undefined
){
this
.
color
.
setHex
(
a
.
color
)}
if
(
a
.
opacity
!==
undefined
){
this
.
opacity
=
a
.
opacity
}
if
(
a
.
blending
!==
undefined
){
this
.
blending
=
a
.
blending
}}
this
.
toString
=
function
(){
return
"
THREE.ParticleCircleMaterial (<br/>color:
"
+
this
.
color
+
"
<br/>opacity:
"
+
this
.
opacity
+
"
<br/>blending:
"
+
this
.
blending
+
"
<br/>)
"
}};
THREE
.
ParticleDOMMaterial
=
function
(
a
){
this
.
domElement
=
a
;
this
.
toString
=
function
(){
return
"
THREE.ParticleDOMMaterial ( domElement:
"
+
this
.
domElement
+
"
)
"
}};
THREE
.
Texture
=
function
(
b
,
a
){
this
.
image
=
b
;
this
.
mapping
=
a
?
a
:
THREE
.
UVMapping
;
this
.
toString
=
function
(){
return
"
THREE.Texture (<br/>image:
"
+
this
.
image
+
"
<br/>mapping:
"
+
this
.
mapping
+
"
<br/>)
"
}};
THREE
.
UVMapping
=
0
;
THREE
.
ReflectionMap
=
1
;
THREE
.
CubeMap
=
2
;
THREE
.
Scene
=
function
(){
this
.
objects
=
[];
this
.
lights
=
[];
this
.
addObject
=
function
(
a
){
this
.
objects
.
push
(
a
)};
this
.
removeObject
=
function
(
a
){
var
b
=
this
.
objects
.
indexOf
(
a
);
if
(
b
!==-
1
){
this
.
objects
.
splice
(
b
,
1
)}};
this
.
addLight
=
function
(
a
){
this
.
lights
.
push
(
a
)};
this
.
removeLight
=
function
(
a
){
var
b
=
this
.
lights
.
indexOf
(
a
);
if
(
b
!==-
1
){
this
.
lights
.
splice
(
b
,
1
)}};
this
.
toString
=
function
(){
return
"
THREE.Scene (
"
+
this
.
objects
+
"
)
"
}};
THREE
.
Projector
=
function
(){
var
e
=
null
,
c
,
p
,
n
=
[],
b
,
f
,
l
=
[],
k
,
m
,
i
=
[],
j
,
h
,
a
=
[],
g
=
new
THREE
.
Vector4
(),
d
=
new
THREE
.
Matrix4
(),
o
=
new
THREE
.
Matrix4
();
this
.
projectScene
=
function
(
J
,
G
){
var
F
,
E
,
D
,
K
,
I
,
B
,
r
,
L
,
q
,
z
,
H
,
u
,
C
,
w
,
A
,
y
,
x
,
t
,
s
;
e
=
[];
p
=
0
,
f
=
0
,
m
=
0
,
h
=
0
;
if
(
G
.
autoUpdateMatrix
){
G
.
updateMatrix
()}
d
.
multiply
(
G
.
projectionMatrix
,
G
.
matrix
);
r
=
J
.
objects
;
for
(
F
=
0
,
E
=
r
.
length
;
F
<
E
;
F
++
){
L
=
r
[
F
];
q
=
L
.
matrix
;
if
(
L
.
autoUpdateMatrix
){
L
.
updateMatrix
()}
if
(
L
instanceof
THREE
.
Mesh
){
o
.
multiply
(
d
,
q
);
z
=
L
.
geometry
.
vertices
;
for
(
D
=
0
,
K
=
z
.
length
;
D
<
K
;
D
++
){
H
=
z
[
D
];
u
=
H
.
positionScreen
;
u
.
copy
(
H
.
position
);
o
.
transform
(
u
);
H
.
__visible
=
u
.
z
>
0
&&
u
.
z
<
1
}
w
=
L
.
geometry
.
faces
;
for
(
I
=
0
,
B
=
w
.
length
;
I
<
B
;
I
++
){
A
=
w
[
I
];
if
(
A
instanceof
THREE
.
Face3
){
y
=
z
[
A
.
a
];
x
=
z
[
A
.
b
];
t
=
z
[
A
.
c
];
if
(
y
.
__visible
&&
x
.
__visible
&&
t
.
__visible
){
if
((
L
.
doubleSided
||
(
L
.
flipSided
!=
(
t
.
positionScreen
.
x
-
y
.
positionScreen
.
x
)
*
(
x
.
positionScreen
.
y
-
y
.
positionScreen
.
y
)
-
(
t
.
positionScreen
.
y
-
y
.
positionScreen
.
y
)
*
(
x
.
positionScreen
.
x
-
y
.
positionScreen
.
x
)
<
0
))){
c
=
n
[
p
]
=
n
[
p
]
||
new
THREE
.
RenderableFace3
();
c
.
v1
.
copy
(
y
.
positionScreen
);
c
.
v2
.
copy
(
x
.
positionScreen
);
c
.
v3
.
copy
(
t
.
positionScreen
);
c
.
normalWorld
.
copy
(
A
.
normal
);
L
.
matrixRotation
.
transform
(
c
.
normalWorld
);
c
.
centroidWorld
.
copy
(
A
.
centroid
);
q
.
transform
(
c
.
centroidWorld
);
c
.
centroidScreen
.
copy
(
c
.
centroidWorld
);
d
.
transform
(
c
.
centroidScreen
);
c
.
z
=
c
.
centroidScreen
.
z
;
c
.
meshMaterial
=
L
.
material
;
c
.
faceMaterial
=
A
.
material
;
c
.
overdraw
=
L
.
overdraw
;
c
.
uvs
=
L
.
geometry
.
uvs
[
I
];
c
.
color
=
A
.
color
;
e
.
push
(
c
);
p
++
}}}
else
{
if
(
A
instanceof
THREE
.
Face4
){
y
=
z
[
A
.
a
];
x
=
z
[
A
.
b
];
t
=
z
[
A
.
c
];
s
=
z
[
A
.
d
];
if
(
y
.
__visible
&&
x
.
__visible
&&
t
.
__visible
&&
s
.
__visible
){
if
((
L
.
doubleSided
||
(
L
.
flipSided
!=
((
s
.
positionScreen
.
x
-
y
.
positionScreen
.
x
)
*
(
x
.
positionScreen
.
y
-
y
.
positionScreen
.
y
)
-
(
s
.
positionScreen
.
y
-
y
.
positionScreen
.
y
)
*
(
x
.
positionScreen
.
x
-
y
.
positionScreen
.
x
)
<
0
||
(
x
.
positionScreen
.
x
-
t
.
positionScreen
.
x
)
*
(
s
.
positionScreen
.
y
-
t
.
positionScreen
.
y
)
-
(
x
.
positionScreen
.
y
-
t
.
positionScreen
.
y
)
*
(
s
.
positionScreen
.
x
-
t
.
positionScreen
.
x
)
<
0
)))){
b
=
l
[
f
]
=
l
[
f
]
||
new
THREE
.
RenderableFace4
();
b
.
v1
.
copy
(
y
.
positionScreen
);
b
.
v2
.
copy
(
x
.
positionScreen
);
b
.
v3
.
copy
(
t
.
positionScreen
);
b
.
v4
.
copy
(
s
.
positionScreen
);
b
.
normalWorld
.
copy
(
A
.
normal
);
L
.
matrixRotation
.
transform
(
b
.
normalWorld
);
b
.
centroidWorld
.
copy
(
A
.
centroid
);
q
.
transform
(
b
.
centroidWorld
);
b
.
centroidScreen
.
copy
(
b
.
centroidWorld
);
d
.
transform
(
b
.
centroidScreen
);
b
.
z
=
b
.
centroidScreen
.
z
;
b
.
meshMaterial
=
L
.
material
;
b
.
faceMaterial
=
A
.
material
;
b
.
overdraw
=
L
.
overdraw
;
b
.
uvs
=
L
.
geometry
.
uvs
[
I
];
b
.
color
=
A
.
color
;
e
.
push
(
b
);
f
++
}}}}}}
else
{
if
(
L
instanceof
THREE
.
Line
){
o
.
multiply
(
d
,
q
);
z
=
L
.
geometry
.
vertices
;
for
(
D
=
0
,
K
=
z
.
length
;
D
<
K
;
D
++
){
H
=
z
[
D
];
u
=
H
.
positionScreen
;
u
.
copy
(
H
.
position
);
o
.
transform
(
u
);
H
.
__visible
=
u
.
z
>
0
&&
u
.
z
<
1
;
if
(
D
>
0
){
C
=
L
.
geometry
.
vertices
[
D
-
1
];
if
(
H
.
__visible
&&
C
.
__visible
){
k
=
i
[
m
]
=
i
[
m
]
||
new
THREE
.
RenderableLine
();
k
.
v1
.
copy
(
H
.
positionScreen
);
k
.
v2
.
copy
(
C
.
positionScreen
);
k
.
z
=
Math
.
max
(
H
.
positionScreen
.
z
,
C
.
positionScreen
.
z
);
k
.
material
=
L
.
material
;
e
.
push
(
k
);
m
++
}}}}
else
{
if
(
L
instanceof
THREE
.
Particle
){
g
.
set
(
L
.
position
.
x
,
L
.
position
.
y
,
L
.
position
.
z
,
1
);
d
.
transform
(
g
);
g
.
z
/=
g
.
w
;
if
(
g
.
z
>
0
&&
g
.
z
<
1
){
j
=
a
[
h
]
=
a
[
h
]
||
new
THREE
.
RenderableParticle
();
j
.
x
=
g
.
x
/
g
.
w
;
j
.
y
=
g
.
y
/
g
.
w
;
j
.
z
=
g
.
z
;
j
.
rotation
=
L
.
rotation
.
z
;
j
.
scale
.
x
=
L
.
scale
.
x
*
Math
.
abs
(
j
.
x
-
(
g
.
x
+
G
.
projectionMatrix
.
n11
)
/
(
g
.
w
+
G
.
projectionMatrix
.
n14
));
j
.
scale
.
y
=
L
.
scale
.
y
*
Math
.
abs
(
j
.
y
-
(
g
.
y
+
G
.
projectionMatrix
.
n22
)
/
(
g
.
w
+
G
.
projectionMatrix
.
n24
));
j
.
material
=
L
.
material
;
e
.
push
(
j
);
h
++
}}}}}
e
.
sort
(
function
(
M
,
v
){
return
v
.
z
-
M
.
z
});
return
e
};
this
.
unprojectVector
=
function
(
q
,
s
){
var
r
=
new
THREE
.
Matrix4
();
r
.
multiply
(
THREE
.
Matrix4
.
makeInvert
(
s
.
matrix
),
THREE
.
Matrix4
.
makeInvert
(
s
.
projectionMatrix
));
r
.
transform
(
q
);
return
q
}};
THREE
.
DOMRenderer
=
function
(){
THREE
.
Renderer
.
call
(
this
);
var
e
=
null
,
g
=
new
THREE
.
Projector
(),
b
=
document
.
createElement
(
"
div
"
),
a
,
c
,
f
,
d
;
this
.
domElement
=
b
;
this
.
setSize
=
function
(
i
,
h
){
a
=
i
;
c
=
h
;
f
=
a
/
2
;
d
=
c
/
2
};
this
.
render
=
function
(
p
,
r
){
var
q
,
h
,
i
,
n
,
o
,
s
,
l
,
k
,
j
;
e
=
g
.
projectScene
(
p
,
r
);
for
(
q
=
0
,
h
=
e
.
length
;
q
<
h
;
q
++
){
o
=
e
[
q
];
if
(
o
instanceof
THREE
.
RenderableParticle
){
k
=
o
.
x
*
f
+
f
;
j
=
o
.
y
*
d
+
d
;
for
(
i
=
0
,
n
=
o
.
material
.
length
;
i
<
n
;
i
++
){
s
=
o
.
material
[
i
];
if
(
s
instanceof
THREE
.
ParticleDOMMaterial
){
l
=
s
.
domElement
;
l
.
style
.
left
=
k
+
"
px
"
;
l
.
style
.
top
=
j
+
"
px
"
}}}}}};
THREE
.
CanvasRenderer
=
function
(){
var
n
=
null
,
x
=
new
THREE
.
Projector
(),
s
=
document
.
createElement
(
"
canvas
"
),
a
,
F
,
v
,
h
,
r
=
s
.
getContext
(
"
2d
"
),
B
=
1
,
i
=
"
#000000
"
,
L
=
"
#000000
"
,
f
=
1
,
w
=
new
THREE
.
Rectangle
(),
I
=
new
THREE
.
Rectangle
(),
m
=
new
THREE
.
Rectangle
(),
D
=
false
,
A
=
new
THREE
.
Color
(
4294967295
),
y
=
new
THREE
.
Color
(
4294967295
),
H
=
new
THREE
.
Color
(
4278190080
),
k
=
Math
.
PI
*
2
,
C
,
G
=
new
THREE
.
Vector2
(),
E
=
new
THREE
.
Vector3
(),
u
=
new
THREE
.
UV
(),
t
=
new
THREE
.
UV
(),
q
=
new
THREE
.
UV
(),
p
=
new
THREE
.
UV
(),
K
=
new
THREE
.
Vector2
(),
J
=
new
THREE
.
Vector2
();
this
.
domElement
=
s
;
this
.
autoClear
=
true
;
this
.
setSize
=
function
(
N
,
M
){
a
=
N
;
F
=
M
;
v
=
a
/
2
;
h
=
F
/
2
;
s
.
width
=
a
;
s
.
height
=
F
;
r
.
lineJoin
=
"
round
"
;
r
.
lineCap
=
"
round
"
;
w
.
set
(
-
v
,
-
h
,
v
,
h
)};
this
.
clear
=
function
(){
if
(
!
I
.
isEmpty
()){
I
.
inflate
(
1
);
I
.
minSelf
(
w
);
r
.
setTransform
(
1
,
0
,
0
,
-
1
,
v
,
h
);
r
.
clearRect
(
I
.
getX
(),
I
.
getY
(),
I
.
getWidth
(),
I
.
getHeight
());
I
.
empty
()}};
this
.
render
=
function
(
ah
,
ae
){
var
ag
,
P
,
R
,
Z
,
af
,
V
,
S
,
Y
,
W
,
T
,
ac
,
aa
,
O
,
M
,
X
,
U
,
ad
,
ab
,
Q
,
N
;
if
(
this
.
autoClear
){
this
.
clear
()}
n
=
x
.
projectScene
(
ah
,
ae
);
r
.
setTransform
(
1
,
0
,
0
,
-
1
,
v
,
h
);
r
.
fillStyle
=
"
rgba(0, 255, 255, 0.5)
"
;
r
.
fillRect
(
w
.
getX
(),
w
.
getY
(),
w
.
getWidth
(),
w
.
getHeight
());
D
=
ah
.
lights
.
length
>
0
;
if
(
D
){
e
(
ah
,
H
)}
for
(
ag
=
0
,
P
=
n
.
length
;
ag
<
P
;
ag
++
){
R
=
n
[
ag
];
m
.
empty
();
if
(
R
instanceof
THREE
.
RenderableParticle
){
W
=
R
.
x
*
v
;
T
=
R
.
y
*
h
;
for
(
Z
=
0
,
af
=
R
.
material
.
length
;
Z
<
af
;
Z
++
){
Y
=
R
.
material
[
Z
];
Y
&&
o
(
W
,
T
,
R
,
Y
,
ah
)}}
else
{
if
(
R
instanceof
THREE
.
RenderableLine
){
W
=
R
.
v1
.
x
*
v
;
T
=
R
.
v1
.
y
*
h
;
ac
=
R
.
v2
.
x
*
v
;
aa
=
R
.
v2
.
y
*
h
;
m
.
addPoint
(
W
,
T
);
m
.
addPoint
(
ac
,
aa
);
if
(
!
w
.
instersects
(
m
)){
continue
}
Z
=
0
;
af
=
R
.
material
.
length
;
while
(
Z
<
af
){
Y
=
R
.
material
[
Z
++
];
Y
&&
z
(
W
,
T
,
ac
,
aa
,
R
,
Y
,
ah
)}}
else
{
if
(
R
instanceof
THREE
.
RenderableFace3
){
R
.
v1
.
x
*=
v
;
R
.
v1
.
y
*=
h
;
R
.
v2
.
x
*=
v
;
R
.
v2
.
y
*=
h
;
R
.
v3
.
x
*=
v
;
R
.
v3
.
y
*=
h
;
if
(
R
.
overdraw
){
b
(
R
.
v1
,
R
.
v2
);
b
(
R
.
v2
,
R
.
v3
);
b
(
R
.
v3
,
R
.
v1
)}
W
=
R
.
v1
.
x
;
T
=
R
.
v1
.
y
;
ac
=
R
.
v2
.
x
;
aa
=
R
.
v2
.
y
;
O
=
R
.
v3
.
x
;
M
=
R
.
v3
.
y
;
m
.
addPoint
(
W
,
T
);
m
.
addPoint
(
ac
,
aa
);
m
.
addPoint
(
O
,
M
);
if
(
!
w
.
instersects
(
m
)){
continue
}
Z
=
0
;
af
=
R
.
meshMaterial
.
length
;
while
(
Z
<
af
){
Y
=
R
.
meshMaterial
[
Z
++
];
if
(
Y
instanceof
THREE
.
MeshFaceMaterial
){
V
=
0
;
S
=
R
.
faceMaterial
.
length
;
while
(
V
<
S
){
Y
=
R
.
faceMaterial
[
V
++
];
Y
&&
l
(
W
,
T
,
ac
,
aa
,
O
,
M
,
R
,
Y
,
ah
)}
continue
}
l
(
W
,
T
,
ac
,
aa
,
O
,
M
,
R
,
Y
,
ah
)}}
else
{
if
(
R
instanceof
THREE
.
RenderableFace4
){
R
.
v1
.
x
*=
v
;
R
.
v1
.
y
*=
h
;
R
.
v2
.
x
*=
v
;
R
.
v2
.
y
*=
h
;
R
.
v3
.
x
*=
v
;
R
.
v3
.
y
*=
h
;
R
.
v4
.
x
*=
v
;
R
.
v4
.
y
*=
h
;
K
.
copy
(
R
.
v2
);
J
.
copy
(
R
.
v4
);
if
(
R
.
overdraw
){
b
(
R
.
v1
,
R
.
v2
);
b
(
R
.
v2
,
R
.
v4
);
b
(
R
.
v4
,
R
.
v1
)}
W
=
R
.
v1
.
x
;
T
=
R
.
v1
.
y
;
ac
=
R
.
v2
.
x
;
aa
=
R
.
v2
.
y
;
X
=
R
.
v4
.
x
;
U
=
R
.
v4
.
y
;
if
(
R
.
overdraw
){
b
(
R
.
v3
,
K
);
b
(
R
.
v3
,
J
)}
O
=
R
.
v3
.
x
;
M
=
R
.
v3
.
y
;
ad
=
K
.
x
;
ab
=
K
.
y
;
Q
=
J
.
x
;
N
=
J
.
y
;
m
.
addPoint
(
W
,
T
);
m
.
addPoint
(
ac
,
aa
);
m
.
addPoint
(
O
,
M
);
m
.
addPoint
(
X
,
U
);
if
(
!
w
.
instersects
(
m
)){
continue
}
Z
=
0
;
af
=
R
.
meshMaterial
.
length
;
while
(
Z
<
af
){
Y
=
R
.
meshMaterial
[
Z
++
];
if
(
Y
instanceof
THREE
.
MeshFaceMaterial
){
V
=
0
;
S
=
R
.
faceMaterial
.
length
;
while
(
V
<
S
){
Y
=
R
.
faceMaterial
[
V
++
];
Y
&&
j
(
W
,
T
,
ac
,
aa
,
O
,
M
,
X
,
U
,
ad
,
ab
,
Q
,
N
,
R
,
Y
,
ah
)}
continue
}
j
(
W
,
T
,
ac
,
aa
,
O
,
M
,
X
,
U
,
ad
,
ab
,
Q
,
N
,
R
,
Y
,
ah
)}}}}}
I
.
addRectangle
(
m
)}
r
.
lineWidth
=
1
;
r
.
strokeStyle
=
"
rgba( 255, 0, 0, 0.5 )
"
;
r
.
strokeRect
(
I
.
getX
(),
I
.
getY
(),
I
.
getWidth
(),
I
.
getHeight
());
r
.
setTransform
(
1
,
0
,
0
,
1
,
0
,
0
)};
function
e
(
S
,
P
){
var
O
,
R
,
N
,
M
,
Q
=
S
.
lights
;
P
.
setRGBA
(
0
,
0
,
0
,
1
);
for
(
O
=
0
,
R
=
Q
.
length
;
O
<
R
;
O
++
){
N
=
Q
[
O
];
M
=
N
.
color
;
if
(
N
instanceof
THREE
.
AmbientLight
){
P
.
r
+=
M
.
r
;
P
.
g
+=
M
.
g
;
P
.
b
+=
M
.
b
}}}
function
g
(
T
,
R
,
P
){
var
O
,
S
,
N
,
M
,
Q
=
T
.
lights
;
for
(
O
=
0
,
S
=
Q
.
length
;
O
<
S
;
O
++
){
N
=
Q
[
O
];
M
=
N
.
color
;
if
(
N
instanceof
THREE
.
DirectionalLight
){
P
.
r
+=
M
.
r
;
P
.
g
+=
M
.
g
;
P
.
b
+=
M
.
b
}
else
{
if
(
N
instanceof
THREE
.
PointLight
){
P
.
r
+=
M
.
r
;
P
.
g
+=
M
.
g
;
P
.
b
+=
M
.
b
}}}}
function
d
(
T
,
R
,
P
){
var
O
,
S
,
N
,
M
,
Q
;
lights
=
T
.
lights
;
for
(
O
=
0
,
S
=
lights
.
length
;
O
<
S
;
O
++
){
N
=
lights
[
O
];
M
=
N
.
color
;
if
(
N
instanceof
THREE
.
DirectionalLight
){
Q
=
R
.
normalWorld
.
dot
(
N
.
position
)
*
N
.
intensity
;
if
(
Q
>
0
){
P
.
r
+=
M
.
r
*
Q
;
P
.
g
+=
M
.
g
*
Q
;
P
.
b
+=
M
.
b
*
Q
}}
else
{
if
(
N
instanceof
THREE
.
PointLight
){
E
.
sub
(
N
.
position
,
R
.
centroidWorld
);
E
.
normalize
();
Q
=
R
.
normalWorld
.
dot
(
E
)
*
N
.
intensity
;
if
(
Q
>
0
){
P
.
r
+=
M
.
r
*
Q
;
P
.
g
+=
M
.
g
*
Q
;
P
.
b
+=
M
.
b
*
Q
}}}}}
function
o
(
O
,
N
,
R
,
U
,
T
){
var
M
,
Z
,
X
,
W
,
S
,
Q
,
V
,
Y
,
P
;
if
(
B
!=
U
.
opacity
){
r
.
globalAlpha
=
B
=
U
.
opacity
}
if
(
U
instanceof
THREE
.
ParticleBasicMaterial
){
V
=
U
.
bitmap
;
Y
=
V
.
width
/
2
;
P
=
V
.
height
/
2
;
X
=
R
.
scale
.
x
*
v
;
W
=
R
.
scale
.
y
*
h
;
M
=
X
*
Y
;
Z
=
W
*
P
;
S
=
U
.
offset
.
x
*
X
;
Q
=
U
.
offset
.
y
*
W
;
m
.
set
(
O
+
S
-
M
,
N
+
Q
-
Z
,
O
+
S
+
M
,
N
+
Q
+
Z
);
if
(
!
w
.
instersects
(
m
)){
return
}
r
.
save
();
r
.
translate
(
O
,
N
);
r
.
rotate
(
-
R
.
rotation
);
r
.
scale
(
X
,
-
W
);
r
.
translate
(
-
Y
+
U
.
offset
.
x
,
-
P
-
U
.
offset
.
y
);
r
.
drawImage
(
V
,
0
,
0
);
r
.
restore
();
r
.
beginPath
();
r
.
moveTo
(
O
-
10
,
N
);
r
.
lineTo
(
O
+
10
,
N
);
r
.
moveTo
(
O
,
N
-
10
);
r
.
lineTo
(
O
,
N
+
10
);
r
.
closePath
();
r
.
strokeStyle
=
"
rgb(255,255,0)
"
;
r
.
stroke
()}
else
{
if
(
U
instanceof
THREE
.
ParticleCircleMaterial
){
if
(
D
){
y
.
copyRGB
(
H
);
g
(
T
,
R
,
y
);
A
.
copyRGBA
(
U
.
color
);
A
.
multiplySelfRGB
(
y
);
A
.
updateStyleString
()}
else
{
A
.
__styleString
=
U
.
color
.
__styleString
}
M
=
R
.
scale
.
x
*
v
;
Z
=
R
.
scale
.
y
*
h
;
m
.
set
(
O
-
M
,
N
-
Z
,
O
+
M
,
N
+
Z
);
if
(
!
w
.
instersects
(
m
)){
return
}
r
.
save
();
r
.
translate
(
O
,
N
);
r
.
rotate
(
-
R
.
rotation
);
r
.
scale
(
M
,
Z
);
r
.
beginPath
();
r
.
arc
(
0
,
0
,
1
,
0
,
k
,
true
);
r
.
closePath
();
r
.
fillStyle
=
A
.
__styleString
;
r
.
fill
();
r
.
restore
()}}}
function
z
(
M
,
S
,
O
,
N
,
P
,
Q
,
R
){
if
(
B
!=
Q
.
opacity
){
r
.
globalAlpha
=
B
=
Q
.
opacity
}
if
(
Q
instanceof
THREE
.
LineBasicMaterial
){
r
.
beginPath
();
r
.
moveTo
(
M
,
S
);
r
.
lineTo
(
O
,
N
);
r
.
closePath
();
A
.
__styleString
=
Q
.
color
.
__styleString
;
if
(
f
!=
Q
.
linewidth
){
r
.
lineWidth
=
f
=
Q
.
linewidth
}
if
(
i
!=
A
.
__styleString
){
r
.
strokeStyle
=
i
=
A
.
__styleString
}
r
.
stroke
();
m
.
inflate
(
Q
.
linewidth
*
2
)}}
function
l
(
O
,
N
,
M
,
X
,
U
,
T
,
Q
,
S
,
R
){
var
V
,
W
,
P
;
if
(
B
!=
S
.
opacity
){
r
.
globalAlpha
=
B
=
S
.
opacity
}
if
(
S
.
map
){
V
=
S
.
map
.
image
;
W
=
V
.
width
-
1
;
P
=
V
.
height
-
1
;
u
.
copy
(
Q
.
uvs
[
0
]);
t
.
copy
(
Q
.
uvs
[
1
]);
q
.
copy
(
Q
.
uvs
[
2
]);
u
.
u
*=
W
;
u
.
v
*=
P
;
t
.
u
*=
W
;
t
.
v
*=
P
;
q
.
u
*=
W
;
q
.
v
*=
P
;
c
(
V
,
O
,
N
,
M
,
X
,
U
,
T
,
u
.
u
,
u
.
v
,
t
.
u
,
t
.
v
,
q
.
u
,
q
.
v
);
return
}
r
.
beginPath
();
r
.
moveTo
(
O
,
N
);
r
.
lineTo
(
M
,
X
);
r
.
lineTo
(
U
,
T
);
r
.
lineTo
(
O
,
N
);
r
.
closePath
();
if
(
S
instanceof
THREE
.
MeshBasicMaterial
){
A
.
__styleString
=
S
.
color
.
__styleString
}
else
{
if
(
S
instanceof
THREE
.
MeshDepthMaterial
){
C
=
1
-
(
S
.
__2near
/
(
S
.
__farPlusNear
-
Q
.
z
*
S
.
__farMinusNear
));
A
.
setRGBA
(
C
,
C
,
C
,
1
)}
else
{
if
(
S
instanceof
THREE
.
MeshLambertMaterial
){
if
(
D
){
y
.
copyRGB
(
H
);
d
(
R
,
Q
,
y
);
A
.
copyRGBA
(
S
.
color
);
A
.
multiplySelfRGB
(
y
);
A
.
updateStyleString
()}
else
{
A
.
__styleString
=
S
.
color
.
__styleString
}}}}
if
(
S
.
wireframe
){
if
(
f
!=
S
.
wireframe_linewidth
){
r
.
lineWidth
=
f
=
S
.
wireframe_linewidth
}
if
(
i
!=
A
.
__styleString
){
r
.
strokeStyle
=
i
=
A
.
__styleString
}
r
.
stroke
();
m
.
inflate
(
S
.
wireframe_linewidth
*
2
)}
else
{
if
(
L
!=
A
.
__styleString
){
r
.
fillStyle
=
L
=
A
.
__styleString
}
r
.
fill
()}}
function
j
(
S
,
R
,
aa
,
Y
,
N
,
M
,
U
,
T
,
ab
,
Z
,
P
,
O
,
Q
,
W
,
ac
){
var
ad
,
V
,
X
;
if
(
B
!=
W
.
opacity
){
r
.
globalAlpha
=
B
=
W
.
opacity
}
if
(
W
.
map
){
ad
=
W
.
map
.
image
;
V
=
ad
.
width
-
1
;
X
=
ad
.
height
-
1
;
u
.
copy
(
Q
.
uvs
[
0
]);
t
.
copy
(
Q
.
uvs
[
1
]);
q
.
copy
(
Q
.
uvs
[
2
]);
p
.
copy
(
Q
.
uvs
[
3
]);
u
.
u
*=
V
;
u
.
v
*=
X
;
t
.
u
*=
V
;
t
.
v
*=
X
;
q
.
u
*=
V
;
q
.
v
*=
X
;
p
.
u
*=
V
;
p
.
v
*=
X
;
c
(
ad
,
S
,
R
,
aa
,
Y
,
U
,
T
,
u
.
u
,
u
.
v
,
t
.
u
,
t
.
v
,
p
.
u
,
p
.
v
);
c
(
ad
,
ab
,
Z
,
N
,
M
,
P
,
O
,
t
.
u
,
t
.
v
,
q
.
u
,
q
.
v
,
p
.
u
,
p
.
v
);
return
}
r
.
beginPath
();
r
.
moveTo
(
S
,
R
);
r
.
lineTo
(
aa
,
Y
);
r
.
lineTo
(
N
,
M
);
r
.
lineTo
(
U
,
T
);
r
.
lineTo
(
S
,
R
);
r
.
closePath
();
if
(
W
instanceof
THREE
.
MeshBasicMaterial
){
A
.
__styleString
=
W
.
color
.
__styleString
}
else
{
if
(
W
instanceof
THREE
.
MeshDepthMaterial
){
C
=
1
-
(
W
.
__2near
/
(
W
.
__farPlusNear
-
Q
.
z
*
W
.
__farMinusNear
));
A
.
setRGBA
(
C
,
C
,
C
,
1
)}
else
{
if
(
W
instanceof
THREE
.
MeshLambertMaterial
){
if
(
D
){
y
.
copyRGB
(
H
);
d
(
ac
,
Q
,
y
);
A
.
copyRGBA
(
W
.
color
);
A
.
multiplySelfRGB
(
y
);
A
.
updateStyleString
()}
else
{
A
.
__styleString
=
W
.
color
.
__styleString
}}}}
if
(
W
.
wireframe
){
if
(
f
!=
W
.
wireframe_linewidth
){
r
.
lineWidth
=
f
=
W
.
wireframe_linewidth
}
if
(
i
!=
A
.
__styleString
){
r
.
strokeStyle
=
i
=
A
.
__styleString
}
r
.
stroke
();
m
.
inflate
(
W
.
wireframe_linewidth
*
2
)}
else
{
if
(
L
!=
A
.
__styleString
){
r
.
fillStyle
=
L
=
A
.
__styleString
}
r
.
fill
()}}
function
c
(
af
,
Z
,
R
,
X
,
Q
,
V
,
O
,
W
,
P
,
U
,
N
,
T
,
M
){
r
.
beginPath
();
r
.
moveTo
(
Z
,
R
);
r
.
lineTo
(
X
,
Q
);
r
.
lineTo
(
V
,
O
);
r
.
lineTo
(
Z
,
R
);
r
.
closePath
();
X
-=
Z
;
Q
-=
R
;
V
-=
Z
;
O
-=
R
;
U
-=
W
;
N
-=
P
;
T
-=
W
;
M
-=
P
;
var
S
=
1
/
(
U
*
M
-
T
*
N
),
ae
=
(
M
*
X
-
N
*
V
)
*
S
,
ad
=
(
M
*
Q
-
N
*
O
)
*
S
,
ac
=
(
U
*
V
-
T
*
X
)
*
S
,
ab
=
(
U
*
O
-
T
*
Q
)
*
S
,
aa
=
Z
-
ae
*
W
-
ac
*
P
,
Y
=
R
-
ad
*
W
-
ab
*
P
;
r
.
save
();
r
.
transform
(
ae
,
ad
,
ac
,
ab
,
aa
,
Y
);
r
.
clip
();
r
.
drawImage
(
af
,
0
,
0
);
r
.
restore
()}
function
b
(
N
,
M
){
G
.
sub
(
M
,
N
);
G
.
unit
();
G
.
multiplyScalar
(
0.75
);
M
.
addSelf
(
G
);
N
.
subSelf
(
G
)}};
THREE
.
SVGRenderer
=
function
(){
var
y
=
null
,
r
=
new
THREE
.
Projector
(),
t
=
document
.
createElementNS
(
"
http://www.w3.org/2000/svg
"
,
"
svg
"
),
b
,
o
,
p
,
s
,
A
=
new
THREE
.
Rectangle
(),
w
=
new
THREE
.
Rectangle
(),
i
=
false
,
k
=
new
THREE
.
Color
(
4294967295
),
v
=
new
THREE
.
Color
(
4294967295
),
c
=
new
THREE
.
Color
(
4294967295
),
x
,
g
=
new
THREE
.
Vector3
(),
d
=
[],
l
=
[],
C
,
n
,
f
,
B
=
1
;
this
.
domElement
=
t
;
this
.
autoClear
=
true
;
this
.
setQuality
=
function
(
D
){
switch
(
D
){
case
"
high
"
:
B
=
1
;
break
;
case
"
low
"
:
B
=
0
;
break
}};
this
.
setSize
=
function
(
E
,
D
){
b
=
E
;
o
=
D
;
p
=
b
/
2
;
s
=
o
/
2
;
t
.
setAttribute
(
"
viewBox
"
,(
-
p
)
+
"
"
+
(
-
s
)
+
"
"
+
b
+
"
"
+
o
);
t
.
setAttribute
(
"
width
"
,
b
);
t
.
setAttribute
(
"
height
"
,
o
);
A
.
set
(
-
p
,
-
s
,
p
,
s
)};
this
.
clear
=
function
(){
while
(
t
.
childNodes
.
length
>
0
){
t
.
removeChild
(
t
.
childNodes
[
0
])}};
this
.
render
=
function
(
U
,
R
){
var
T
,
F
,
O
,
S
,
K
,
H
,
G
,
N
,
L
,
I
,
Q
,
P
,
E
,
D
,
M
,
J
;
if
(
this
.
autoClear
){
this
.
clear
()}
y
=
r
.
projectScene
(
U
,
R
);
n
=
0
;
f
=
0
;
i
=
U
.
lights
.
length
>
0
;
if
(
i
){
z
(
U
,
c
)}
for
(
T
=
0
,
F
=
y
.
length
;
T
<
F
;
T
++
){
G
=
y
[
T
];
w
.
empty
();
if
(
G
instanceof
THREE
.
RenderableParticle
){
L
=
G
.
x
*
p
;
I
=
G
.
y
*-
s
;
for
(
O
=
0
,
S
=
G
.
material
.
length
;
O
<
S
;
O
++
){
N
=
G
.
material
[
O
];
N
&&
j
(
L
,
I
,
G
,
N
,
U
)}}
else
{
if
(
G
instanceof
THREE
.
RenderableFace3
){
L
=
G
.
v1
.
x
*
p
;
I
=
G
.
v1
.
y
*-
s
;
Q
=
G
.
v2
.
x
*
p
;
P
=
G
.
v2
.
y
*-
s
;
E
=
G
.
v3
.
x
*
p
;
D
=
G
.
v3
.
y
*-
s
;
w
.
addPoint
(
L
,
I
);
w
.
addPoint
(
Q
,
P
);
w
.
addPoint
(
E
,
D
);
if
(
!
A
.
instersects
(
w
)){
continue
}
O
=
0
;
S
=
G
.
meshMaterial
.
length
;
while
(
O
<
S
){
N
=
G
.
meshMaterial
[
O
++
];
if
(
N
instanceof
THREE
.
MeshFaceMaterial
){
K
=
0
;
H
=
G
.
faceMaterial
.
length
;
while
(
K
<
H
){
N
=
G
.
faceMaterial
[
K
++
];
N
&&
h
(
L
,
I
,
Q
,
P
,
E
,
D
,
G
,
N
,
U
)}
continue
}
N
&&
h
(
L
,
I
,
Q
,
P
,
E
,
D
,
G
,
N
,
U
)}}
else
{
if
(
G
instanceof
THREE
.
RenderableFace4
){
L
=
G
.
v1
.
x
*
p
;
I
=
G
.
v1
.
y
*-
s
;
Q
=
G
.
v2
.
x
*
p
;
P
=
G
.
v2
.
y
*-
s
;
E
=
G
.
v3
.
x
*
p
;
D
=
G
.
v3
.
y
*-
s
;
M
=
G
.
v4
.
x
*
p
;
J
=
G
.
v4
.
y
*-
s
;
w
.
addPoint
(
L
,
I
);
w
.
addPoint
(
Q
,
P
);
w
.
addPoint
(
E
,
D
);
w
.
addPoint
(
M
,
J
);
if
(
!
A
.
instersects
(
w
)){
continue
}
O
=
0
;
S
=
G
.
meshMaterial
.
length
;
while
(
O
<
S
){
N
=
G
.
meshMaterial
[
O
++
];
if
(
N
instanceof
THREE
.
MeshFaceMaterial
){
K
=
0
;
H
=
G
.
faceMaterial
.
length
;
while
(
K
<
H
){
N
=
G
.
faceMaterial
[
K
++
];
N
&&
e
(
L
,
I
,
Q
,
P
,
E
,
D
,
M
,
J
,
G
,
N
,
U
)}
continue
}
N
&&
e
(
L
,
I
,
Q
,
P
,
E
,
D
,
M
,
J
,
G
,
N
,
U
)}}}}}};
function
z
(
H
,
F
){
var
E
,
G
,
D
;
F
.
setRGBA
(
0
,
0
,
0
,
1
);
for
(
E
=
0
,
G
=
H
.
lights
.
length
;
E
<
G
;
E
++
){
D
=
H
.
lights
[
E
];
if
(
D
instanceof
THREE
.
AmbientLight
){
F
.
r
+=
D
.
color
.
r
;
F
.
g
+=
D
.
color
.
g
;
F
.
b
+=
D
.
color
.
b
}}}
function
q
(
I
,
G
,
F
){
var
E
,
H
,
D
;
for
(
E
=
0
,
H
=
I
.
lights
.
length
;
E
<
H
;
E
++
){
D
=
I
.
lights
[
E
];
if
(
D
instanceof
THREE
.
DirectionalLight
){
F
.
r
+=
D
.
color
.
r
;
F
.
g
+=
D
.
color
.
g
;
F
.
b
+=
D
.
color
.
b
}
else
{
if
(
D
instanceof
THREE
.
PointLight
){
F
.
r
+=
D
.
color
.
r
;
F
.
g
+=
D
.
color
.
g
;
F
.
b
+=
D
.
color
.
b
}}}}
function
a
(
J
,
H
,
F
){
var
E
,
I
,
D
,
G
;
for
(
E
=
0
,
I
=
J
.
lights
.
length
;
E
<
I
;
E
++
){
D
=
J
.
lights
[
E
];
if
(
D
instanceof
THREE
.
DirectionalLight
){
G
=
H
.
normalWorld
.
dot
(
D
.
position
)
*
D
.
intensity
;
if
(
G
>
0
){
F
.
r
+=
D
.
color
.
r
*
G
;
F
.
g
+=
D
.
color
.
g
*
G
;
F
.
b
+=
D
.
color
.
b
*
G
}}
else
{
if
(
D
instanceof
THREE
.
PointLight
){
g
.
sub
(
D
.
position
,
H
.
centroidWorld
);
g
.
normalize
();
G
=
H
.
normalWorld
.
dot
(
g
)
*
D
.
intensity
;
if
(
G
>
0
){
F
.
r
+=
D
.
color
.
r
*
G
;
F
.
g
+=
D
.
color
.
g
*
G
;
F
.
b
+=
D
.
color
.
b
*
G
}}}}}
function
j
(
D
,
H
,
E
,
F
,
G
){
C
=
u
(
f
++
);
C
.
setAttribute
(
"
cx
"
,
D
);
C
.
setAttribute
(
"
cy
"
,
H
);
C
.
setAttribute
(
"
r
"
,
E
.
scale
.
x
*
p
);
if
(
F
instanceof
THREE
.
ParticleCircleMaterial
){
if
(
i
){
v
.
copyRGB
(
c
);
q
(
G
,
E
,
v
);
k
.
copyRGBA
(
F
.
color
);
k
.
multiplySelfRGB
(
v
);
k
.
updateStyleString
()}
else
{
k
=
F
.
color
}
C
.
setAttribute
(
"
style
"
,
"
fill:
"
+
k
.
__styleString
)}
t
.
appendChild
(
C
)}
function
h
(
F
,
E
,
D
,
L
,
K
,
J
,
G
,
I
,
H
){
C
=
m
(
n
++
);
C
.
setAttribute
(
"
d
"
,
"
M
"
+
F
+
"
"
+
E
+
"
L
"
+
D
+
"
"
+
L
+
"
L
"
+
K
+
"
,
"
+
J
+
"
z
"
);
if
(
I
instanceof
THREE
.
MeshBasicMaterial
){
k
.
__styleString
=
I
.
color
.
__styleString
}
else
{
if
(
I
instanceof
THREE
.
MeshDepthMaterial
){
x
=
1
-
(
I
.
__2near
/
(
I
.
__farPlusNear
-
G
.
z
*
I
.
__farMinusNear
));
k
.
setRGBA
(
x
,
x
,
x
,
1
)}
else
{
if
(
I
instanceof
THREE
.
MeshLambertMaterial
){
if
(
i
){
v
.
copyRGB
(
c
);
a
(
H
,
G
,
v
);
k
.
copyRGBA
(
I
.
color
);
k
.
multiplySelfRGB
(
v
);
k
.
updateStyleString
()}
else
{
k
.
__styleString
=
I
.
color
.
__styleString
}}}}
if
(
I
.
wireframe
){
C
.
setAttribute
(
"
style
"
,
"
fill: none; stroke:
"
+
k
.
__styleString
+
"
; stroke-width:
"
+
I
.
wireframe_linewidth
+
"
; stroke-opacity:
"
+
I
.
opacity
+
"
; stroke-linecap: round; stroke-linejoin: round
"
)}
else
{
C
.
setAttribute
(
"
style
"
,
"
fill:
"
+
k
.
__styleString
+
"
; fill-opacity:
"
+
I
.
opacity
)}
t
.
appendChild
(
C
)}
function
e
(
H
,
F
,
D
,
N
,
M
,
L
,
G
,
E
,
I
,
K
,
J
){
C
=
m
(
n
++
);
C
.
setAttribute
(
"
d
"
,
"
M
"
+
H
+
"
"
+
F
+
"
L
"
+
D
+
"
"
+
N
+
"
L
"
+
M
+
"
,
"
+
L
+
"
L
"
+
G
+
"
,
"
+
E
+
"
z
"
);
if
(
K
instanceof
THREE
.
MeshBasicMaterial
){
k
.
__styleString
=
K
.
color
.
__styleString
}
else
{
if
(
K
instanceof
THREE
.
MeshLambertMaterial
){
if
(
i
){
v
.
copyRGB
(
c
);
a
(
J
,
I
,
v
);
k
.
copyRGBA
(
K
.
color
);
k
.
multiplySelfRGB
(
v
);
k
.
updateStyleString
()}
else
{
k
.
__styleString
=
K
.
color
.
__styleString
}}}
if
(
K
.
wireframe
){
C
.
setAttribute
(
"
style
"
,
"
fill: none; stroke:
"
+
k
.
__styleString
+
"
; stroke-width:
"
+
K
.
wireframe_linewidth
+
"
; stroke-opacity:
"
+
K
.
opacity
+
"
; stroke-linecap: round; stroke-linejoin: round
"
)}
else
{
C
.
setAttribute
(
"
style
"
,
"
fill:
"
+
k
.
__styleString
+
"
; fill-opacity:
"
+
K
.
opacity
)}
t
.
appendChild
(
C
)}
function
m
(
D
){
if
(
d
[
D
]
==
null
){
d
[
D
]
=
document
.
createElementNS
(
"
http://www.w3.org/2000/svg
"
,
"
path
"
);
if
(
B
==
0
){
d
[
D
].
setAttribute
(
"
shape-rendering
"
,
"
crispEdges
"
)}
return
d
[
D
]}
return
d
[
D
]}
function
u
(
D
){
if
(
l
[
D
]
==
null
){
l
[
D
]
=
document
.
createElementNS
(
"
http://www.w3.org/2000/svg
"
,
"
circle
"
);
if
(
B
==
0
){
l
[
D
].
setAttribute
(
"
shape-rendering
"
,
"
crispEdges
"
)}
return
l
[
D
]}
return
l
[
D
]}};
THREE
.
WebGLRenderer
=
function
(
q
){
var
h
=
document
.
createElement
(
"
canvas
"
),
f
,
n
,
k
=
new
THREE
.
Matrix4
(),
d
,
g
=
0
,
c
=
1
,
s
=
2
,
o
=
3
,
l
=
b
(
q
,
5
);
this
.
domElement
=
h
;
this
.
autoClear
=
true
;
a
();
i
(
l
.
directional
,
l
.
point
);
function
b
(
x
,
y
){
if
(
x
){
var
u
,
w
,
t
,
v
=
pointLights
=
maxDirLights
=
maxPointLights
=
0
;
for
(
u
=
0
,
w
=
x
.
lights
.
length
;
u
<
w
;
u
++
){
t
=
x
.
lights
[
u
];
if
(
t
instanceof
THREE
.
DirectionalLight
){
v
++
}
if
(
t
instanceof
THREE
.
PointLight
){
pointLights
++
}}
if
((
pointLights
+
v
)
<=
y
){
maxDirLights
=
v
;
maxPointLights
=
pointLights
}
else
{
maxDirLights
=
Math
.
ceil
(
y
*
v
/
(
pointLights
+
v
));
maxPointLights
=
y
-
maxDirLights
}
return
{
directional
:
maxDirLights
,
point
:
maxPointLights
}}
return
{
directional
:
1
,
point
:
y
-
1
}}
this
.
setSize
=
function
(
u
,
t
){
h
.
width
=
u
;
h
.
height
=
t
;
f
.
viewport
(
0
,
0
,
h
.
width
,
h
.
height
)};
this
.
clear
=
function
(){
f
.
clear
(
f
.
COLOR_BUFFER_BIT
|
f
.
DEPTH_BUFFER_BIT
)};
this
.
setupLights
=
function
(
z
){
var
w
,
D
,
x
,
u
,
A
,
E
,
v
=
[],
B
=
[],
C
=
[],
t
=
[],
y
=
[];
f
.
uniform1i
(
n
.
enableLighting
,
z
.
lights
.
length
);
for
(
w
=
0
,
D
=
z
.
lights
.
length
;
w
<
D
;
w
++
){
x
=
z
.
lights
[
w
];
if
(
x
instanceof
THREE
.
AmbientLight
){
v
.
push
(
x
)}
else
{
if
(
x
instanceof
THREE
.
DirectionalLight
){
C
.
push
(
x
)}
else
{
if
(
x
instanceof
THREE
.
PointLight
){
B
.
push
(
x
)}}}}
u
=
A
=
E
=
0
;
for
(
w
=
0
,
D
=
v
.
length
;
w
<
D
;
w
++
){
u
+=
v
[
w
].
color
.
r
;
A
+=
v
[
w
].
color
.
g
;
E
+=
v
[
w
].
color
.
b
}
f
.
uniform3f
(
n
.
ambientLightColor
,
u
,
A
,
E
);
t
=
[];
y
=
[];
for
(
w
=
0
,
D
=
C
.
length
;
w
<
D
;
w
++
){
x
=
C
[
w
];
t
.
push
(
x
.
color
.
r
*
x
.
intensity
);
t
.
push
(
x
.
color
.
g
*
x
.
intensity
);
t
.
push
(
x
.
color
.
b
*
x
.
intensity
);
y
.
push
(
x
.
position
.
x
);
y
.
push
(
x
.
position
.
y
);
y
.
push
(
x
.
position
.
z
)}
if
(
C
.
length
){
f
.
uniform1i
(
n
.
directionalLightNumber
,
C
.
length
);
f
.
uniform3fv
(
n
.
directionalLightDirection
,
y
);
f
.
uniform3fv
(
n
.
directionalLightColor
,
t
)}
t
=
[];
y
=
[];
for
(
w
=
0
,
D
=
B
.
length
;
w
<
D
;
w
++
){
x
=
B
[
w
];
t
.
push
(
x
.
color
.
r
*
x
.
intensity
);
t
.
push
(
x
.
color
.
g
*
x
.
intensity
);
t
.
push
(
x
.
color
.
b
*
x
.
intensity
);
y
.
push
(
x
.
position
.
x
);
y
.
push
(
x
.
position
.
y
);
y
.
push
(
x
.
position
.
z
)}
if
(
B
.
length
){
f
.
uniform1i
(
n
.
pointLightNumber
,
B
.
length
);
f
.
uniform3fv
(
n
.
pointLightPosition
,
y
);
f
.
uniform3fv
(
n
.
pointLightColor
,
t
)}};
this
.
createBuffers
=
function
(
M
,
K
){
var
I
,
A
,
C
,
z
,
H
,
L
,
y
,
w
,
v
,
u
,
t
,
x
=
M
.
materialFaceGroup
[
K
],
E
=
[],
G
=
[],
D
=
[],
J
=
[],
F
=
[],
B
=
0
;
for
(
I
=
0
,
A
=
x
.
faces
.
length
;
I
<
A
;
I
++
){
C
=
x
.
faces
[
I
];
z
=
M
.
geometry
.
faces
[
C
];
H
=
z
.
vertexNormals
;
L
=
z
.
normal
;
y
=
M
.
geometry
.
uvs
[
C
];
if
(
z
instanceof
THREE
.
Face3
){
w
=
M
.
geometry
.
vertices
[
z
.
a
].
position
;
v
=
M
.
geometry
.
vertices
[
z
.
b
].
position
;
u
=
M
.
geometry
.
vertices
[
z
.
c
].
position
;
D
.
push
(
w
.
x
,
w
.
y
,
w
.
z
);
D
.
push
(
v
.
x
,
v
.
y
,
v
.
z
);
D
.
push
(
u
.
x
,
u
.
y
,
u
.
z
);
if
(
H
.
length
==
3
){
J
.
push
(
H
[
0
].
x
,
H
[
0
].
y
,
H
[
0
].
z
);
J
.
push
(
H
[
1
].
x
,
H
[
1
].
y
,
H
[
1
].
z
);
J
.
push
(
H
[
2
].
x
,
H
[
2
].
y
,
H
[
2
].
z
)}
else
{
J
.
push
(
L
.
x
,
L
.
y
,
L
.
z
);
J
.
push
(
L
.
x
,
L
.
y
,
L
.
z
);
J
.
push
(
L
.
x
,
L
.
y
,
L
.
z
)}
if
(
y
){
F
.
push
(
y
[
0
].
u
,
y
[
0
].
v
);
F
.
push
(
y
[
1
].
u
,
y
[
1
].
v
);
F
.
push
(
y
[
2
].
u
,
y
[
2
].
v
)}
E
.
push
(
B
,
B
+
1
,
B
+
2
);
G
.
push
(
B
,
B
+
1
);
G
.
push
(
B
,
B
+
2
);
G
.
push
(
B
+
1
,
B
+
2
);
B
+=
3
}
else
{
if
(
z
instanceof
THREE
.
Face4
){
w
=
M
.
geometry
.
vertices
[
z
.
a
].
position
;
v
=
M
.
geometry
.
vertices
[
z
.
b
].
position
;
u
=
M
.
geometry
.
vertices
[
z
.
c
].
position
;
t
=
M
.
geometry
.
vertices
[
z
.
d
].
position
;
D
.
push
(
w
.
x
,
w
.
y
,
w
.
z
);
D
.
push
(
v
.
x
,
v
.
y
,
v
.
z
);
D
.
push
(
u
.
x
,
u
.
y
,
u
.
z
);
D
.
push
(
t
.
x
,
t
.
y
,
t
.
z
);
if
(
H
.
length
==
4
){
J
.
push
(
H
[
0
].
x
,
H
[
0
].
y
,
H
[
0
].
z
);
J
.
push
(
H
[
1
].
x
,
H
[
1
].
y
,
H
[
1
].
z
);
J
.
push
(
H
[
2
].
x
,
H
[
2
].
y
,
H
[
2
].
z
);
J
.
push
(
H
[
3
].
x
,
H
[
3
].
y
,
H
[
3
].
z
)}
else
{
J
.
push
(
L
.
x
,
L
.
y
,
L
.
z
);
J
.
push
(
L
.
x
,
L
.
y
,
L
.
z
);
J
.
push
(
L
.
x
,
L
.
y
,
L
.
z
);
J
.
push
(
L
.
x
,
L
.
y
,
L
.
z
)}
if
(
y
){
F
.
push
(
y
[
0
].
u
,
y
[
0
].
v
);
F
.
push
(
y
[
1
].
u
,
y
[
1
].
v
);
F
.
push
(
y
[
2
].
u
,
y
[
2
].
v
);
F
.
push
(
y
[
3
].
u
,
y
[
3
].
v
)}
E
.
push
(
B
,
B
+
1
,
B
+
2
);
E
.
push
(
B
,
B
+
2
,
B
+
3
);
G
.
push
(
B
,
B
+
1
);
G
.
push
(
B
,
B
+
2
);
G
.
push
(
B
,
B
+
3
);
G
.
push
(
B
+
1
,
B
+
2
);
G
.
push
(
B
+
2
,
B
+
3
);
B
+=
4
}}}
if
(
!
D
.
length
){
return
}
x
.
__webGLVertexBuffer
=
f
.
createBuffer
();
f
.
bindBuffer
(
f
.
ARRAY_BUFFER
,
x
.
__webGLVertexBuffer
);
f
.
bufferData
(
f
.
ARRAY_BUFFER
,
new
Float32Array
(
D
),
f
.
STATIC_DRAW
);
x
.
__webGLNormalBuffer
=
f
.
createBuffer
();
f
.
bindBuffer
(
f
.
ARRAY_BUFFER
,
x
.
__webGLNormalBuffer
);
f
.
bufferData
(
f
.
ARRAY_BUFFER
,
new
Float32Array
(
J
),
f
.
STATIC_DRAW
);
x
.
__webGLUVBuffer
=
f
.
createBuffer
();
f
.
bindBuffer
(
f
.
ARRAY_BUFFER
,
x
.
__webGLUVBuffer
);
f
.
bufferData
(
f
.
ARRAY_BUFFER
,
new
Float32Array
(
F
),
f
.
STATIC_DRAW
);
x
.
__webGLFaceBuffer
=
f
.
createBuffer
();
f
.
bindBuffer
(
f
.
ELEMENT_ARRAY_BUFFER
,
x
.
__webGLFaceBuffer
);
f
.
bufferData
(
f
.
ELEMENT_ARRAY_BUFFER
,
new
Uint16Array
(
E
),
f
.
STATIC_DRAW
);
x
.
__webGLLineBuffer
=
f
.
createBuffer
();
f
.
bindBuffer
(
f
.
ELEMENT_ARRAY_BUFFER
,
x
.
__webGLLineBuffer
);
f
.
bufferData
(
f
.
ELEMENT_ARRAY_BUFFER
,
new
Uint16Array
(
G
),
f
.
STATIC_DRAW
);
x
.
__webGLFaceCount
=
E
.
length
;
x
.
__webGLLineCount
=
G
.
length
};
this
.
renderBuffer
=
function
(
u
,
t
){
if
(
u
instanceof
THREE
.
MeshPhongMaterial
){
mAmbient
=
u
.
ambient
;
mDiffuse
=
u
.
diffuse
;
mSpecular
=
u
.
specular
;
f
.
uniform4f
(
n
.
mAmbient
,
mAmbient
.
r
,
mAmbient
.
g
,
mAmbient
.
b
,
u
.
opacity
);
f
.
uniform4f
(
n
.
mDiffuse
,
mDiffuse
.
r
,
mDiffuse
.
g
,
mDiffuse
.
b
,
u
.
opacity
);
f
.
uniform4f
(
n
.
mSpecular
,
mSpecular
.
r
,
mSpecular
.
g
,
mSpecular
.
b
,
u
.
opacity
);
f
.
uniform1f
(
n
.
mShininess
,
u
.
shininess
);
f
.
uniform1i
(
n
.
material
,
o
)}
else
{
if
(
u
instanceof
THREE
.
MeshColorFillMaterial
){
color
=
u
.
color
;
f
.
uniform4f
(
n
.
mColor
,
color
.
r
*
color
.
a
,
color
.
g
*
color
.
a
,
color
.
b
*
color
.
a
,
color
.
a
);
f
.
uniform1i
(
n
.
material
,
g
)}
else
{
if
(
u
instanceof
THREE
.
MeshColorStrokeMaterial
){
lineWidth
=
u
.
lineWidth
;
color
=
u
.
color
;
f
.
uniform4f
(
n
.
mColor
,
color
.
r
*
color
.
a
,
color
.
g
*
color
.
a
,
color
.
b
*
color
.
a
,
color
.
a
);
f
.
uniform1i
(
n
.
material
,
c
)}
else
{
if
(
u
instanceof
THREE
.
MeshBitmapMaterial
){
if
(
!
u
.
__webGLTexture
&&
u
.
loaded
){
u
.
__webGLTexture
=
f
.
createTexture
();
f
.
bindTexture
(
f
.
TEXTURE_2D
,
u
.
__webGLTexture
);
f
.
texImage2D
(
f
.
TEXTURE_2D
,
0
,
f
.
RGBA
,
f
.
RGBA
,
f
.
UNSIGNED_BYTE
,
u
.
bitmap
);
f
.
texParameteri
(
f
.
TEXTURE_2D
,
f
.
TEXTURE_MAG_FILTER
,
f
.
LINEAR
);
f
.
texParameteri
(
f
.
TEXTURE_2D
,
f
.
TEXTURE_MIN_FILTER
,
f
.
LINEAR_MIPMAP_LINEAR
);
f
.
generateMipmap
(
f
.
TEXTURE_2D
);
f
.
bindTexture
(
f
.
TEXTURE_2D
,
null
)}
f
.
activeTexture
(
f
.
TEXTURE0
);
f
.
bindTexture
(
f
.
TEXTURE_2D
,
u
.
__webGLTexture
);
f
.
uniform1i
(
n
.
tDiffuse
,
0
);
f
.
uniform1i
(
n
.
material
,
s
)}}}}
f
.
bindBuffer
(
f
.
ARRAY_BUFFER
,
t
.
__webGLVertexBuffer
);
f
.
vertexAttribPointer
(
n
.
position
,
3
,
f
.
FLOAT
,
false
,
0
,
0
);
f
.
bindBuffer
(
f
.
ARRAY_BUFFER
,
t
.
__webGLNormalBuffer
);
f
.
vertexAttribPointer
(
n
.
normal
,
3
,
f
.
FLOAT
,
false
,
0
,
0
);
if
(
u
instanceof
THREE
.
MeshBitmapMaterial
){
f
.
bindBuffer
(
f
.
ARRAY_BUFFER
,
t
.
__webGLUVBuffer
);
f
.
enableVertexAttribArray
(
n
.
uv
);
f
.
vertexAttribPointer
(
n
.
uv
,
2
,
f
.
FLOAT
,
false
,
0
,
0
)}
else
{
f
.
disableVertexAttribArray
(
n
.
uv
)}
if
(
u
instanceof
THREE
.
MeshBitmapMaterial
||
u
instanceof
THREE
.
MeshColorFillMaterial
||
u
instanceof
THREE
.
MeshPhongMaterial
){
f
.
bindBuffer
(
f
.
ELEMENT_ARRAY_BUFFER
,
t
.
__webGLFaceBuffer
);
f
.
drawElements
(
f
.
TRIANGLES
,
t
.
__webGLFaceCount
,
f
.
UNSIGNED_SHORT
,
0
)}
else
{
if
(
u
instanceof
THREE
.
MeshColorStrokeMaterial
){
f
.
lineWidth
(
lineWidth
);
f
.
bindBuffer
(
f
.
ELEMENT_ARRAY_BUFFER
,
t
.
__webGLLineBuffer
);
f
.
drawElements
(
f
.
LINES
,
t
.
__webGLLineCount
,
f
.
UNSIGNED_SHORT
,
0
)}}};
this
.
renderMesh
=
function
(
v
,
y
){
var
x
,
u
,
t
,
w
,
B
,
z
,
A
,
C
;
for
(
B
in
v
.
materialFaceGroup
){
C
=
v
.
materialFaceGroup
[
B
];
if
(
!
C
.
__webGLVertexBuffer
){
this
.
createBuffers
(
v
,
B
)}
for
(
t
=
0
,
w
=
v
.
material
.
length
;
t
<
w
;
t
++
){
A
=
v
.
material
[
t
];
if
(
A
instanceof
THREE
.
MeshFaceMaterial
){
for
(
x
=
0
,
u
=
C
.
material
.
length
;
x
<
u
;
x
++
){
z
=
C
.
material
[
x
];
this
.
renderBuffer
(
z
,
C
)}}
else
{
z
=
A
;
this
.
renderBuffer
(
z
,
C
)}}}};
this
.
setupMatrices
=
function
(
t
,
u
){
t
.
autoUpdateMatrix
&&
t
.
updateMatrix
();
k
.
multiply
(
u
.
matrix
,
t
.
matrix
);
n
.
viewMatrixArray
=
new
Float32Array
(
u
.
matrix
.
flatten
());
n
.
modelViewMatrixArray
=
new
Float32Array
(
k
.
flatten
());
n
.
projectionMatrixArray
=
new
Float32Array
(
u
.
projectionMatrix
.
flatten
());
d
=
THREE
.
Matrix4
.
makeInvert3x3
(
k
).
transpose
();
n
.
normalMatrixArray
=
new
Float32Array
(
d
.
m
);
f
.
uniformMatrix4fv
(
n
.
viewMatrix
,
false
,
n
.
viewMatrixArray
);
f
.
uniformMatrix4fv
(
n
.
modelViewMatrix
,
false
,
n
.
modelViewMatrixArray
);
f
.
uniformMatrix4fv
(
n
.
projectionMatrix
,
false
,
n
.
projectionMatrixArray
);
f
.
uniformMatrix3fv
(
n
.
normalMatrix
,
false
,
n
.
normalMatrixArray
);
f
.
uniformMatrix4fv
(
n
.
objMatrix
,
false
,
new
Float32Array
(
t
.
matrix
.
flatten
()))};
this
.
render
=
function
(
w
,
v
){
var
x
,
u
,
t
;
if
(
this
.
autoClear
){
this
.
clear
()}
v
.
autoUpdateMatrix
&&
v
.
updateMatrix
();
f
.
uniform3f
(
n
.
cameraPosition
,
v
.
position
.
x
,
v
.
position
.
y
,
v
.
position
.
z
);
this
.
setupLights
(
w
);
for
(
x
=
0
,
u
=
w
.
objects
.
length
;
x
<
u
;
x
++
){
t
=
w
.
objects
[
x
];
this
.
setupMatrices
(
t
,
v
);
if
(
t
instanceof
THREE
.
Mesh
){
this
.
renderMesh
(
t
,
v
)}
else
{
if
(
t
instanceof
THREE
.
Line
){}
else
{
if
(
t
instanceof
THREE
.
Particle
){}}}}};
this
.
setFaceCulling
=
function
(
u
,
t
){
if
(
u
){
if
(
!
t
||
t
==
"
ccw
"
){
f
.
frontFace
(
f
.
CCW
)}
else
{
f
.
frontFace
(
f
.
CW
)}
if
(
u
==
"
back
"
){
f
.
cullFace
(
f
.
BACK
)}
else
{
if
(
u
==
"
front
"
){
f
.
cullFace
(
f
.
FRONT
)}
else
{
f
.
cullFace
(
f
.
FRONT_AND_BACK
)}}
f
.
enable
(
f
.
CULL_FACE
)}
else
{
f
.
disable
(
f
.
CULL_FACE
)}};
function
a
(){
try
{
f
=
h
.
getContext
(
"
experimental-webgl
"
,{
antialias
:
true
})}
catch
(
t
){}
if
(
!
f
){
alert
(
"
WebGL not supported
"
);
throw
"
cannot create webgl context
"
}
f
.
clearColor
(
0
,
0
,
0
,
1
);
f
.
clearDepth
(
1
);
f
.
enable
(
f
.
DEPTH_TEST
);
f
.
depthFunc
(
f
.
LEQUAL
);
f
.
frontFace
(
f
.
CCW
);
f
.
cullFace
(
f
.
BACK
);
f
.
enable
(
f
.
CULL_FACE
);
f
.
enable
(
f
.
BLEND
);
f
.
blendFunc
(
f
.
ONE
,
f
.
ONE_MINUS_SRC_ALPHA
);
f
.
clearColor
(
0
,
0
,
0
,
0
)}
function
p
(
t
,
u
){
var
v
=
[
"
#ifdef GL_ES
"
,
"
precision highp float;
"
,
"
#endif
"
,
t
?
"
#define MAX_DIR_LIGHTS
"
+
t
:
""
,
u
?
"
#define MAX_POINT_LIGHTS
"
+
u
:
""
,
"
uniform int material;
"
,
"
uniform sampler2D tDiffuse;
"
,
"
uniform vec4 mColor;
"
,
"
uniform vec4 mAmbient;
"
,
"
uniform vec4 mDiffuse;
"
,
"
uniform vec4 mSpecular;
"
,
"
uniform float mShininess;
"
,
"
uniform int pointLightNumber;
"
,
"
uniform int directionalLightNumber;
"
,
t
?
"
uniform mat4 viewMatrix;
"
:
""
,
t
?
"
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
"
:
""
,
"
varying vec3 vNormal;
"
,
"
varying vec2 vUv;
"
,
"
varying vec3 vLightWeighting;
"
,
u
?
"
varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];
"
:
""
,
"
varying vec3 vViewPosition;
"
,
"
void main() {
"
,
"
if ( material == 3 ) {
"
,
"
vec3 normal = normalize( vNormal );
"
,
"
vec3 viewPosition = normalize( vViewPosition );
"
,
u
?
"
vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
u
?
"
vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
u
?
"
for( int i = 0; i < pointLightNumber; i++ ) {
"
:
""
,
u
?
"
vec3 pointVector = normalize( vPointLightVector[ i ] );
"
:
""
,
u
?
"
vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );
"
:
""
,
u
?
"
float pointDotNormalHalf = dot( normal, pointHalfVector );
"
:
""
,
u
?
"
float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );
"
:
""
,
u
?
"
float pointSpecularWeight = 0.0;
"
:
""
,
u
?
"
if ( pointDotNormalHalf >= 0.0 )
"
:
""
,
u
?
"
pointSpecularWeight = pow( pointDotNormalHalf, mShininess );
"
:
""
,
u
?
"
pointDiffuse += mDiffuse * pointDiffuseWeight;
"
:
""
,
u
?
"
pointSpecular += mSpecular * pointSpecularWeight;
"
:
""
,
u
?
"
}
"
:
""
,
t
?
"
vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
t
?
"
vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );
"
:
""
,
t
?
"
for( int i = 0; i < directionalLightNumber; i++ ) {
"
:
""
,
t
?
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
:
""
,
t
?
"
vec3 dirVector = normalize( lDirection.xyz );
"
:
""
,
t
?
"
vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );
"
:
""
,
t
?
"
float dirDotNormalHalf = dot( normal, dirHalfVector );
"
:
""
,
t
?
"
float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );
"
:
""
,
t
?
"
float dirSpecularWeight = 0.0;
"
:
""
,
t
?
"
if ( dirDotNormalHalf >= 0.0 )
"
:
""
,
t
?
"
dirSpecularWeight = pow( dirDotNormalHalf, mShininess );
"
:
""
,
t
?
"
dirDiffuse += mDiffuse * dirDiffuseWeight;
"
:
""
,
t
?
"
dirSpecular += mSpecular * dirSpecularWeight;
"
:
""
,
t
?
"
}
"
:
""
,
"
vec4 totalLight = mAmbient;
"
,
t
?
"
totalLight += dirDiffuse + dirSpecular;
"
:
""
,
u
?
"
totalLight += pointDiffuse + pointSpecular;
"
:
""
,
"
gl_FragColor = vec4( totalLight.xyz * vLightWeighting, 1.0 );
"
,
"
} else if ( material == 2 ) {
"
,
"
vec4 texelColor = texture2D( tDiffuse, vUv );
"
,
"
gl_FragColor = vec4( texelColor.rgb * vLightWeighting, texelColor.a );
"
,
"
} else if ( material == 1 ) {
"
,
"
gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );
"
,
"
} else {
"
,
"
gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );
"
,
"
}
"
,
"
}
"
];
return
v
.
join
(
"
\n
"
)}
function
j
(
t
,
u
){
var
v
=
[
t
?
"
#define MAX_DIR_LIGHTS
"
+
t
:
""
,
u
?
"
#define MAX_POINT_LIGHTS
"
+
u
:
""
,
"
attribute vec3 position;
"
,
"
attribute vec3 normal;
"
,
"
attribute vec2 uv;
"
,
"
uniform vec3 cameraPosition;
"
,
"
uniform bool enableLighting;
"
,
"
uniform int pointLightNumber;
"
,
"
uniform int directionalLightNumber;
"
,
"
uniform vec3 ambientLightColor;
"
,
t
?
"
uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
"
:
""
,
t
?
"
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
"
:
""
,
u
?
"
uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
"
:
""
,
u
?
"
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
"
:
""
,
"
uniform mat4 objMatrix;
"
,
"
uniform mat4 viewMatrix;
"
,
"
uniform mat4 modelViewMatrix;
"
,
"
uniform mat4 projectionMatrix;
"
,
"
uniform mat3 normalMatrix;
"
,
"
varying vec3 vNormal;
"
,
"
varying vec2 vUv;
"
,
"
varying vec3 vLightWeighting;
"
,
u
?
"
varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];
"
:
""
,
"
varying vec3 vViewPosition;
"
,
"
void main(void) {
"
,
"
vec4 mPosition = objMatrix * vec4( position, 1.0 );
"
,
"
vViewPosition = cameraPosition - mPosition.xyz;
"
,
"
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
"
,
"
vec3 transformedNormal = normalize( normalMatrix * normal );
"
,
"
if ( !enableLighting ) {
"
,
"
vLightWeighting = vec3( 1.0, 1.0, 1.0 );
"
,
"
} else {
"
,
"
vLightWeighting = ambientLightColor;
"
,
t
?
"
for( int i = 0; i < directionalLightNumber; i++ ) {
"
:
""
,
t
?
"
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
"
:
""
,
t
?
"
float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );
"
:
""
,
t
?
"
vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;
"
:
""
,
t
?
"
}
"
:
""
,
u
?
"
for( int i = 0; i < pointLightNumber; i++ ) {
"
:
""
,
u
?
"
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
"
:
""
,
u
?
"
vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );
"
:
""
,
u
?
"
float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );
"
:
""
,
u
?
"
vLightWeighting += pointLightColor[ i ] * pointLightWeighting;
"
:
""
,
u
?
"
}
"
:
""
,
"
}
"
,
"
vNormal = transformedNormal;
"
,
"
vUv = uv;
"
,
"
gl_Position = projectionMatrix * mvPosition;
"
,
"
}
"
];
return
v
.
join
(
"
\n
"
)}
function
i
(
t
,
u
){
n
=
f
.
createProgram
();
f
.
attachShader
(
n
,
r
(
"
fragment
"
,
p
(
t
,
u
)));
f
.
attachShader
(
n
,
r
(
"
vertex
"
,
j
(
t
,
u
)));
f
.
linkProgram
(
n
);
if
(
!
f
.
getProgramParameter
(
n
,
f
.
LINK_STATUS
)){
alert
(
"
Could not initialise shaders
"
)}
f
.
useProgram
(
n
);
n
.
viewMatrix
=
f
.
getUniformLocation
(
n
,
"
viewMatrix
"
);
n
.
modelViewMatrix
=
f
.
getUniformLocation
(
n
,
"
modelViewMatrix
"
);
n
.
projectionMatrix
=
f
.
getUniformLocation
(
n
,
"
projectionMatrix
"
);
n
.
normalMatrix
=
f
.
getUniformLocation
(
n
,
"
normalMatrix
"
);
n
.
objMatrix
=
f
.
getUniformLocation
(
n
,
"
objMatrix
"
);
n
.
cameraPosition
=
f
.
getUniformLocation
(
n
,
"
cameraPosition
"
);
n
.
enableLighting
=
f
.
getUniformLocation
(
n
,
"
enableLighting
"
);
n
.
ambientLightColor
=
f
.
getUniformLocation
(
n
,
"
ambientLightColor
"
);
if
(
t
){
n
.
directionalLightNumber
=
f
.
getUniformLocation
(
n
,
"
directionalLightNumber
"
);
n
.
directionalLightColor
=
f
.
getUniformLocation
(
n
,
"
directionalLightColor
"
);
n
.
directionalLightDirection
=
f
.
getUniformLocation
(
n
,
"
directionalLightDirection
"
)}
if
(
u
){
n
.
pointLightNumber
=
f
.
getUniformLocation
(
n
,
"
pointLightNumber
"
);
n
.
pointLightColor
=
f
.
getUniformLocation
(
n
,
"
pointLightColor
"
);
n
.
pointLightPosition
=
f
.
getUniformLocation
(
n
,
"
pointLightPosition
"
)}
n
.
material
=
f
.
getUniformLocation
(
n
,
"
material
"
);
n
.
mColor
=
f
.
getUniformLocation
(
n
,
"
mColor
"
);
n
.
mAmbient
=
f
.
getUniformLocation
(
n
,
"
mAmbient
"
);
n
.
mDiffuse
=
f
.
getUniformLocation
(
n
,
"
mDiffuse
"
);
n
.
mSpecular
=
f
.
getUniformLocation
(
n
,
"
mSpecular
"
);
n
.
mShininess
=
f
.
getUniformLocation
(
n
,
"
mShininess
"
);
n
.
tDiffuse
=
f
.
getUniformLocation
(
n
,
"
tDiffuse
"
);
f
.
uniform1i
(
n
.
tDiffuse
,
0
);
n
.
position
=
f
.
getAttribLocation
(
n
,
"
position
"
);
f
.
enableVertexAttribArray
(
n
.
position
);
n
.
normal
=
f
.
getAttribLocation
(
n
,
"
normal
"
);
f
.
enableVertexAttribArray
(
n
.
normal
);
n
.
uv
=
f
.
getAttribLocation
(
n
,
"
uv
"
);
f
.
enableVertexAttribArray
(
n
.
uv
);
n
.
viewMatrixArray
=
new
Float32Array
(
16
);
n
.
modelViewMatrixArray
=
new
Float32Array
(
16
);
n
.
projectionMatrixArray
=
new
Float32Array
(
16
)}
function
r
(
u
,
t
){
var
v
;
if
(
u
==
"
fragment
"
){
v
=
f
.
createShader
(
f
.
FRAGMENT_SHADER
)}
else
{
if
(
u
==
"
vertex
"
){
v
=
f
.
createShader
(
f
.
VERTEX_SHADER
)}}
f
.
shaderSource
(
v
,
t
);
f
.
compileShader
(
v
);
if
(
!
f
.
getShaderParameter
(
v
,
f
.
COMPILE_STATUS
)){
alert
(
f
.
getShaderInfoLog
(
v
));
return
null
}
return
v
}
function
e
(){
var
t
=
{
MAX_VARYING_VECTORS
:
f
.
getParameter
(
f
.
MAX_VARYING_VECTORS
),
MAX_VERTEX_ATTRIBS
:
f
.
getParameter
(
f
.
MAX_VERTEX_ATTRIBS
),
MAX_TEXTURE_IMAGE_UNITS
:
f
.
getParameter
(
f
.
MAX_TEXTURE_IMAGE_UNITS
),
MAX_VERTEX_TEXTURE_IMAGE_UNITS
:
f
.
getParameter
(
f
.
MAX_VERTEX_TEXTURE_IMAGE_UNITS
),
MAX_COMBINED_TEXTURE_IMAGE_UNITS
:
f
.
getParameter
(
f
.
MAX_COMBINED_TEXTURE_IMAGE_UNITS
),
MAX_VERTEX_UNIFORM_VECTORS
:
f
.
getParameter
(
f
.
MAX_VERTEX_UNIFORM_VECTORS
),
MAX_FRAGMENT_UNIFORM_VECTORS
:
f
.
getParameter
(
f
.
MAX_FRAGMENT_UNIFORM_VECTORS
)};
return
t
}
function
m
(
u
){
var
t
,
v
=
""
;
for
(
t
in
u
){
v
+=
t
+
"
:
"
+
u
[
t
]
+
"
\n
"
}
return
v
}};
THREE
.
RenderableFace3
=
function
(){
this
.
v1
=
new
THREE
.
Vector2
();
this
.
v2
=
new
THREE
.
Vector2
();
this
.
v3
=
new
THREE
.
Vector2
();
this
.
centroidWorld
=
new
THREE
.
Vector3
();
this
.
centroidScreen
=
new
THREE
.
Vector3
();
this
.
normalWorld
=
new
THREE
.
Vector3
();
this
.
z
=
null
;
this
.
color
=
null
;
this
.
material
=
null
};
THREE
.
RenderableFace4
=
function
(){
this
.
v1
=
new
THREE
.
Vector2
();
this
.
v2
=
new
THREE
.
Vector2
();
this
.
v3
=
new
THREE
.
Vector2
();
this
.
v4
=
new
THREE
.
Vector2
();
this
.
centroidWorld
=
new
THREE
.
Vector3
();
this
.
centroidScreen
=
new
THREE
.
Vector3
();
this
.
normalWorld
=
new
THREE
.
Vector3
();
this
.
z
=
null
;
this
.
color
=
null
;
this
.
material
=
null
};
THREE
.
RenderableParticle
=
function
(){
this
.
x
=
null
;
this
.
y
=
null
;
this
.
z
=
null
;
this
.
rotation
=
null
;
this
.
scale
=
new
THREE
.
Vector2
();
this
.
color
=
null
;
this
.
material
=
null
};
THREE
.
RenderableLine
=
function
(){
this
.
v1
=
new
THREE
.
Vector2
();
this
.
v2
=
new
THREE
.
Vector2
();
this
.
z
=
null
;
this
.
color
=
null
;
this
.
material
=
null
};
\ No newline at end of file
src/materials/MeshDepthMaterial.js
0 → 100644
浏览文件 @
aebe8986
/**
* @author mr.doob / http://mrdoob.com/
*
* parameters = {
* near: <float>,
* far: <float>,
* wireframe: <boolean>,
* wireframe_linewidth: <float>
* }
*/
THREE
.
MeshDepthMaterial
=
function
(
parameters
)
{
this
.
near
=
1
;
this
.
far
=
1000
;
this
.
opacity
=
1
;
this
.
wireframe
=
false
;
this
.
wireframe_linewidth
=
1
;
if
(
parameters
)
{
if
(
parameters
.
near
!==
undefined
)
this
.
near
=
parameters
.
near
;
if
(
parameters
.
far
!==
undefined
)
this
.
far
=
parameters
.
far
;
if
(
parameters
.
opacity
!==
undefined
)
this
.
opacity
=
parameters
.
opacity
;
if
(
parameters
.
wireframe
!==
undefined
)
this
.
wireframe
=
parameters
.
wireframe
;
if
(
parameters
.
wireframe_linewidth
!==
undefined
)
this
.
wireframe_linewidth
=
parameters
.
wireframe_linewidth
;
}
this
.
__2near
=
2
*
this
.
near
;
this
.
__farPlusNear
=
this
.
far
+
this
.
near
;
this
.
__farMinusNear
=
this
.
far
-
this
.
near
;
this
.
toString
=
function
()
{
return
'
THREE.MeshDepthMaterial
'
;
};
}
src/renderers/CanvasRenderer.js
浏览文件 @
aebe8986
...
...
@@ -722,6 +722,7 @@ THREE.CanvasRenderer = function () {
_context
.
moveTo
(
x0
,
y0
);
_context
.
lineTo
(
x1
,
y1
);
_context
.
lineTo
(
x2
,
y2
);
_context
.
lineTo
(
x0
,
y0
);
_context
.
closePath
();
x1
-=
x0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录