Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
08c8108d
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,发现更多精彩内容 >>
提交
08c8108d
编写于
5月 27, 2012
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
GUI: Geometry exporter starting to work :)
上级
5958803c
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
245 addition
and
207 deletion
+245
-207
build/Three.js
build/Three.js
+21
-21
build/custom/ThreeCanvas.js
build/custom/ThreeCanvas.js
+12
-12
build/custom/ThreeExtras.js
build/custom/ThreeExtras.js
+9
-9
build/custom/ThreeWebGL.js
build/custom/ThreeWebGL.js
+12
-12
gui/js/ui/Sidebar.Properties.Geometry.js
gui/js/ui/Sidebar.Properties.Geometry.js
+31
-0
src/loaders/GeometryLoader.js
src/loaders/GeometryLoader.js
+160
-153
未找到文件。
build/Three.js
浏览文件 @
08c8108d
此差异已折叠。
点击以展开。
build/custom/ThreeCanvas.js
浏览文件 @
08c8108d
...
...
@@ -148,18 +148,18 @@ f.z=w[o];p.normal=f}if(j)for(c=0;c<n;c++){o=A[l++]*3;f=new THREE.Vector3;f.x=w[o
b
+
2
){
f
=
a
.
skinIndices
[
b
];
k
=
a
.
skinIndices
[
b
+
1
];
d
.
skinIndices
.
push
(
new
THREE
.
Vector4
(
f
,
k
,
0
,
0
))}}
d
.
bones
=
a
.
bones
;
d
.
animation
=
a
.
animation
})();(
function
(
b
){
if
(
a
.
morphTargets
!==
void
0
){
var
c
,
f
,
k
,
l
,
h
,
n
;
c
=
0
;
for
(
f
=
a
.
morphTargets
.
length
;
c
<
f
;
c
++
){
d
.
morphTargets
[
c
]
=
{};
d
.
morphTargets
[
c
].
name
=
a
.
morphTargets
[
c
].
name
;
d
.
morphTargets
[
c
].
vertices
=
[];
h
=
d
.
morphTargets
[
c
].
vertices
;
n
=
a
.
morphTargets
[
c
].
vertices
;
k
=
0
;
for
(
l
=
n
.
length
;
k
<
l
;
k
=
k
+
3
){
var
j
=
new
THREE
.
Vector3
;
j
.
x
=
n
[
k
]
*
b
;
j
.
y
=
n
[
k
+
1
]
*
b
;
j
.
z
=
n
[
k
+
2
]
*
b
;
h
.
push
(
j
)}}}
if
(
a
.
morphColors
!==
void
0
){
c
=
0
;
for
(
f
=
a
.
morphColors
.
length
;
c
<
f
;
c
++
){
d
.
morphColors
[
c
]
=
{};
d
.
morphColors
[
c
].
name
=
a
.
morphColors
[
c
].
name
;
d
.
morphColors
[
c
].
colors
=
[];
l
=
d
.
morphColors
[
c
].
colors
;
h
=
a
.
morphColors
[
c
].
colors
;
b
=
0
;
for
(
k
=
h
.
length
;
b
<
k
;
b
=
b
+
3
){
n
=
new
THREE
.
Color
(
16755200
);
n
.
setRGB
(
h
[
b
],
h
[
b
+
1
],
h
[
b
+
2
]);
l
.
push
(
n
)}}}})(
f
);
d
.
computeCentroids
();
d
.
computeFaceNormals
();
this
.
hasNormals
(
d
)
&&
d
.
computeTangents
();
b
(
d
)};
THREE
.
GeometryLoader
=
function
(){
THREE
.
EventTarget
.
call
(
this
);
this
.
path
=
this
.
crossOrigin
=
null
};
THREE
.
GeometryLoader
.
prototype
=
{
constructor
:
THREE
.
GeometryLoader
,
load
:
function
(
a
){
var
b
=
this
,
c
=
null
;
if
(
b
.
path
===
null
){
var
d
=
a
.
split
(
"
/
"
);
d
.
pop
();
b
.
path
=
d
.
length
<
1
?
"
.
"
:
d
.
join
(
"
/
"
)}
d
=
new
XMLHttpRequest
;
d
.
addEventListener
(
"
load
"
,
function
(
d
){
d
.
target
.
responseText
?
c
=
b
.
parse
(
JSON
.
parse
(
d
.
target
.
responseText
),
f
):
b
.
dispatchEvent
({
type
:
"
error
"
,
message
:
"
Invalid file [
"
+
a
+
"
]
"
})},
false
);
d
.
addEventListener
(
"
error
"
,
function
(){
b
.
dispatchEvent
({
type
:
"
error
"
,
message
:
"
Couldn't load URL [
"
+
a
+
"
]
"
})},
false
);
d
.
open
(
"
GET
"
,
a
,
true
);
d
.
send
(
null
);
var
f
=
new
THREE
.
LoadingMonitor
;
f
.
addEventListener
(
"
load
"
,
function
(){
b
.
dispatchEvent
({
type
:
"
load
"
,
content
:
c
})});
f
.
add
(
d
)},
parse
:
function
(
a
,
b
){
var
c
=
this
,
d
=
new
THREE
.
Geometry
,
f
=
a
.
scale
!==
void
0
?
1
/
a
.
scale
:
1
;
d
.
materials
=
[];
for
(
var
e
=
0
;
e
<
a
.
materials
.
length
;
++
e
){
var
g
=
a
.
materials
[
e
],
m
=
function
(
a
){
a
=
Math
.
log
(
a
)
/
Math
.
LN2
;
return
Math
.
floor
(
a
)
==
a
},
k
=
function
(
a
){
a
=
Math
.
log
(
a
)
/
Math
.
LN2
;
return
Math
.
pow
(
2
,
Math
.
round
(
a
))},
l
=
function
(
a
,
d
,
e
,
f
,
g
,
h
){
a
[
d
]
=
new
THREE
.
Texture
;
a
[
d
].
sourceFile
=
e
;
if
(
f
){
a
[
d
].
repeat
.
set
(
f
[
0
],
f
[
1
]);
if
(
f
[
0
]
!=
1
)
a
[
d
].
wrapS
=
THREE
.
RepeatWrapping
;
if
(
f
[
1
]
!=
1
)
a
[
d
].
wrapT
=
THREE
.
RepeatWrapping
}
g
&&
a
[
d
].
offset
.
set
(
g
[
0
],
g
[
1
]);
if
(
h
){
f
=
{
repeat
:
THREE
.
RepeatWrapping
,
mirror
:
THREE
.
MirroredRepeatWrapping
};
if
(
f
[
h
[
0
]]
!==
void
0
)
a
[
d
].
wrapS
=
f
[
h
[
0
]];
if
(
f
[
h
[
1
]]
!==
void
0
)
a
[
d
].
wrapT
=
f
[
h
[
1
]]}
var
l
=
a
[
d
],
a
=
new
THREE
.
ImageLoader
;
a
.
addEventListener
(
"
load
"
,
function
(
a
){
a
=
a
.
content
;
if
(
!
m
(
a
.
width
)
||!
m
(
a
.
height
)){
var
b
=
k
(
a
.
width
),
c
=
k
(
a
.
height
);
l
.
image
=
document
.
createElement
(
"
canvas
"
);
l
.
image
.
width
=
b
;
l
.
image
.
height
=
c
;
l
.
image
.
getContext
(
"
2d
"
).
drawImage
(
a
,
0
,
0
,
b
,
c
)}
else
l
.
image
=
a
;
l
.
needsUpdate
=
true
});
a
.
crossOrigin
=
c
.
crossOrigin
;
a
.
load
(
c
.
path
+
"
/
"
+
e
);
b
&&
b
.
add
(
a
)},
h
=
function
(
a
){
return
(
a
[
0
]
*
255
<<
16
)
+
(
a
[
1
]
*
255
<<
8
)
+
a
[
2
]
*
255
},
n
=
"
MeshLambertMaterial
"
,
j
=
{
color
:
15658734
,
opacity
:
1
,
map
:
null
,
lightMap
:
null
,
normalMap
:
null
,
wireframe
:
g
.
wireframe
};
if
(
g
.
shading
){
var
o
=
g
.
shading
.
toLowerCase
();
o
===
"
phong
"
?
n
=
"
MeshPhongMaterial
"
:
o
===
"
basic
"
&&
(
n
=
"
MeshBasicMaterial
"
)}
if
(
g
.
blending
!==
void
0
&&
THREE
[
g
.
blending
]
!==
void
0
)
j
.
blending
=
THREE
[
g
.
blending
];
if
(
g
.
transparent
!==
void
0
||
g
.
opacity
<
1
)
j
.
transparent
=
g
.
transparent
;
if
(
g
.
depthTest
!==
void
0
)
j
.
depthTest
=
g
.
depthTest
;
if
(
g
.
depthWrite
!==
void
0
)
j
.
depthWrite
=
g
.
depthWrite
;
if
(
g
.
vertexColors
!==
void
0
)
if
(
g
.
vertexColors
==
"
face
"
)
j
.
vertexColors
=
THREE
.
FaceColors
;
else
if
(
g
.
vertexColors
)
j
.
vertexColors
=
THREE
.
VertexColors
;
if
(
g
.
colorDiffuse
)
j
.
color
=
h
(
g
.
colorDiffuse
);
else
if
(
g
.
DbgColor
)
j
.
color
=
g
.
DbgColor
;
if
(
g
.
colorSpecular
)
j
.
specular
=
h
(
g
.
colorSpecular
);
if
(
g
.
colorAmbient
)
j
.
ambient
=
h
(
g
.
colorAmbient
);
if
(
g
.
transparency
)
j
.
opacity
=
g
.
transparency
;
if
(
g
.
specularCoef
)
j
.
shininess
=
g
.
specularCoef
;
g
.
mapDiffuse
&&
l
(
j
,
"
map
"
,
g
.
mapDiffuse
,
g
.
mapDiffuseRepeat
,
g
.
mapDiffuseOffset
,
g
.
mapDiffuseWrap
);
g
.
mapLight
&&
l
(
j
,
"
lightMap
"
,
g
.
mapLight
,
g
.
mapLightRepeat
,
g
.
mapLightOffset
,
g
.
mapLightWrap
);
g
.
mapNormal
&&
l
(
j
,
"
normalMap
"
,
g
.
mapNormal
,
g
.
mapNormalRepeat
,
g
.
mapNormalOffset
,
g
.
mapNormalWrap
);
g
.
mapSpecular
&&
l
(
j
,
"
specularMap
"
,
g
.
mapSpecular
,
g
.
mapSpecularRepeat
,
g
.
mapSpecularOffset
,
g
.
mapSpecularWrap
);
if
(
g
.
mapNormal
){
l
=
THREE
.
ShaderUtils
.
lib
.
normal
;
h
=
THREE
.
UniformsUtils
.
clone
(
l
.
uniforms
)
;
h
.
tNormal
.
texture
=
j
.
normalMap
;
if
(
g
.
mapNormalFactor
)
h
.
uNormalScale
.
value
=
g
.
mapNormalFactor
;
if
(
j
.
map
){
h
.
tDiffuse
.
texture
=
j
.
map
;
h
.
enableDiffuse
.
value
=
true
}
if
(
j
.
specularMap
){
h
.
tSpecular
.
texture
=
j
.
specularMap
;
h
.
enableSpecular
.
value
=
true
}
if
(
j
.
lightMap
){
h
.
tAO
.
texture
=
j
.
lightMap
;
h
.
enableAO
.
value
=
true
}
h
.
uDiffuseColor
.
value
.
setHex
(
j
.
color
);
h
.
uSpecularColor
.
value
.
setHex
(
j
.
specular
);
h
.
uAmbientColor
.
value
.
setHex
(
j
.
ambient
);
h
.
uShininess
.
value
=
j
.
shininess
;
if
(
j
.
opacity
!==
void
0
)
h
.
uOpacity
.
value
=
j
.
opacity
;
j
=
new
THREE
.
ShaderMaterial
({
fragmentShader
:
l
.
fragmentShader
,
vertexShader
:
l
.
vertexShader
,
uniforms
:
h
,
lights
:
true
,
fog
:
true
})}
else
j
=
new
THREE
[
n
](
j
);
if
(
g
.
DbgName
!==
void
0
)
j
.
name
=
g
.
DbgName
;
d
.
materials
[
e
]
=
j
}
for
(
var
g
=
a
.
faces
,
q
=
a
.
vertices
,
j
=
a
.
normals
,
l
=
a
.
colors
,
e
=
h
=
0
;
e
<
a
.
uvs
.
length
;
e
++
)
a
.
uvs
[
e
].
length
&&
h
++
;
for
(
e
=
0
;
e
<
h
;
e
++
){
d
.
faceUvs
[
e
]
=
[];
d
.
faceVertexUvs
[
e
]
=
[]}
n
=
0
;
for
(
o
=
q
.
length
;
n
<
o
;){
var
i
=
new
THREE
.
Vector3
;
i
.
x
=
q
[
n
++
]
*
f
;
i
.
y
=
q
[
n
++
]
*
f
;
i
.
z
=
q
[
n
++
]
*
f
;
d
.
vertices
.
push
(
i
)}
n
=
0
;
for
(
o
=
g
.
length
;
n
<
o
;){
var
p
=
g
[
n
++
],
r
=
p
&
2
,
e
=
p
&
4
,
s
=
p
&
8
,
v
=
p
&
16
,
q
=
p
&
32
,
A
=
p
&
64
,
i
=
p
&
128
;
if
(
p
&
1
){
p
=
new
THREE
.
Face4
;
p
.
a
=
g
[
n
++
];
p
.
b
=
g
[
n
++
];
p
.
c
=
g
[
n
++
];
p
.
d
=
g
[
n
++
];
var
w
=
4
}
else
{
p
=
new
THREE
.
Face3
;
p
.
a
=
g
[
n
++
];
p
.
b
=
g
[
n
++
];
p
.
c
=
g
[
n
++
];
w
=
3
}
if
(
r
){
r
=
g
[
n
++
];
p
.
materialIndex
=
r
}
var
B
=
d
.
faces
.
length
;
if
(
e
)
for
(
e
=
0
;
e
<
h
;
e
++
){
var
x
=
a
.
uvs
[
e
],
r
=
g
[
n
++
],
F
=
x
[
r
*
2
],
r
=
x
[
r
*
2
+
1
];
d
.
faceUvs
[
e
][
B
]
=
new
THREE
.
UV
(
F
,
r
)}
if
(
s
)
for
(
e
=
0
;
e
<
h
;
e
++
){
for
(
var
x
=
a
.
uvs
[
e
],
s
=
[],
u
=
0
;
u
<
w
;
u
++
){
r
=
g
[
n
++
];
F
=
x
[
r
*
2
];
r
=
x
[
r
*
2
+
1
];
s
[
u
]
=
new
THREE
.
UV
(
F
,
r
)}
d
.
faceVertexUvs
[
e
][
B
]
=
s
}
if
(
v
){
v
=
g
[
n
++
]
*
3
;
r
=
new
THREE
.
Vector3
;
r
.
x
=
j
[
v
++
];
r
.
y
=
j
[
v
++
];
r
.
z
=
j
[
v
];
p
.
normal
=
r
}
if
(
q
)
for
(
e
=
0
;
e
<
w
;
e
++
){
v
=
g
[
n
++
]
*
3
;
r
=
new
THREE
.
Vector3
;
r
.
x
=
j
[
v
++
];
r
.
y
=
j
[
v
++
];
r
.
z
=
j
[
v
];
p
.
vertexNormals
.
push
(
r
)}
if
(
A
){
q
=
g
[
n
++
];
p
.
color
=
new
THREE
.
Color
(
l
[
q
])}
if
(
i
)
for
(
e
=
0
;
e
<
w
;
e
++
){
q
=
g
[
n
++
];
p
.
vertexColors
.
push
(
new
THREE
.
Color
(
l
[
q
]))}
d
.
faces
.
push
(
p
)}
if
(
a
.
skinWeights
){
e
=
0
;
for
(
g
=
a
.
skinWeights
.
length
;
e
<
g
;
e
=
e
+
2
)
d
.
skinWeights
.
push
(
new
THREE
.
Vector4
(
a
.
skinWeights
[
e
],
a
.
skinWeights
[
e
+
1
],
0
,
0
))}
if
(
a
.
skinIndices
){
e
=
0
;
for
(
g
=
a
.
skinIndices
.
length
;
e
<
g
;
e
=
e
+
2
){
j
=
0
;
d
.
skinIndices
.
push
(
new
THREE
.
Vector4
(
a
.
skinIndices
[
e
],
a
.
skinIndices
[
e
+
1
],
j
,
0
))}}
d
.
bones
=
a
.
bones
;
d
.
animation
=
a
.
animation
;
if
(
a
.
morphTargets
!==
void
0
){
e
=
0
;
for
(
g
=
a
.
morphTargets
.
length
;
e
<
g
;
e
++
){
d
.
morphTargets
[
e
]
=
{};
d
.
morphTargets
[
e
].
name
=
a
.
morphTargets
[
e
].
name
;
d
.
morphTargets
[
e
].
vertices
=
[];
j
=
d
.
morphTargets
[
e
].
vertices
;
l
=
a
.
morphTargets
[
e
].
vertices
;
r
=
0
;
for
(
h
=
l
.
length
;
r
<
h
;
r
=
r
+
3
){
i
=
new
THREE
.
Vector3
;
i
.
x
=
l
[
r
]
*
f
;
i
.
y
=
l
[
r
+
1
]
*
f
;
i
.
z
=
l
[
r
+
2
]
*
f
;
j
.
push
(
i
)}}}
if
(
a
.
morphColors
!==
void
0
){
e
=
0
;
for
(
g
=
a
.
morphColors
.
length
;
e
<
g
;
e
++
){
d
.
morphColors
[
e
]
=
{};
d
.
morphColors
[
e
].
name
=
a
.
morphColors
[
e
].
name
;
d
.
morphColors
[
e
].
colors
=
[];
f
=
d
.
morphColors
[
e
].
colors
;
l
=
a
.
morphColors
[
e
].
colors
;
j
=
0
;
for
(
h
=
l
.
length
;
j
<
h
;
j
=
j
+
3
){
n
=
new
THREE
.
Color
(
16755200
);
n
.
setRGB
(
l
[
j
],
l
[
j
+
1
],
l
[
j
+
2
]);
f
.
push
(
n
)}}}
d
.
computeCentroids
();
d
.
computeFaceNormals
();
return
d
}};
THREE
.
SceneLoader
=
function
(){
this
.
onLoadStart
=
function
(){};
this
.
onLoadProgress
=
function
(){};
this
.
onLoadComplete
=
function
(){};
this
.
callbackSync
=
function
(){};
this
.
callbackProgress
=
function
(){}};
THREE
.
SceneLoader
.
prototype
.
constructor
=
THREE
.
SceneLoader
;
THREE
.
SceneLoader
.
prototype
.
load
=
function
(
a
,
b
){
var
c
=
this
,
d
=
new
XMLHttpRequest
;
d
.
onreadystatechange
=
function
(){
if
(
d
.
readyState
==
4
)
if
(
d
.
status
==
200
||
d
.
status
==
0
){
var
f
=
JSON
.
parse
(
d
.
responseText
);
c
.
createScene
(
f
,
b
,
a
)}
else
console
.
error
(
"
THREE.SceneLoader: Couldn't load [
"
+
a
+
"
] [
"
+
d
.
status
+
"
]
"
)};
d
.
open
(
"
GET
"
,
a
,
true
);
d
.
overrideMimeType
&&
d
.
overrideMimeType
(
"
text/plain; charset=x-user-defined
"
);
d
.
setRequestHeader
(
"
Content-Type
"
,
"
text/plain
"
);
d
.
send
(
null
)};
a
,
true
);
d
.
send
(
null
);
var
f
=
new
THREE
.
LoadingMonitor
;
f
.
addEventListener
(
"
load
"
,
function
(){
b
.
dispatchEvent
({
type
:
"
load
"
,
content
:
c
})});
f
.
add
(
d
)},
parse
:
function
(
a
,
b
){
var
c
=
this
,
d
=
new
THREE
.
Geometry
,
f
=
a
.
scale
!==
void
0
?
1
/
a
.
scale
:
1
;
if
(
a
.
materials
){
d
.
materials
=
[];
for
(
var
e
=
0
;
e
<
a
.
materials
.
length
;
++
e
){
var
g
=
a
.
materials
[
e
],
m
=
function
(
a
){
a
=
Math
.
log
(
a
)
/
Math
.
LN2
;
return
Math
.
floor
(
a
)
==
a
},
k
=
function
(
a
){
a
=
Math
.
log
(
a
)
/
Math
.
LN2
;
return
Math
.
pow
(
2
,
Math
.
round
(
a
))},
l
=
function
(
a
,
d
,
e
,
f
,
g
,
h
){
a
[
d
]
=
new
THREE
.
Texture
;
a
[
d
].
sourceFile
=
e
;
if
(
f
){
a
[
d
].
repeat
.
set
(
f
[
0
],
f
[
1
]);
if
(
f
[
0
]
!=
1
)
a
[
d
].
wrapS
=
THREE
.
RepeatWrapping
;
if
(
f
[
1
]
!=
1
)
a
[
d
].
wrapT
=
THREE
.
RepeatWrapping
}
g
&&
a
[
d
].
offset
.
set
(
g
[
0
],
g
[
1
]);
if
(
h
){
f
=
{
repeat
:
THREE
.
RepeatWrapping
,
mirror
:
THREE
.
MirroredRepeatWrapping
};
if
(
f
[
h
[
0
]]
!==
void
0
)
a
[
d
].
wrapS
=
f
[
h
[
0
]];
if
(
f
[
h
[
1
]]
!==
void
0
)
a
[
d
].
wrapT
=
f
[
h
[
1
]]}
var
l
=
a
[
d
],
a
=
new
THREE
.
ImageLoader
;
a
.
addEventListener
(
"
load
"
,
function
(
a
){
a
=
a
.
content
;
if
(
!
m
(
a
.
width
)
||!
m
(
a
.
height
)){
var
b
=
k
(
a
.
width
),
c
=
k
(
a
.
height
);
l
.
image
=
document
.
createElement
(
"
canvas
"
);
l
.
image
.
width
=
b
;
l
.
image
.
height
=
c
;
l
.
image
.
getContext
(
"
2d
"
).
drawImage
(
a
,
0
,
0
,
b
,
c
)}
else
l
.
image
=
a
;
l
.
needsUpdate
=
true
});
a
.
crossOrigin
=
c
.
crossOrigin
;
a
.
load
(
c
.
path
+
"
/
"
+
e
);
b
&&
b
.
add
(
a
)},
h
=
function
(
a
){
return
(
a
[
0
]
*
255
<<
16
)
+
(
a
[
1
]
*
255
<<
8
)
+
a
[
2
]
*
255
},
n
=
"
MeshLambertMaterial
"
,
j
=
{
color
:
15658734
,
opacity
:
1
,
map
:
null
,
lightMap
:
null
,
normalMap
:
null
,
wireframe
:
g
.
wireframe
};
if
(
g
.
shading
){
var
o
=
g
.
shading
.
toLowerCase
();
o
===
"
phong
"
?
n
=
"
MeshPhongMaterial
"
:
o
===
"
basic
"
&&
(
n
=
"
MeshBasicMaterial
"
)}
if
(
g
.
blending
!==
void
0
&&
THREE
[
g
.
blending
]
!==
void
0
)
j
.
blending
=
THREE
[
g
.
blending
];
if
(
g
.
transparent
!==
void
0
||
g
.
opacity
<
1
)
j
.
transparent
=
g
.
transparent
;
if
(
g
.
depthTest
!==
void
0
)
j
.
depthTest
=
g
.
depthTest
;
if
(
g
.
depthWrite
!==
void
0
)
j
.
depthWrite
=
g
.
depthWrite
;
if
(
g
.
vertexColors
!==
void
0
)
if
(
g
.
vertexColors
==
"
face
"
)
j
.
vertexColors
=
THREE
.
FaceColors
;
else
if
(
g
.
vertexColors
)
j
.
vertexColors
=
THREE
.
VertexColors
;
if
(
g
.
colorDiffuse
)
j
.
color
=
h
(
g
.
colorDiffuse
);
else
if
(
g
.
DbgColor
)
j
.
color
=
g
.
DbgColor
;
if
(
g
.
colorSpecular
)
j
.
specular
=
h
(
g
.
colorSpecular
);
if
(
g
.
colorAmbient
)
j
.
ambient
=
h
(
g
.
colorAmbient
)
;
if
(
g
.
transparency
)
j
.
opacity
=
g
.
transparency
;
if
(
g
.
specularCoef
)
j
.
shininess
=
g
.
specularCoef
;
g
.
mapDiffuse
&&
l
(
j
,
"
map
"
,
g
.
mapDiffuse
,
g
.
mapDiffuseRepeat
,
g
.
mapDiffuseOffset
,
g
.
mapDiffuseWrap
);
g
.
mapLight
&&
l
(
j
,
"
lightMap
"
,
g
.
mapLight
,
g
.
mapLightRepeat
,
g
.
mapLightOffset
,
g
.
mapLightWrap
);
g
.
mapNormal
&&
l
(
j
,
"
normalMap
"
,
g
.
mapNormal
,
g
.
mapNormalRepeat
,
g
.
mapNormalOffset
,
g
.
mapNormalWrap
);
g
.
mapSpecular
&&
l
(
j
,
"
specularMap
"
,
g
.
mapSpecular
,
g
.
mapSpecularRepeat
,
g
.
mapSpecularOffset
,
g
.
mapSpecularWrap
);
if
(
g
.
mapNormal
){
l
=
THREE
.
ShaderUtils
.
lib
.
normal
;
h
=
THREE
.
UniformsUtils
.
clone
(
l
.
uniforms
);
h
.
tNormal
.
texture
=
j
.
normalMap
;
if
(
g
.
mapNormalFactor
)
h
.
uNormalScale
.
value
=
g
.
mapNormalFactor
;
if
(
j
.
map
){
h
.
tDiffuse
.
texture
=
j
.
map
;
h
.
enableDiffuse
.
value
=
true
}
if
(
j
.
specularMap
){
h
.
tSpecular
.
texture
=
j
.
specularMap
;
h
.
enableSpecular
.
value
=
true
}
if
(
j
.
lightMap
){
h
.
tAO
.
texture
=
j
.
lightMap
;
h
.
enableAO
.
value
=
true
}
h
.
uDiffuseColor
.
value
.
setHex
(
j
.
color
);
h
.
uSpecularColor
.
value
.
setHex
(
j
.
specular
);
h
.
uAmbientColor
.
value
.
setHex
(
j
.
ambient
);
h
.
uShininess
.
value
=
j
.
shininess
;
if
(
j
.
opacity
!==
void
0
)
h
.
uOpacity
.
value
=
j
.
opacity
;
j
=
new
THREE
.
ShaderMaterial
({
fragmentShader
:
l
.
fragmentShader
,
vertexShader
:
l
.
vertexShader
,
uniforms
:
h
,
lights
:
true
,
fog
:
true
})}
else
j
=
new
THREE
[
n
](
j
);
if
(
g
.
DbgName
!==
void
0
)
j
.
name
=
g
.
DbgName
;
d
.
materials
[
e
]
=
j
}}
var
g
=
a
.
faces
,
q
=
a
.
vertices
,
j
=
a
.
normals
,
l
=
a
.
colors
,
h
=
0
;
if
(
a
.
uvs
)
for
(
e
=
0
;
e
<
a
.
uvs
.
length
;
e
++
)
a
.
uvs
[
e
].
length
&&
h
++
;
for
(
e
=
0
;
e
<
h
;
e
++
){
d
.
faceUvs
[
e
]
=
[];
d
.
faceVertexUvs
[
e
]
=
[]}
n
=
0
;
for
(
o
=
q
.
length
;
n
<
o
;){
var
i
=
new
THREE
.
Vector3
;
i
.
x
=
q
[
n
++
]
*
f
;
i
.
y
=
q
[
n
++
]
*
f
;
i
.
z
=
q
[
n
++
]
*
f
;
d
.
vertices
.
push
(
i
)}
n
=
0
;
for
(
o
=
g
.
length
;
n
<
o
;){
var
p
=
g
[
n
++
],
r
=
p
&
2
,
e
=
p
&
4
,
s
=
p
&
8
,
v
=
p
&
16
,
q
=
p
&
32
,
A
=
p
&
64
,
i
=
p
&
128
;
if
(
p
&
1
){
p
=
new
THREE
.
Face4
;
p
.
a
=
g
[
n
++
];
p
.
b
=
g
[
n
++
];
p
.
c
=
g
[
n
++
];
p
.
d
=
g
[
n
++
];
var
w
=
4
}
else
{
p
=
new
THREE
.
Face3
;
p
.
a
=
g
[
n
++
];
p
.
b
=
g
[
n
++
];
p
.
c
=
g
[
n
++
];
w
=
3
}
if
(
r
){
r
=
g
[
n
++
];
p
.
materialIndex
=
r
}
var
B
=
d
.
faces
.
length
;
if
(
e
)
for
(
e
=
0
;
e
<
h
;
e
++
){
var
x
=
a
.
uvs
[
e
],
r
=
g
[
n
++
],
F
=
x
[
r
*
2
],
r
=
x
[
r
*
2
+
1
];
d
.
faceUvs
[
e
][
B
]
=
new
THREE
.
UV
(
F
,
r
)}
if
(
s
)
for
(
e
=
0
;
e
<
h
;
e
++
){
for
(
var
x
=
a
.
uvs
[
e
],
s
=
[],
u
=
0
;
u
<
w
;
u
++
){
r
=
g
[
n
++
];
F
=
x
[
r
*
2
];
r
=
x
[
r
*
2
+
1
];
s
[
u
]
=
new
THREE
.
UV
(
F
,
r
)}
d
.
faceVertexUvs
[
e
][
B
]
=
s
}
if
(
v
){
v
=
g
[
n
++
]
*
3
;
r
=
new
THREE
.
Vector3
;
r
.
x
=
j
[
v
++
];
r
.
y
=
j
[
v
++
];
r
.
z
=
j
[
v
];
p
.
normal
=
r
}
if
(
q
)
for
(
e
=
0
;
e
<
w
;
e
++
){
v
=
g
[
n
++
]
*
3
;
r
=
new
THREE
.
Vector3
;
r
.
x
=
j
[
v
++
];
r
.
y
=
j
[
v
++
];
r
.
z
=
j
[
v
];
p
.
vertexNormals
.
push
(
r
)}
if
(
A
){
q
=
g
[
n
++
];
p
.
color
=
new
THREE
.
Color
(
l
[
q
])}
if
(
i
)
for
(
e
=
0
;
e
<
w
;
e
++
){
q
=
g
[
n
++
];
p
.
vertexColors
.
push
(
new
THREE
.
Color
(
l
[
q
]))}
d
.
faces
.
push
(
p
)}
if
(
a
.
skinWeights
){
e
=
0
;
for
(
g
=
a
.
skinWeights
.
length
;
e
<
g
;
e
=
e
+
2
)
d
.
skinWeights
.
push
(
new
THREE
.
Vector4
(
a
.
skinWeights
[
e
],
a
.
skinWeights
[
e
+
1
],
0
,
0
))}
if
(
a
.
skinIndices
){
e
=
0
;
for
(
g
=
a
.
skinIndices
.
length
;
e
<
g
;
e
=
e
+
2
){
j
=
0
;
d
.
skinIndices
.
push
(
new
THREE
.
Vector4
(
a
.
skinIndices
[
e
],
a
.
skinIndices
[
e
+
1
],
j
,
0
))}}
d
.
bones
=
a
.
bones
;
d
.
animation
=
a
.
animation
;
if
(
a
.
morphTargets
){
e
=
0
;
for
(
g
=
a
.
morphTargets
.
length
;
e
<
g
;
e
++
){
d
.
morphTargets
[
e
]
=
{};
d
.
morphTargets
[
e
].
name
=
a
.
morphTargets
[
e
].
name
;
d
.
morphTargets
[
e
].
vertices
=
[];
j
=
d
.
morphTargets
[
e
].
vertices
;
l
=
a
.
morphTargets
[
e
].
vertices
;
r
=
0
;
for
(
h
=
l
.
length
;
r
<
h
;
r
=
r
+
3
){
i
=
new
THREE
.
Vector3
;
i
.
x
=
l
[
r
]
*
f
;
i
.
y
=
l
[
r
+
1
]
*
f
;
i
.
z
=
l
[
r
+
2
]
*
f
;
j
.
push
(
i
)}}}
if
(
a
.
morphColors
){
e
=
0
;
for
(
g
=
a
.
morphColors
.
length
;
e
<
g
;
e
++
){
d
.
morphColors
[
e
]
=
{};
d
.
morphColors
[
e
].
name
=
a
.
morphColors
[
e
].
name
;
d
.
morphColors
[
e
].
colors
=
[];
f
=
d
.
morphColors
[
e
].
colors
;
l
=
a
.
morphColors
[
e
].
colors
;
j
=
0
;
for
(
h
=
l
.
length
;
j
<
h
;
j
=
j
+
3
){
n
=
new
THREE
.
Color
(
16755200
);
n
.
setRGB
(
l
[
j
],
l
[
j
+
1
],
l
[
j
+
2
]);
f
.
push
(
n
)}}}
d
.
computeCentroids
();
d
.
computeFaceNormals
();
return
d
}};
THREE
.
SceneLoader
=
function
(){
this
.
onLoadStart
=
function
(){};
this
.
onLoadProgress
=
function
(){};
this
.
onLoadComplete
=
function
(){};
this
.
callbackSync
=
function
(){};
this
.
callbackProgress
=
function
(){}}
;
THREE
.
SceneLoader
.
prototype
.
constructor
=
THREE
.
SceneLoader
;
THREE
.
SceneLoader
.
prototype
.
load
=
function
(
a
,
b
){
var
c
=
this
,
d
=
new
XMLHttpRequest
;
d
.
onreadystatechange
=
function
(){
if
(
d
.
readyState
==
4
)
if
(
d
.
status
==
200
||
d
.
status
==
0
){
var
f
=
JSON
.
parse
(
d
.
responseText
);
c
.
createScene
(
f
,
b
,
a
)}
else
console
.
error
(
"
THREE.SceneLoader: Couldn't load [
"
+
a
+
"
] [
"
+
d
.
status
+
"
]
"
)};
d
.
open
(
"
GET
"
,
a
,
true
);
d
.
overrideMimeType
&&
d
.
overrideMimeType
(
"
text/plain; charset=x-user-defined
"
);
d
.
setRequestHeader
(
"
Content-Type
"
,
"
text/plain
"
);
d
.
send
(
null
)};
THREE
.
SceneLoader
.
prototype
.
createScene
=
function
(
a
,
b
,
c
){
function
d
(
a
,
b
){
return
b
==
"
relativeToHTML
"
?
a
:
l
+
"
/
"
+
a
}
function
f
(){
var
a
;
for
(
j
in
t
.
objects
)
if
(
!
y
.
objects
[
j
]){
r
=
t
.
objects
[
j
];
if
(
r
.
geometry
!==
void
0
){
if
(
D
=
y
.
geometries
[
r
.
geometry
]){
a
=
false
;
H
=
y
.
materials
[
r
.
materials
[
0
]];(
a
=
H
instanceof
THREE
.
ShaderMaterial
)
&&
D
.
computeTangents
();
w
=
r
.
position
;
B
=
r
.
rotation
;
x
=
r
.
quaternion
;
F
=
r
.
scale
;
s
=
r
.
matrix
;
x
=
0
;
r
.
materials
.
length
==
0
&&
(
H
=
new
THREE
.
MeshFaceMaterial
);
r
.
materials
.
length
>
1
&&
(
H
=
new
THREE
.
MeshFaceMaterial
);
a
=
new
THREE
.
Mesh
(
D
,
H
);
a
.
name
=
j
;
if
(
s
){
a
.
matrixAutoUpdate
=
false
;
a
.
matrix
.
set
(
s
[
0
],
s
[
1
],
s
[
2
],
s
[
3
],
s
[
4
],
s
[
5
],
s
[
6
],
s
[
7
],
s
[
8
],
s
[
9
],
s
[
10
],
s
[
11
],
s
[
12
],
s
[
13
],
s
[
14
],
s
[
15
])}
else
{
a
.
position
.
set
(
w
[
0
],
w
[
1
],
w
[
2
]);
if
(
x
){
a
.
quaternion
.
set
(
x
[
0
],
x
[
1
],
x
[
2
],
x
[
3
]);
a
.
useQuaternion
=
true
}
else
a
.
rotation
.
set
(
B
[
0
],
B
[
1
],
B
[
2
]);
a
.
scale
.
set
(
F
[
0
],
F
[
1
],
F
[
2
])}
a
.
visible
=
r
.
visible
;
a
.
doubleSided
=
r
.
doubleSided
;
a
.
castShadow
=
r
.
castShadow
;
a
.
receiveShadow
=
r
.
receiveShadow
;
y
.
scene
.
add
(
a
);
y
.
objects
[
j
]
=
a
}}
else
{
w
=
r
.
position
;
B
=
r
.
rotation
;
x
=
r
.
quaternion
;
F
=
r
.
scale
;
x
=
0
;
a
=
new
THREE
.
Object3D
;
a
.
name
=
j
;
a
.
position
.
set
(
w
[
0
],
w
[
1
],
w
[
2
]);
if
(
x
){
a
.
quaternion
.
set
(
x
[
0
],
x
[
1
],
x
[
2
],
x
[
3
]);
a
.
useQuaternion
=
true
}
else
a
.
rotation
.
set
(
B
[
0
],
B
[
1
],
B
[
2
]);
a
.
scale
.
set
(
F
[
0
],
F
[
1
],
F
[
2
]);
a
.
visible
=
r
.
visible
!==
void
0
?
r
.
visible
:
false
;
y
.
scene
.
add
(
a
);
y
.
objects
[
j
]
=
a
;
y
.
empties
[
j
]
=
a
}}}
function
e
(
a
){
return
function
(
b
){
y
.
geometries
[
a
]
=
b
;
f
();
G
=
G
-
1
;
k
.
onLoadComplete
();
m
()}}
function
g
(
a
){
return
function
(
b
){
y
.
geometries
[
a
]
=
b
}}
function
m
(){
k
.
callbackProgress
({
totalModels
:
Q
,
totalTextures
:
O
,
loadedModels
:
Q
-
...
...
build/custom/ThreeExtras.js
浏览文件 @
08c8108d
...
...
@@ -134,12 +134,12 @@ THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;t
THREE
.
FirstPersonControls
=
function
(
b
,
a
){
function
c
(
a
,
b
){
return
function
(){
b
.
apply
(
a
,
arguments
)}}
this
.
object
=
b
;
this
.
target
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
this
.
domElement
=
a
!==
void
0
?
a
:
document
;
this
.
movementSpeed
=
1
;
this
.
lookSpeed
=
0.005
;
this
.
noFly
=
false
;
this
.
lookVertical
=
true
;
this
.
autoForward
=
false
;
this
.
activeLook
=
true
;
this
.
heightSpeed
=
false
;
this
.
heightCoef
=
1
;
this
.
heightMin
=
0
;
this
.
constrainVertical
=
false
;
this
.
verticalMin
=
0
;
this
.
verticalMax
=
Math
.
PI
;
this
.
theta
=
this
.
phi
=
this
.
lon
=
this
.
lat
=
this
.
mouseY
=
this
.
mouseX
=
this
.
autoSpeedFactor
=
0
;
this
.
mouseDragOn
=
this
.
freeze
=
this
.
moveRight
=
this
.
moveLeft
=
this
.
moveBackward
=
this
.
moveForward
=
false
;
if
(
this
.
domElement
===
document
){
this
.
viewHalfX
=
window
.
innerWidth
/
2
;
this
.
viewHalfY
=
window
.
innerHeight
/
2
}
else
{
this
.
viewHalfX
=
this
.
domElement
.
offsetWidth
/
2
;
this
.
viewHalfY
=
this
.
domElement
.
offsetHeight
/
2
;
this
.
domElement
.
setAttribute
(
"
tabindex
"
,
-
1
)}
this
.
onMouseDown
=
function
(
a
){
this
.
domElement
!==
document
&&
this
.
domElement
.
focus
();
a
.
preventDefault
();
a
.
stopPropagation
();
if
(
this
.
activeLook
)
switch
(
a
.
button
){
case
0
:
this
.
moveForward
=
true
;
break
;
case
2
:
this
.
moveBackward
=
true
}
this
.
mouseDragOn
=
true
};
this
.
onMouseUp
=
function
(
a
){
a
.
preventDefault
();
a
.
stopPropagation
();
if
(
this
.
activeLook
)
switch
(
a
.
button
){
case
0
:
this
.
moveForward
=
false
;
break
;
case
2
:
this
.
moveBackward
=
false
}
this
.
mouseDragOn
=
false
};
this
.
onMouseMove
=
function
(
a
){
if
(
this
.
domElement
===
document
){
this
.
mouseX
=
a
.
pageX
-
this
.
viewHalfX
;
this
.
mouseY
=
a
.
pageY
-
this
.
viewHalfY
}
else
{
this
.
mouseX
=
a
.
pageX
-
this
.
domElement
.
offsetLeft
-
this
.
viewHalfX
;
this
.
mouseY
=
a
.
pageY
-
this
.
domElement
.
offsetTop
-
this
.
viewHalfY
}};
this
.
onKeyDown
=
function
(
a
){
switch
(
a
.
keyCode
){
case
38
:
case
87
:
this
.
moveForward
=
true
;
break
;
case
37
:
case
65
:
this
.
moveLeft
=
true
;
break
;
case
40
:
case
83
:
this
.
moveBackward
=
true
;
break
;
case
39
:
case
68
:
this
.
moveRight
=
true
;
break
;
case
82
:
this
.
moveUp
=
true
;
break
;
case
70
:
this
.
moveDown
=
true
;
break
;
case
81
:
this
.
freeze
=!
this
.
freeze
}};
this
.
onKeyUp
=
function
(
a
){
switch
(
a
.
keyCode
){
case
38
:
case
87
:
this
.
moveForward
=
false
;
break
;
case
37
:
case
65
:
this
.
moveLeft
=
false
;
break
;
case
40
:
case
83
:
this
.
moveBackward
=
false
;
break
;
case
39
:
case
68
:
this
.
moveRight
=
false
;
break
;
case
82
:
this
.
moveUp
=
false
;
break
;
case
70
:
this
.
moveDown
=
false
}};
this
.
update
=
function
(
a
){
var
b
=
0
;
if
(
!
this
.
freeze
){
if
(
this
.
heightSpeed
){
b
=
THREE
.
Math
.
clamp
(
this
.
object
.
position
.
y
,
this
.
heightMin
,
this
.
heightMax
)
-
this
.
heightMin
;
this
.
autoSpeedFactor
=
a
*
b
*
this
.
heightCoef
}
else
this
.
autoSpeedFactor
=
0
;
b
=
a
*
this
.
movementSpeed
;(
this
.
moveForward
||
this
.
autoForward
&&!
this
.
moveBackward
)
&&
this
.
object
.
translateZ
(
-
(
b
+
this
.
autoSpeedFactor
));
this
.
moveBackward
&&
this
.
object
.
translateZ
(
b
);
this
.
moveLeft
&&
this
.
object
.
translateX
(
-
b
);
this
.
move
Right
&&
this
.
object
.
translateX
(
b
);
this
.
moveUp
&&
this
.
object
.
translateY
(
b
);
this
.
moveDown
&&
this
.
object
.
translateY
(
-
b
);
a
=
a
*
this
.
lookSpeed
;
this
.
activeLook
||
(
a
=
0
);
this
.
lon
=
this
.
lon
+
this
.
mouseX
*
a
;
if
(
this
.
lookVertical
)
this
.
lat
=
this
.
lat
-
this
.
mouseY
*
a
;
this
.
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
this
.
lat
));
this
.
phi
=
(
90
-
this
.
lat
)
*
Math
.
PI
/
180
;
this
.
theta
=
this
.
lon
*
Math
.
PI
/
180
;
var
b
=
this
.
target
,
c
=
this
.
object
.
position
;
b
.
x
=
c
.
x
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
cos
(
this
.
theta
);
b
.
y
=
c
.
y
+
100
*
Math
.
cos
(
this
.
phi
);
b
.
z
=
c
.
z
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
sin
(
this
.
theta
);
b
=
1
;
this
.
constrainVertical
&&
(
b
=
Math
.
PI
/
(
this
.
verticalMax
-
this
.
verticalMin
));
this
.
lon
=
this
.
lon
+
this
.
mouseX
*
a
;
if
(
this
.
lookVertical
)
this
.
lat
=
this
.
lat
-
this
.
mouseY
*
a
*
b
;
this
.
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
this
.
lat
));
this
.
phi
=
(
90
-
this
.
lat
)
*
Math
.
PI
/
180
;
this
.
theta
=
this
.
lon
*
Math
.
PI
/
180
;
if
(
this
.
constrainVertical
)
this
.
phi
=
THREE
.
Math
.
mapLinear
(
this
.
phi
,
0
,
Math
.
PI
,
this
.
verticalMin
,
this
.
verticalMax
);
b
=
this
.
target
;
c
=
this
.
object
.
position
;
b
.
x
=
c
.
x
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
cos
(
this
.
theta
);
b
.
y
=
c
.
y
+
100
*
Math
.
cos
(
this
.
phi
);
b
.
z
=
c
.
z
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
sin
(
this
.
theta
);
this
.
object
.
lookAt
(
b
)}};
this
.
domElement
.
addEventListener
(
"
contextmenu
"
,
function
(
a
){
a
.
preventDefault
()},
false
);
this
.
domElement
.
addEventListener
(
"
mousemove
"
,
c
(
this
,
this
.
onMouseMove
),
false
);
this
.
domElement
.
addEventListener
(
"
mousedown
"
,
c
(
this
,
this
.
onMouseDown
),
false
);
this
.
domElement
.
addEventListener
(
"
mouseup
"
,
c
(
this
,
this
.
onMouseUp
),
false
);
this
.
domElement
.
addEventListener
(
"
keydown
"
,
c
(
this
,
this
.
onKeyDown
),
false
);
this
.
domElement
.
addEventListener
(
"
keyup
"
,
c
(
this
,
this
.
onKeyUp
),
false
)};
this
.
onKeyDown
=
function
(
a
){
a
.
preventDefault
();
switch
(
a
.
keyCode
){
case
38
:
case
87
:
this
.
moveForward
=
true
;
break
;
case
37
:
case
65
:
this
.
moveLeft
=
true
;
break
;
case
40
:
case
83
:
this
.
moveBackward
=
true
;
break
;
case
39
:
case
68
:
this
.
moveRight
=
true
;
break
;
case
82
:
this
.
moveUp
=
true
;
break
;
case
70
:
this
.
moveDown
=
true
;
break
;
case
81
:
this
.
freeze
=!
this
.
freeze
}};
this
.
onKeyUp
=
function
(
a
){
switch
(
a
.
keyCode
){
case
38
:
case
87
:
this
.
moveForward
=
false
;
break
;
case
37
:
case
65
:
this
.
moveLeft
=
false
;
break
;
case
40
:
case
83
:
this
.
moveBackward
=
false
;
break
;
case
39
:
case
68
:
this
.
moveRight
=
false
;
break
;
case
82
:
this
.
moveUp
=
false
;
break
;
case
70
:
this
.
moveDown
=
false
}};
this
.
update
=
function
(
a
){
var
b
=
0
;
if
(
!
this
.
freeze
){
if
(
this
.
heightSpeed
){
b
=
THREE
.
Math
.
clamp
(
this
.
object
.
position
.
y
,
this
.
heightMin
,
this
.
heightMax
)
-
this
.
heightMin
;
this
.
autoSpeedFactor
=
a
*
b
*
this
.
heightCoef
}
else
this
.
autoSpeedFactor
=
0
;
b
=
a
*
this
.
movementSpeed
;(
this
.
moveForward
||
this
.
autoForward
&&!
this
.
moveBackward
)
&&
this
.
object
.
translateZ
(
-
(
b
+
this
.
autoSpeedFactor
));
this
.
moveBackward
&&
this
.
object
.
translateZ
(
b
);
this
.
move
Left
&&
this
.
object
.
translateX
(
-
b
);
this
.
moveRight
&&
this
.
object
.
translateX
(
b
);
this
.
moveUp
&&
this
.
object
.
translateY
(
b
);
this
.
moveDown
&&
this
.
object
.
translateY
(
-
b
);
a
=
a
*
this
.
lookSpeed
;
this
.
activeLook
||
(
a
=
0
);
this
.
lon
=
this
.
lon
+
this
.
mouseX
*
a
;
if
(
this
.
lookVertical
)
this
.
lat
=
this
.
lat
-
this
.
mouseY
*
a
;
this
.
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
this
.
lat
));
this
.
phi
=
(
90
-
this
.
lat
)
*
Math
.
PI
/
180
;
this
.
theta
=
this
.
lon
*
Math
.
PI
/
180
;
var
b
=
this
.
target
,
c
=
this
.
object
.
position
;
b
.
x
=
c
.
x
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
cos
(
this
.
theta
);
b
.
y
=
c
.
y
+
100
*
Math
.
cos
(
this
.
phi
);
b
.
z
=
c
.
z
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
sin
(
this
.
theta
);
b
=
1
;
this
.
constrainVertical
&&
(
b
=
Math
.
PI
/
(
this
.
verticalMax
-
this
.
verticalMin
));
this
.
lon
=
this
.
lon
+
this
.
mouseX
*
a
;
if
(
this
.
lookVertical
)
this
.
lat
=
this
.
lat
-
this
.
mouseY
*
a
*
b
;
this
.
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
this
.
lat
));
this
.
phi
=
(
90
-
this
.
lat
)
*
Math
.
PI
/
180
;
this
.
theta
=
this
.
lon
*
Math
.
PI
/
180
;
if
(
this
.
constrainVertical
)
this
.
phi
=
THREE
.
Math
.
mapLinear
(
this
.
phi
,
0
,
Math
.
PI
,
this
.
verticalMin
,
this
.
verticalMax
);
b
=
this
.
target
;
c
=
this
.
object
.
position
;
b
.
x
=
c
.
x
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
cos
(
this
.
theta
);
b
.
y
=
c
.
y
+
100
*
Math
.
cos
(
this
.
phi
);
b
.
z
=
c
.
z
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
sin
(
this
.
theta
);
this
.
object
.
lookAt
(
b
)}};
this
.
domElement
.
addEventListener
(
"
contextmenu
"
,
function
(
a
){
a
.
preventDefault
()},
false
);
this
.
domElement
.
addEventListener
(
"
mousemove
"
,
c
(
this
,
this
.
onMouseMove
),
false
);
this
.
domElement
.
addEventListener
(
"
mousedown
"
,
c
(
this
,
this
.
onMouseDown
),
false
);
this
.
domElement
.
addEventListener
(
"
mouseup
"
,
c
(
this
,
this
.
onMouseUp
),
false
);
this
.
domElement
.
addEventListener
(
"
keydown
"
,
c
(
this
,
this
.
onKey
Down
),
false
);
this
.
domElement
.
addEventListener
(
"
keyup
"
,
c
(
this
,
this
.
onKey
Up
),
false
)};
THREE
.
PathControls
=
function
(
b
,
a
){
function
c
(
a
){
return
(
a
=
a
*
2
)
<
1
?
0.5
*
a
*
a
:
-
0.5
*
(
--
a
*
(
a
-
2
)
-
1
)}
function
d
(
a
,
b
){
return
function
(){
b
.
apply
(
a
,
arguments
)}}
function
e
(
a
,
b
,
c
,
d
){
var
e
=
{
name
:
c
,
fps
:
0.6
,
length
:
d
,
hierarchy
:[]},
f
,
g
=
b
.
getControlPointsArray
(),
h
=
b
.
getLength
(),
r
=
g
.
length
,
s
=
0
;
f
=
r
-
1
;
b
=
{
parent
:
-
1
,
keys
:[]};
b
.
keys
[
0
]
=
{
time
:
0
,
pos
:
g
[
0
],
rot
:[
0
,
0
,
0
,
1
],
scl
:[
1
,
1
,
1
]};
b
.
keys
[
f
]
=
{
time
:
d
,
pos
:
g
[
f
],
rot
:[
0
,
0
,
0
,
1
],
scl
:[
1
,
1
,
1
]};
for
(
f
=
1
;
f
<
r
-
1
;
f
++
){
s
=
d
*
h
.
chunks
[
f
]
/
h
.
total
;
b
.
keys
[
f
]
=
{
time
:
s
,
pos
:
g
[
f
]}}
e
.
hierarchy
[
0
]
=
b
;
THREE
.
AnimationHandler
.
add
(
e
);
return
new
THREE
.
Animation
(
a
,
c
,
THREE
.
AnimationHandler
.
CATMULLROM_FORWARD
,
false
)}
function
f
(
a
,
b
){
var
c
,
d
,
e
=
new
THREE
.
Geometry
;
for
(
c
=
0
;
c
<
a
.
points
.
length
*
b
;
c
++
){
d
=
c
/
(
a
.
points
.
length
*
b
);
d
=
a
.
getPoint
(
d
);
e
.
vertices
[
c
]
=
new
THREE
.
Vector3
(
d
.
x
,
d
.
y
,
d
.
z
)}
return
e
}
this
.
object
=
b
;
this
.
domElement
=
a
!==
void
0
?
a
:
document
;
this
.
id
=
"
PathControls
"
+
THREE
.
PathControlsIdCounter
++
;
this
.
duration
=
1
E4
;
this
.
waypoints
=
[];
this
.
useConstantSpeed
=
true
;
this
.
resamplingCoef
=
50
;
this
.
debugPath
=
new
THREE
.
Object3D
;
this
.
debugDummy
=
new
THREE
.
Object3D
;
this
.
animationParent
=
new
THREE
.
Object3D
;
this
.
lookSpeed
=
0.005
;
this
.
lookHorizontal
=
this
.
lookVertical
=
true
;
this
.
verticalAngleMap
=
{
srcRange
:[
0
,
2
*
Math
.
PI
],
dstRange
:[
0
,
2
*
Math
.
PI
]};
this
.
horizontalAngleMap
=
{
srcRange
:[
0
,
2
*
Math
.
PI
],
dstRange
:[
0
,
2
*
Math
.
PI
]};
this
.
target
=
new
THREE
.
Object3D
;
this
.
theta
=
this
.
phi
=
this
.
lon
=
this
.
lat
=
this
.
mouseY
=
this
.
mouseX
=
0
;
if
(
this
.
domElement
===
document
){
this
.
viewHalfX
=
window
.
innerWidth
/
2
;
this
.
viewHalfY
=
window
.
innerHeight
/
2
}
else
{
this
.
viewHalfX
=
this
.
domElement
.
offsetWidth
/
2
;
this
.
viewHalfY
=
...
...
@@ -150,7 +150,7 @@ c=new THREE.CubeGeometry(10,10,20),g=new THREE.CubeGeometry(2,2,10);this.animati
this
.
debugPath
,
b
=
this
.
spline
,
g
=
f
(
b
,
10
),
c
=
f
(
b
,
10
),
h
=
new
THREE
.
LineBasicMaterial
({
color
:
16711680
,
linewidth
:
3
}),
g
=
new
THREE
.
Line
(
g
,
h
),
c
=
new
THREE
.
ParticleSystem
(
c
,
new
THREE
.
ParticleBasicMaterial
({
color
:
16755200
,
size
:
3
}));
g
.
scale
.
set
(
1
,
1
,
1
);
a
.
add
(
g
);
c
.
scale
.
set
(
1
,
1
,
1
);
a
.
add
(
c
);
for
(
var
g
=
new
THREE
.
SphereGeometry
(
1
,
16
,
8
),
h
=
new
THREE
.
MeshBasicMaterial
({
color
:
65280
}),
m
=
0
;
m
<
b
.
points
.
length
;
m
++
){
c
=
new
THREE
.
Mesh
(
g
,
h
);
c
.
position
.
copy
(
b
.
points
[
m
]);
a
.
add
(
c
)}}
this
.
domElement
.
addEventListener
(
"
mousemove
"
,
d
(
this
,
this
.
onMouseMove
),
false
)}};
THREE
.
PathControlsIdCounter
=
0
;
THREE
.
FlyControls
=
function
(
b
,
a
){
function
c
(
a
,
b
){
return
function
(){
b
.
apply
(
a
,
arguments
)}}
this
.
object
=
b
;
this
.
domElement
=
a
!==
void
0
?
a
:
document
;
a
&&
this
.
domElement
.
setAttribute
(
"
tabindex
"
,
-
1
);
this
.
movementSpeed
=
1
;
this
.
rollSpeed
=
0.005
;
this
.
autoForward
=
this
.
dragToLook
=
false
;
this
.
object
.
useQuaternion
=
true
;
this
.
tmpQuaternion
=
new
THREE
.
Quaternion
;
this
.
mouseStatus
=
0
;
this
.
moveState
=
{
up
:
0
,
down
:
0
,
left
:
0
,
right
:
0
,
forward
:
0
,
back
:
0
,
pitchUp
:
0
,
pitchDown
:
0
,
yawLeft
:
0
,
yawRight
:
0
,
rollLeft
:
0
,
rollRight
:
0
};
this
.
moveVector
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
this
.
rotationVector
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
this
.
handleEvent
=
function
(
a
){
if
(
typeof
this
[
a
.
type
]
==
"
function
"
)
this
[
a
.
type
](
a
)};
this
.
keydown
=
function
(
a
){
if
(
!
a
.
altKey
){
switch
(
a
.
keyCode
){
case
16
:
this
.
movementSpeedMultiplier
=
0.1
;
break
;
case
87
:
this
.
moveState
.
forward
=
1
;
break
;
case
83
:
this
.
moveState
.
back
=
1
;
break
;
case
65
:
this
.
moveState
.
left
=
1
;
break
;
case
68
:
this
.
moveState
.
right
=
1
;
break
;
case
82
:
this
.
moveState
.
up
=
1
;
break
;
case
70
:
this
.
moveState
.
down
=
1
;
break
;
case
38
:
this
.
moveState
.
pitchUp
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
this
.
rotationVector
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
this
.
handleEvent
=
function
(
a
){
if
(
typeof
this
[
a
.
type
]
==
"
function
"
)
this
[
a
.
type
](
a
)};
this
.
keydown
=
function
(
a
){
if
(
!
a
.
altKey
){
a
.
preventDefault
();
switch
(
a
.
keyCode
){
case
16
:
this
.
movementSpeedMultiplier
=
0.1
;
break
;
case
87
:
this
.
moveState
.
forward
=
1
;
break
;
case
83
:
this
.
moveState
.
back
=
1
;
break
;
case
65
:
this
.
moveState
.
left
=
1
;
break
;
case
68
:
this
.
moveState
.
right
=
1
;
break
;
case
82
:
this
.
moveState
.
up
=
1
;
break
;
case
70
:
this
.
moveState
.
down
=
1
;
break
;
case
38
:
this
.
moveState
.
pitchUp
=
1
;
break
;
case
40
:
this
.
moveState
.
pitchDown
=
1
;
break
;
case
37
:
this
.
moveState
.
yawLeft
=
1
;
break
;
case
39
:
this
.
moveState
.
yawRight
=
1
;
break
;
case
81
:
this
.
moveState
.
rollLeft
=
1
;
break
;
case
69
:
this
.
moveState
.
rollRight
=
1
}
this
.
updateMovementVector
();
this
.
updateRotationVector
()}};
this
.
keyup
=
function
(
a
){
switch
(
a
.
keyCode
){
case
16
:
this
.
movementSpeedMultiplier
=
1
;
break
;
case
87
:
this
.
moveState
.
forward
=
0
;
break
;
case
83
:
this
.
moveState
.
back
=
0
;
break
;
case
65
:
this
.
moveState
.
left
=
0
;
break
;
case
68
:
this
.
moveState
.
right
=
0
;
break
;
case
82
:
this
.
moveState
.
up
=
0
;
break
;
case
70
:
this
.
moveState
.
down
=
0
;
break
;
case
38
:
this
.
moveState
.
pitchUp
=
0
;
break
;
case
40
:
this
.
moveState
.
pitchDown
=
0
;
break
;
case
37
:
this
.
moveState
.
yawLeft
=
0
;
break
;
case
39
:
this
.
moveState
.
yawRight
=
0
;
break
;
case
81
:
this
.
moveState
.
rollLeft
=
0
;
break
;
case
69
:
this
.
moveState
.
rollRight
=
0
}
this
.
updateMovementVector
();
this
.
updateRotationVector
()};
this
.
mousedown
=
function
(
a
){
this
.
domElement
!==
document
&&
this
.
domElement
.
focus
();
a
.
preventDefault
();
a
.
stopPropagation
();
if
(
this
.
dragToLook
)
this
.
mouseStatus
++
;
else
switch
(
a
.
button
){
case
0
:
this
.
object
.
moveForward
=
true
;
break
;
case
2
:
this
.
object
.
moveBackward
=
true
}};
this
.
mousemove
=
function
(
a
){
if
(
!
this
.
dragToLook
||
this
.
mouseStatus
>
0
){
var
b
=
this
.
getContainerDimensions
(),
c
=
b
.
size
[
0
]
/
2
,
g
=
b
.
size
[
1
]
/
2
;
this
.
moveState
.
yawLeft
=-
(
a
.
pageX
-
b
.
offset
[
0
]
-
c
)
/
c
;
this
.
moveState
.
pitchDown
=
(
a
.
pageY
-
b
.
offset
[
1
]
-
g
)
/
g
;
this
.
updateRotationVector
()}};
this
.
mouseup
=
function
(
a
){
a
.
preventDefault
();
a
.
stopPropagation
();
if
(
this
.
dragToLook
){
this
.
mouseStatus
--
;
this
.
moveState
.
yawLeft
=
this
.
moveState
.
pitchDown
=
0
}
else
switch
(
a
.
button
){
case
0
:
this
.
moveForward
=
...
...
@@ -164,8 +164,8 @@ d.set(0,1,0);c.cross(d,e).normalize();d.cross(e,c).normalize();this.object.matri
Math
.
cos
(
this
.
roll
);
this
.
object
.
matrix
.
multiplySelf
(
f
);
this
.
object
.
matrixWorldNeedsUpdate
=
true
;
this
.
object
.
matrix
.
elements
[
12
]
=
this
.
object
.
position
.
x
;
this
.
object
.
matrix
.
elements
[
13
]
=
this
.
object
.
position
.
y
;
this
.
object
.
matrix
.
elements
[
14
]
=
this
.
object
.
position
.
z
};
this
.
translateX
=
function
(
a
){
this
.
object
.
position
.
x
=
this
.
object
.
position
.
x
+
this
.
object
.
matrix
.
elements
[
0
]
*
a
;
this
.
object
.
position
.
y
=
this
.
object
.
position
.
y
+
this
.
object
.
matrix
.
elements
[
1
]
*
a
;
this
.
object
.
position
.
z
=
this
.
object
.
position
.
z
+
this
.
object
.
matrix
.
elements
[
2
]
*
a
};
this
.
translateY
=
function
(
a
){
this
.
object
.
position
.
x
=
this
.
object
.
position
.
x
+
this
.
object
.
matrix
.
elements
[
4
]
*
a
;
this
.
object
.
position
.
y
=
this
.
object
.
position
.
y
+
this
.
object
.
matrix
.
elements
[
5
]
*
a
;
this
.
object
.
position
.
z
=
this
.
object
.
position
.
z
+
this
.
object
.
matrix
.
elements
[
6
]
*
a
};
this
.
translateZ
=
function
(
a
){
this
.
object
.
position
.
x
=
this
.
object
.
position
.
x
-
this
.
object
.
matrix
.
elements
[
8
]
*
a
;
this
.
object
.
position
.
y
=
this
.
object
.
position
.
y
-
this
.
object
.
matrix
.
elements
[
9
]
*
a
;
this
.
object
.
position
.
z
=
this
.
object
.
position
.
z
-
this
.
object
.
matrix
.
elements
[
10
]
*
a
};
this
.
rotateHorizontally
=
function
(
a
){
c
.
set
(
this
.
object
.
matrix
.
elements
[
0
],
this
.
object
.
matrix
.
elements
[
1
],
this
.
object
.
matrix
.
elements
[
2
]);
c
.
multiplyScalar
(
a
);
this
.
forward
.
subSelf
(
c
);
this
.
forward
.
normalize
()};
this
.
rotateVertically
=
function
(
a
){
d
.
set
(
this
.
object
.
matrix
.
elements
[
4
],
this
.
object
.
matrix
.
elements
[
5
],
this
.
object
.
matrix
.
elements
[
6
]);
d
.
multiplyScalar
(
a
);
this
.
forward
.
addSelf
(
d
);
this
.
forward
.
normalize
()};
this
.
domElement
.
addEventListener
(
"
contextmenu
"
,
function
(
a
){
a
.
preventDefault
()},
false
);
this
.
domElement
.
addEventListener
(
"
mousemove
"
,
function
(
a
){
n
=
(
a
.
clientX
-
m
)
/
window
.
innerWidth
;
k
=
(
a
.
clientY
-
o
)
/
window
.
innerHeight
},
false
);
this
.
domElement
.
addEventListener
(
"
mousedown
"
,
function
(
a
){
a
.
preventDefault
();
a
.
stopPropagation
();
switch
(
a
.
button
){
case
0
:
i
=
1
;
break
;
case
2
:
i
=-
1
}},
false
);
this
.
domElement
.
addEventListener
(
"
mouseup
"
,
function
(
a
){
a
.
preventDefault
();
a
.
stopPropagation
();
switch
(
a
.
button
){
case
0
:
i
=
0
;
break
;
case
2
:
i
=
0
}},
false
);
this
.
domElement
.
addEventListener
(
"
keydown
"
,
function
(
a
){
switch
(
a
.
keyCode
){
case
38
:
case
87
:
i
=
1
;
break
;
case
37
:
case
65
:
j
=-
1
;
break
;
case
40
:
case
83
:
i
=-
1
;
break
;
case
39
:
case
68
:
j
=
1
;
break
;
case
81
:
g
=
true
;
h
=
1
;
break
;
case
69
:
g
=
true
;
h
=-
1
;
break
;
case
82
:
l
=
1
;
break
;
case
70
:
l
=-
1
}},
false
);
this
.
domElement
.
addEventListener
(
"
keyup
"
,
function
(
a
){
switch
(
a
.
keyCode
){
case
38
:
case
87
:
i
=
0
;
break
;
case
37
:
case
65
:
j
=
0
;
break
;
case
40
:
case
83
:
i
=
0
;
break
;
case
39
:
case
68
:
j
=
0
;
break
;
case
81
:
g
=
false
;
break
;
case
69
:
g
=
false
;
break
;
case
82
:
l
=
0
;
break
;
case
70
:
l
=
0
}},
false
)};
false
);
this
.
domElement
.
addEventListener
(
"
mousemove
"
,
function
(
a
){
n
=
(
a
.
clientX
-
m
)
/
window
.
innerWidth
;
k
=
(
a
.
clientY
-
o
)
/
window
.
innerHeight
},
false
);
this
.
domElement
.
addEventListener
(
"
mousedown
"
,
function
(
a
){
a
.
preventDefault
();
a
.
stopPropagation
();
switch
(
a
.
button
){
case
0
:
i
=
1
;
break
;
case
2
:
i
=-
1
}},
false
);
this
.
domElement
.
addEventListener
(
"
mouseup
"
,
function
(
a
){
a
.
preventDefault
();
a
.
stopPropagation
();
switch
(
a
.
button
){
case
0
:
i
=
0
;
break
;
case
2
:
i
=
0
}},
false
);
this
.
domElement
.
addEventListener
(
"
keydown
"
,
function
(
a
){
a
.
preventDefault
();
switch
(
a
.
keyCode
){
case
38
:
case
87
:
i
=
1
;
break
;
case
37
:
case
65
:
j
=-
1
;
break
;
case
40
:
case
83
:
i
=-
1
;
break
;
case
39
:
case
68
:
j
=
1
;
break
;
case
81
:
g
=
true
;
h
=
1
;
break
;
case
69
:
g
=
true
;
h
=-
1
;
break
;
case
82
:
l
=
1
;
break
;
case
70
:
l
=-
1
}},
false
);
this
.
domElement
.
addEventListener
(
"
keyup
"
,
function
(
a
){
switch
(
a
.
keyCode
){
case
38
:
case
87
:
i
=
0
;
break
;
case
37
:
case
65
:
j
=
0
;
break
;
case
40
:
case
83
:
i
=
0
;
break
;
case
39
:
case
68
:
j
=
0
;
break
;
case
81
:
g
=
false
;
break
;
case
69
:
g
=
false
;
break
;
case
82
:
l
=
0
;
break
;
case
70
:
l
=
0
}},
false
)};
THREE
.
TrackballControls
=
function
(
b
,
a
){
THREE
.
EventTarget
.
call
(
this
);
var
c
=
this
;
this
.
object
=
b
;
this
.
domElement
=
a
!==
void
0
?
a
:
document
;
this
.
enabled
=
true
;
this
.
screen
=
{
width
:
window
.
innerWidth
,
height
:
window
.
innerHeight
,
offsetLeft
:
0
,
offsetTop
:
0
};
this
.
radius
=
(
this
.
screen
.
width
+
this
.
screen
.
height
)
/
4
;
this
.
rotateSpeed
=
1
;
this
.
zoomSpeed
=
1.2
;
this
.
panSpeed
=
0.3
;
this
.
staticMoving
=
this
.
noPan
=
this
.
noZoom
=
this
.
noRotate
=
false
;
this
.
dynamicDampingFactor
=
0.2
;
this
.
minDistance
=
0
;
this
.
maxDistance
=
Infinity
;
this
.
keys
=
[
65
,
83
,
68
];
this
.
target
=
new
THREE
.
Vector3
;
var
d
=
new
THREE
.
Vector3
,
e
=
false
,
f
=-
1
,
g
=
new
THREE
.
Vector3
,
h
=
new
THREE
.
Vector3
,
i
=
new
THREE
.
Vector3
,
j
=
new
THREE
.
Vector2
,
l
=
new
THREE
.
Vector2
,
n
=
new
THREE
.
Vector2
,
k
=
new
THREE
.
Vector2
,
m
=
{
type
:
"
change
"
};
this
.
handleEvent
=
function
(
a
){
if
(
typeof
this
[
a
.
type
]
==
"
function
"
)
this
[
a
.
type
](
a
)};
this
.
getMouseOnScreen
=
function
(
a
,
b
){
return
new
THREE
.
Vector2
((
a
-
c
.
screen
.
offsetLeft
)
/
c
.
radius
*
0.5
,(
b
-
c
.
screen
.
offsetTop
)
/
c
.
radius
*
0.5
)};
this
.
getMouseProjectionOnBall
=
function
(
a
,
b
){
var
d
=
new
THREE
.
Vector3
((
a
-
c
.
screen
.
width
*
0.5
-
c
.
screen
.
offsetLeft
)
/
c
.
radius
,(
c
.
screen
.
height
*
0.5
+
c
.
screen
.
offsetTop
-
b
)
/
c
.
radius
,
0
),
e
=
d
.
length
();
e
>
1
?
d
.
normalize
():
d
.
z
=
Math
.
sqrt
(
1
-
e
*
e
);
g
.
copy
(
c
.
object
.
position
).
subSelf
(
c
.
target
);
e
=
c
.
object
.
up
.
clone
().
setLength
(
d
.
y
);
e
.
addSelf
(
c
.
object
.
up
.
clone
().
crossSelf
(
g
).
setLength
(
d
.
x
));
e
.
addSelf
(
g
.
setLength
(
d
.
z
));
return
e
};
this
.
rotateCamera
=
function
(){
var
a
=
Math
.
acos
(
h
.
dot
(
i
)
/
h
.
length
()
/
i
.
length
());
if
(
a
){
var
b
=
(
new
THREE
.
Vector3
).
cross
(
h
,
i
).
normalize
(),
d
=
new
THREE
.
Quaternion
,
a
=
a
*
c
.
rotateSpeed
;
...
...
build/custom/ThreeWebGL.js
浏览文件 @
08c8108d
...
...
@@ -154,18 +154,18 @@ f.z=u[w];q.normal=f}if(j)for(c=0;c<o;c++){w=A[k++]*3;f=new THREE.Vector3;f.x=u[w
b
+
2
){
f
=
a
.
skinIndices
[
b
];
m
=
a
.
skinIndices
[
b
+
1
];
d
.
skinIndices
.
push
(
new
THREE
.
Vector4
(
f
,
m
,
0
,
0
))}}
d
.
bones
=
a
.
bones
;
d
.
animation
=
a
.
animation
})();(
function
(
b
){
if
(
a
.
morphTargets
!==
void
0
){
var
c
,
f
,
m
,
k
,
i
,
o
;
c
=
0
;
for
(
f
=
a
.
morphTargets
.
length
;
c
<
f
;
c
++
){
d
.
morphTargets
[
c
]
=
{};
d
.
morphTargets
[
c
].
name
=
a
.
morphTargets
[
c
].
name
;
d
.
morphTargets
[
c
].
vertices
=
[];
i
=
d
.
morphTargets
[
c
].
vertices
;
o
=
a
.
morphTargets
[
c
].
vertices
;
m
=
0
;
for
(
k
=
o
.
length
;
m
<
k
;
m
=
m
+
3
){
var
j
=
new
THREE
.
Vector3
;
j
.
x
=
o
[
m
]
*
b
;
j
.
y
=
o
[
m
+
1
]
*
b
;
j
.
z
=
o
[
m
+
2
]
*
b
;
i
.
push
(
j
)}}}
if
(
a
.
morphColors
!==
void
0
){
c
=
0
;
for
(
f
=
a
.
morphColors
.
length
;
c
<
f
;
c
++
){
d
.
morphColors
[
c
]
=
{};
d
.
morphColors
[
c
].
name
=
a
.
morphColors
[
c
].
name
;
d
.
morphColors
[
c
].
colors
=
[];
k
=
d
.
morphColors
[
c
].
colors
;
i
=
a
.
morphColors
[
c
].
colors
;
b
=
0
;
for
(
m
=
i
.
length
;
b
<
m
;
b
=
b
+
3
){
o
=
new
THREE
.
Color
(
16755200
);
o
.
setRGB
(
i
[
b
],
i
[
b
+
1
],
i
[
b
+
2
]);
k
.
push
(
o
)}}}})(
f
);
d
.
computeCentroids
();
d
.
computeFaceNormals
();
this
.
hasNormals
(
d
)
&&
d
.
computeTangents
();
b
(
d
)};
THREE
.
GeometryLoader
=
function
(){
THREE
.
EventTarget
.
call
(
this
);
this
.
path
=
this
.
crossOrigin
=
null
};
THREE
.
GeometryLoader
.
prototype
=
{
constructor
:
THREE
.
GeometryLoader
,
load
:
function
(
a
){
var
b
=
this
,
c
=
null
;
if
(
b
.
path
===
null
){
var
d
=
a
.
split
(
"
/
"
);
d
.
pop
();
b
.
path
=
d
.
length
<
1
?
"
.
"
:
d
.
join
(
"
/
"
)}
d
=
new
XMLHttpRequest
;
d
.
addEventListener
(
"
load
"
,
function
(
d
){
d
.
target
.
responseText
?
c
=
b
.
parse
(
JSON
.
parse
(
d
.
target
.
responseText
),
f
):
b
.
dispatchEvent
({
type
:
"
error
"
,
message
:
"
Invalid file [
"
+
a
+
"
]
"
})},
false
);
d
.
addEventListener
(
"
error
"
,
function
(){
b
.
dispatchEvent
({
type
:
"
error
"
,
message
:
"
Couldn't load URL [
"
+
a
+
"
]
"
})},
false
);
d
.
open
(
"
GET
"
,
a
,
true
);
d
.
send
(
null
);
var
f
=
new
THREE
.
LoadingMonitor
;
f
.
addEventListener
(
"
load
"
,
function
(){
b
.
dispatchEvent
({
type
:
"
load
"
,
content
:
c
})});
f
.
add
(
d
)},
parse
:
function
(
a
,
b
){
var
c
=
this
,
d
=
new
THREE
.
Geometry
,
f
=
a
.
scale
!==
void
0
?
1
/
a
.
scale
:
1
;
d
.
materials
=
[];
for
(
var
e
=
0
;
e
<
a
.
materials
.
length
;
++
e
){
var
h
=
a
.
materials
[
e
],
l
=
function
(
a
){
a
=
Math
.
log
(
a
)
/
Math
.
LN2
;
return
Math
.
floor
(
a
)
==
a
},
m
=
function
(
a
){
a
=
Math
.
log
(
a
)
/
Math
.
LN2
;
return
Math
.
pow
(
2
,
Math
.
round
(
a
))},
k
=
function
(
a
,
d
,
f
,
e
,
h
,
i
){
a
[
d
]
=
new
THREE
.
Texture
;
a
[
d
].
sourceFile
=
f
;
if
(
e
){
a
[
d
].
repeat
.
set
(
e
[
0
],
e
[
1
]);
if
(
e
[
0
]
!=
1
)
a
[
d
].
wrapS
=
THREE
.
RepeatWrapping
;
if
(
e
[
1
]
!=
1
)
a
[
d
].
wrapT
=
THREE
.
RepeatWrapping
}
h
&&
a
[
d
].
offset
.
set
(
h
[
0
],
h
[
1
]);
if
(
i
){
e
=
{
repeat
:
THREE
.
RepeatWrapping
,
mirror
:
THREE
.
MirroredRepeatWrapping
};
if
(
e
[
i
[
0
]]
!==
void
0
)
a
[
d
].
wrapS
=
e
[
i
[
0
]];
if
(
e
[
i
[
1
]]
!==
void
0
)
a
[
d
].
wrapT
=
e
[
i
[
1
]]}
var
j
=
a
[
d
],
a
=
new
THREE
.
ImageLoader
;
a
.
addEventListener
(
"
load
"
,
function
(
a
){
a
=
a
.
content
;
if
(
!
l
(
a
.
width
)
||!
l
(
a
.
height
)){
var
b
=
m
(
a
.
width
),
c
=
m
(
a
.
height
);
j
.
image
=
document
.
createElement
(
"
canvas
"
);
j
.
image
.
width
=
b
;
j
.
image
.
height
=
c
;
j
.
image
.
getContext
(
"
2d
"
).
drawImage
(
a
,
0
,
0
,
b
,
c
)}
else
j
.
image
=
a
;
j
.
needsUpdate
=
true
});
a
.
crossOrigin
=
c
.
crossOrigin
;
a
.
load
(
c
.
path
+
"
/
"
+
f
);
b
&&
b
.
add
(
a
)},
i
=
function
(
a
){
return
(
a
[
0
]
*
255
<<
16
)
+
(
a
[
1
]
*
255
<<
8
)
+
a
[
2
]
*
255
},
o
=
"
MeshLambertMaterial
"
,
j
=
{
color
:
15658734
,
opacity
:
1
,
map
:
null
,
lightMap
:
null
,
normalMap
:
null
,
wireframe
:
h
.
wireframe
};
if
(
h
.
shading
){
var
w
=
h
.
shading
.
toLowerCase
();
w
===
"
phong
"
?
o
=
"
MeshPhongMaterial
"
:
w
===
"
basic
"
&&
(
o
=
"
MeshBasicMaterial
"
)}
if
(
h
.
blending
!==
void
0
&&
THREE
[
h
.
blending
]
!==
void
0
)
j
.
blending
=
THREE
[
h
.
blending
];
if
(
h
.
transparent
!==
void
0
||
h
.
opacity
<
1
)
j
.
transparent
=
h
.
transparent
;
if
(
h
.
depthTest
!==
void
0
)
j
.
depthTest
=
h
.
depthTest
;
if
(
h
.
depthWrite
!==
void
0
)
j
.
depthWrite
=
h
.
depthWrite
;
if
(
h
.
vertexColors
!==
void
0
)
if
(
h
.
vertexColors
==
"
face
"
)
j
.
vertexColors
=
THREE
.
FaceColors
;
else
if
(
h
.
vertexColors
)
j
.
vertexColors
=
THREE
.
VertexColors
;
if
(
h
.
colorDiffuse
)
j
.
color
=
i
(
h
.
colorDiffuse
);
else
if
(
h
.
DbgColor
)
j
.
color
=
h
.
DbgColor
;
if
(
h
.
colorSpecular
)
j
.
specular
=
i
(
h
.
colorSpecular
);
if
(
h
.
colorAmbient
)
j
.
ambient
=
i
(
h
.
colorAmbient
);
if
(
h
.
transparency
)
j
.
opacity
=
h
.
transparency
;
if
(
h
.
specularCoef
)
j
.
shininess
=
h
.
specularCoef
;
h
.
mapDiffuse
&&
k
(
j
,
"
map
"
,
h
.
mapDiffuse
,
h
.
mapDiffuseRepeat
,
h
.
mapDiffuseOffset
,
h
.
mapDiffuseWrap
);
h
.
mapLight
&&
k
(
j
,
"
lightMap
"
,
h
.
mapLight
,
h
.
mapLightRepeat
,
h
.
mapLightOffset
,
h
.
mapLightWrap
);
h
.
mapNormal
&&
k
(
j
,
"
normalMap
"
,
h
.
mapNormal
,
h
.
mapNormalRepeat
,
h
.
mapNormalOffset
,
h
.
mapNormalWrap
);
h
.
mapSpecular
&&
k
(
j
,
"
specularMap
"
,
h
.
mapSpecular
,
h
.
mapSpecularRepeat
,
h
.
mapSpecularOffset
,
h
.
mapSpecularWrap
);
if
(
h
.
mapNormal
){
k
=
THREE
.
ShaderUtils
.
lib
.
normal
;
i
=
THREE
.
UniformsUtils
.
clone
(
k
.
uniforms
)
;
i
.
tNormal
.
texture
=
j
.
normalMap
;
if
(
h
.
mapNormalFactor
)
i
.
uNormalScale
.
value
=
h
.
mapNormalFactor
;
if
(
j
.
map
){
i
.
tDiffuse
.
texture
=
j
.
map
;
i
.
enableDiffuse
.
value
=
true
}
if
(
j
.
specularMap
){
i
.
tSpecular
.
texture
=
j
.
specularMap
;
i
.
enableSpecular
.
value
=
true
}
if
(
j
.
lightMap
){
i
.
tAO
.
texture
=
j
.
lightMap
;
i
.
enableAO
.
value
=
true
}
i
.
uDiffuseColor
.
value
.
setHex
(
j
.
color
);
i
.
uSpecularColor
.
value
.
setHex
(
j
.
specular
);
i
.
uAmbientColor
.
value
.
setHex
(
j
.
ambient
);
i
.
uShininess
.
value
=
j
.
shininess
;
if
(
j
.
opacity
!==
void
0
)
i
.
uOpacity
.
value
=
j
.
opacity
;
j
=
new
THREE
.
ShaderMaterial
({
fragmentShader
:
k
.
fragmentShader
,
vertexShader
:
k
.
vertexShader
,
uniforms
:
i
,
lights
:
true
,
fog
:
true
})}
else
j
=
new
THREE
[
o
](
j
);
if
(
h
.
DbgName
!==
void
0
)
j
.
name
=
h
.
DbgName
;
d
.
materials
[
e
]
=
j
}
for
(
var
h
=
a
.
faces
,
r
=
a
.
vertices
,
j
=
a
.
normals
,
k
=
a
.
colors
,
e
=
i
=
0
;
e
<
a
.
uvs
.
length
;
e
++
)
a
.
uvs
[
e
].
length
&&
i
++
;
for
(
e
=
0
;
e
<
i
;
e
++
){
d
.
faceUvs
[
e
]
=
[];
d
.
faceVertexUvs
[
e
]
=
[]}
o
=
0
;
for
(
w
=
r
.
length
;
o
<
w
;){
var
n
=
new
THREE
.
Vector3
;
n
.
x
=
r
[
o
++
]
*
f
;
n
.
y
=
r
[
o
++
]
*
f
;
n
.
z
=
r
[
o
++
]
*
f
;
d
.
vertices
.
push
(
n
)}
o
=
0
;
for
(
w
=
h
.
length
;
o
<
w
;){
var
q
=
h
[
o
++
],
p
=
q
&
2
,
e
=
q
&
4
,
s
=
q
&
8
,
B
=
q
&
16
,
r
=
q
&
32
,
A
=
q
&
64
,
n
=
q
&
128
;
if
(
q
&
1
){
q
=
new
THREE
.
Face4
;
q
.
a
=
h
[
o
++
];
q
.
b
=
h
[
o
++
];
q
.
c
=
h
[
o
++
];
q
.
d
=
h
[
o
++
];
var
u
=
4
}
else
{
q
=
new
THREE
.
Face3
;
q
.
a
=
h
[
o
++
];
q
.
b
=
h
[
o
++
];
q
.
c
=
h
[
o
++
];
u
=
3
}
if
(
p
){
p
=
h
[
o
++
];
q
.
materialIndex
=
p
}
var
J
=
d
.
faces
.
length
;
if
(
e
)
for
(
e
=
0
;
e
<
i
;
e
++
){
var
D
=
a
.
uvs
[
e
],
p
=
h
[
o
++
],
M
=
D
[
p
*
2
],
p
=
D
[
p
*
2
+
1
];
d
.
faceUvs
[
e
][
J
]
=
new
THREE
.
UV
(
M
,
p
)}
if
(
s
)
for
(
e
=
0
;
e
<
i
;
e
++
){
for
(
var
D
=
a
.
uvs
[
e
],
s
=
[],
E
=
0
;
E
<
u
;
E
++
){
p
=
h
[
o
++
];
M
=
D
[
p
*
2
];
p
=
D
[
p
*
2
+
1
];
s
[
E
]
=
new
THREE
.
UV
(
M
,
p
)}
d
.
faceVertexUvs
[
e
][
J
]
=
s
}
if
(
B
){
B
=
h
[
o
++
]
*
3
;
p
=
new
THREE
.
Vector3
;
p
.
x
=
j
[
B
++
];
p
.
y
=
j
[
B
++
];
p
.
z
=
j
[
B
];
q
.
normal
=
p
}
if
(
r
)
for
(
e
=
0
;
e
<
u
;
e
++
){
B
=
h
[
o
++
]
*
3
;
p
=
new
THREE
.
Vector3
;
p
.
x
=
j
[
B
++
];
p
.
y
=
j
[
B
++
];
p
.
z
=
j
[
B
];
q
.
vertexNormals
.
push
(
p
)}
if
(
A
){
r
=
h
[
o
++
];
q
.
color
=
new
THREE
.
Color
(
k
[
r
])}
if
(
n
)
for
(
e
=
0
;
e
<
u
;
e
++
){
r
=
h
[
o
++
];
q
.
vertexColors
.
push
(
new
THREE
.
Color
(
k
[
r
]))}
d
.
faces
.
push
(
q
)}
if
(
a
.
skinWeights
){
e
=
0
;
for
(
h
=
a
.
skinWeights
.
length
;
e
<
h
;
e
=
e
+
2
)
d
.
skinWeights
.
push
(
new
THREE
.
Vector4
(
a
.
skinWeights
[
e
],
a
.
skinWeights
[
e
+
1
],
0
,
0
))}
if
(
a
.
skinIndices
){
e
=
0
;
for
(
h
=
a
.
skinIndices
.
length
;
e
<
h
;
e
=
e
+
2
){
j
=
0
;
d
.
skinIndices
.
push
(
new
THREE
.
Vector4
(
a
.
skinIndices
[
e
],
a
.
skinIndices
[
e
+
1
],
j
,
0
))}}
d
.
bones
=
a
.
bones
;
d
.
animation
=
a
.
animation
;
if
(
a
.
morphTargets
!==
void
0
){
e
=
0
;
for
(
h
=
a
.
morphTargets
.
length
;
e
<
h
;
e
++
){
d
.
morphTargets
[
e
]
=
{};
d
.
morphTargets
[
e
].
name
=
a
.
morphTargets
[
e
].
name
;
d
.
morphTargets
[
e
].
vertices
=
[];
j
=
d
.
morphTargets
[
e
].
vertices
;
k
=
a
.
morphTargets
[
e
].
vertices
;
p
=
0
;
for
(
i
=
k
.
length
;
p
<
i
;
p
=
p
+
3
){
n
=
new
THREE
.
Vector3
;
n
.
x
=
k
[
p
]
*
f
;
n
.
y
=
k
[
p
+
1
]
*
f
;
n
.
z
=
k
[
p
+
2
]
*
f
;
j
.
push
(
n
)}}}
if
(
a
.
morphColors
!==
void
0
){
e
=
0
;
for
(
h
=
a
.
morphColors
.
length
;
e
<
h
;
e
++
){
d
.
morphColors
[
e
]
=
{};
d
.
morphColors
[
e
].
name
=
a
.
morphColors
[
e
].
name
;
d
.
morphColors
[
e
].
colors
=
[];
f
=
d
.
morphColors
[
e
].
colors
;
k
=
a
.
morphColors
[
e
].
colors
;
j
=
0
;
for
(
i
=
k
.
length
;
j
<
i
;
j
=
j
+
3
){
o
=
new
THREE
.
Color
(
16755200
);
o
.
setRGB
(
k
[
j
],
k
[
j
+
1
],
k
[
j
+
2
]);
f
.
push
(
o
)}}}
d
.
computeCentroids
();
d
.
computeFaceNormals
();
return
d
}};
THREE
.
SceneLoader
=
function
(){
this
.
onLoadStart
=
function
(){};
this
.
onLoadProgress
=
function
(){};
this
.
onLoadComplete
=
function
(){};
this
.
callbackSync
=
function
(){};
this
.
callbackProgress
=
function
(){}};
THREE
.
SceneLoader
.
prototype
.
constructor
=
THREE
.
SceneLoader
;
THREE
.
SceneLoader
.
prototype
.
load
=
function
(
a
,
b
){
var
c
=
this
,
d
=
new
XMLHttpRequest
;
d
.
onreadystatechange
=
function
(){
if
(
d
.
readyState
==
4
)
if
(
d
.
status
==
200
||
d
.
status
==
0
){
var
f
=
JSON
.
parse
(
d
.
responseText
);
c
.
createScene
(
f
,
b
,
a
)}
else
console
.
error
(
"
THREE.SceneLoader: Couldn't load [
"
+
a
+
"
] [
"
+
d
.
status
+
"
]
"
)};
d
.
open
(
"
GET
"
,
a
,
true
);
d
.
overrideMimeType
&&
d
.
overrideMimeType
(
"
text/plain; charset=x-user-defined
"
);
d
.
setRequestHeader
(
"
Content-Type
"
,
"
text/plain
"
);
d
.
send
(
null
)};
a
,
true
);
d
.
send
(
null
);
var
f
=
new
THREE
.
LoadingMonitor
;
f
.
addEventListener
(
"
load
"
,
function
(){
b
.
dispatchEvent
({
type
:
"
load
"
,
content
:
c
})});
f
.
add
(
d
)},
parse
:
function
(
a
,
b
){
var
c
=
this
,
d
=
new
THREE
.
Geometry
,
f
=
a
.
scale
!==
void
0
?
1
/
a
.
scale
:
1
;
if
(
a
.
materials
){
d
.
materials
=
[];
for
(
var
e
=
0
;
e
<
a
.
materials
.
length
;
++
e
){
var
h
=
a
.
materials
[
e
],
l
=
function
(
a
){
a
=
Math
.
log
(
a
)
/
Math
.
LN2
;
return
Math
.
floor
(
a
)
==
a
},
m
=
function
(
a
){
a
=
Math
.
log
(
a
)
/
Math
.
LN2
;
return
Math
.
pow
(
2
,
Math
.
round
(
a
))},
k
=
function
(
a
,
d
,
f
,
e
,
h
,
i
){
a
[
d
]
=
new
THREE
.
Texture
;
a
[
d
].
sourceFile
=
f
;
if
(
e
){
a
[
d
].
repeat
.
set
(
e
[
0
],
e
[
1
]);
if
(
e
[
0
]
!=
1
)
a
[
d
].
wrapS
=
THREE
.
RepeatWrapping
;
if
(
e
[
1
]
!=
1
)
a
[
d
].
wrapT
=
THREE
.
RepeatWrapping
}
h
&&
a
[
d
].
offset
.
set
(
h
[
0
],
h
[
1
]);
if
(
i
){
e
=
{
repeat
:
THREE
.
RepeatWrapping
,
mirror
:
THREE
.
MirroredRepeatWrapping
};
if
(
e
[
i
[
0
]]
!==
void
0
)
a
[
d
].
wrapS
=
e
[
i
[
0
]];
if
(
e
[
i
[
1
]]
!==
void
0
)
a
[
d
].
wrapT
=
e
[
i
[
1
]]}
var
j
=
a
[
d
],
a
=
new
THREE
.
ImageLoader
;
a
.
addEventListener
(
"
load
"
,
function
(
a
){
a
=
a
.
content
;
if
(
!
l
(
a
.
width
)
||!
l
(
a
.
height
)){
var
b
=
m
(
a
.
width
),
c
=
m
(
a
.
height
);
j
.
image
=
document
.
createElement
(
"
canvas
"
);
j
.
image
.
width
=
b
;
j
.
image
.
height
=
c
;
j
.
image
.
getContext
(
"
2d
"
).
drawImage
(
a
,
0
,
0
,
b
,
c
)}
else
j
.
image
=
a
;
j
.
needsUpdate
=
true
});
a
.
crossOrigin
=
c
.
crossOrigin
;
a
.
load
(
c
.
path
+
"
/
"
+
f
);
b
&&
b
.
add
(
a
)},
i
=
function
(
a
){
return
(
a
[
0
]
*
255
<<
16
)
+
(
a
[
1
]
*
255
<<
8
)
+
a
[
2
]
*
255
},
o
=
"
MeshLambertMaterial
"
,
j
=
{
color
:
15658734
,
opacity
:
1
,
map
:
null
,
lightMap
:
null
,
normalMap
:
null
,
wireframe
:
h
.
wireframe
};
if
(
h
.
shading
){
var
w
=
h
.
shading
.
toLowerCase
();
w
===
"
phong
"
?
o
=
"
MeshPhongMaterial
"
:
w
===
"
basic
"
&&
(
o
=
"
MeshBasicMaterial
"
)}
if
(
h
.
blending
!==
void
0
&&
THREE
[
h
.
blending
]
!==
void
0
)
j
.
blending
=
THREE
[
h
.
blending
];
if
(
h
.
transparent
!==
void
0
||
h
.
opacity
<
1
)
j
.
transparent
=
h
.
transparent
;
if
(
h
.
depthTest
!==
void
0
)
j
.
depthTest
=
h
.
depthTest
;
if
(
h
.
depthWrite
!==
void
0
)
j
.
depthWrite
=
h
.
depthWrite
;
if
(
h
.
vertexColors
!==
void
0
)
if
(
h
.
vertexColors
==
"
face
"
)
j
.
vertexColors
=
THREE
.
FaceColors
;
else
if
(
h
.
vertexColors
)
j
.
vertexColors
=
THREE
.
VertexColors
;
if
(
h
.
colorDiffuse
)
j
.
color
=
i
(
h
.
colorDiffuse
);
else
if
(
h
.
DbgColor
)
j
.
color
=
h
.
DbgColor
;
if
(
h
.
colorSpecular
)
j
.
specular
=
i
(
h
.
colorSpecular
);
if
(
h
.
colorAmbient
)
j
.
ambient
=
i
(
h
.
colorAmbient
)
;
if
(
h
.
transparency
)
j
.
opacity
=
h
.
transparency
;
if
(
h
.
specularCoef
)
j
.
shininess
=
h
.
specularCoef
;
h
.
mapDiffuse
&&
k
(
j
,
"
map
"
,
h
.
mapDiffuse
,
h
.
mapDiffuseRepeat
,
h
.
mapDiffuseOffset
,
h
.
mapDiffuseWrap
);
h
.
mapLight
&&
k
(
j
,
"
lightMap
"
,
h
.
mapLight
,
h
.
mapLightRepeat
,
h
.
mapLightOffset
,
h
.
mapLightWrap
);
h
.
mapNormal
&&
k
(
j
,
"
normalMap
"
,
h
.
mapNormal
,
h
.
mapNormalRepeat
,
h
.
mapNormalOffset
,
h
.
mapNormalWrap
);
h
.
mapSpecular
&&
k
(
j
,
"
specularMap
"
,
h
.
mapSpecular
,
h
.
mapSpecularRepeat
,
h
.
mapSpecularOffset
,
h
.
mapSpecularWrap
);
if
(
h
.
mapNormal
){
k
=
THREE
.
ShaderUtils
.
lib
.
normal
;
i
=
THREE
.
UniformsUtils
.
clone
(
k
.
uniforms
);
i
.
tNormal
.
texture
=
j
.
normalMap
;
if
(
h
.
mapNormalFactor
)
i
.
uNormalScale
.
value
=
h
.
mapNormalFactor
;
if
(
j
.
map
){
i
.
tDiffuse
.
texture
=
j
.
map
;
i
.
enableDiffuse
.
value
=
true
}
if
(
j
.
specularMap
){
i
.
tSpecular
.
texture
=
j
.
specularMap
;
i
.
enableSpecular
.
value
=
true
}
if
(
j
.
lightMap
){
i
.
tAO
.
texture
=
j
.
lightMap
;
i
.
enableAO
.
value
=
true
}
i
.
uDiffuseColor
.
value
.
setHex
(
j
.
color
);
i
.
uSpecularColor
.
value
.
setHex
(
j
.
specular
);
i
.
uAmbientColor
.
value
.
setHex
(
j
.
ambient
);
i
.
uShininess
.
value
=
j
.
shininess
;
if
(
j
.
opacity
!==
void
0
)
i
.
uOpacity
.
value
=
j
.
opacity
;
j
=
new
THREE
.
ShaderMaterial
({
fragmentShader
:
k
.
fragmentShader
,
vertexShader
:
k
.
vertexShader
,
uniforms
:
i
,
lights
:
true
,
fog
:
true
})}
else
j
=
new
THREE
[
o
](
j
);
if
(
h
.
DbgName
!==
void
0
)
j
.
name
=
h
.
DbgName
;
d
.
materials
[
e
]
=
j
}}
var
h
=
a
.
faces
,
r
=
a
.
vertices
,
j
=
a
.
normals
,
k
=
a
.
colors
,
i
=
0
;
if
(
a
.
uvs
)
for
(
e
=
0
;
e
<
a
.
uvs
.
length
;
e
++
)
a
.
uvs
[
e
].
length
&&
i
++
;
for
(
e
=
0
;
e
<
i
;
e
++
){
d
.
faceUvs
[
e
]
=
[];
d
.
faceVertexUvs
[
e
]
=
[]}
o
=
0
;
for
(
w
=
r
.
length
;
o
<
w
;){
var
n
=
new
THREE
.
Vector3
;
n
.
x
=
r
[
o
++
]
*
f
;
n
.
y
=
r
[
o
++
]
*
f
;
n
.
z
=
r
[
o
++
]
*
f
;
d
.
vertices
.
push
(
n
)}
o
=
0
;
for
(
w
=
h
.
length
;
o
<
w
;){
var
q
=
h
[
o
++
],
p
=
q
&
2
,
e
=
q
&
4
,
s
=
q
&
8
,
B
=
q
&
16
,
r
=
q
&
32
,
A
=
q
&
64
,
n
=
q
&
128
;
if
(
q
&
1
){
q
=
new
THREE
.
Face4
;
q
.
a
=
h
[
o
++
];
q
.
b
=
h
[
o
++
];
q
.
c
=
h
[
o
++
];
q
.
d
=
h
[
o
++
];
var
u
=
4
}
else
{
q
=
new
THREE
.
Face3
;
q
.
a
=
h
[
o
++
];
q
.
b
=
h
[
o
++
];
q
.
c
=
h
[
o
++
];
u
=
3
}
if
(
p
){
p
=
h
[
o
++
];
q
.
materialIndex
=
p
}
var
J
=
d
.
faces
.
length
;
if
(
e
)
for
(
e
=
0
;
e
<
i
;
e
++
){
var
D
=
a
.
uvs
[
e
],
p
=
h
[
o
++
],
M
=
D
[
p
*
2
],
p
=
D
[
p
*
2
+
1
];
d
.
faceUvs
[
e
][
J
]
=
new
THREE
.
UV
(
M
,
p
)}
if
(
s
)
for
(
e
=
0
;
e
<
i
;
e
++
){
for
(
var
D
=
a
.
uvs
[
e
],
s
=
[],
E
=
0
;
E
<
u
;
E
++
){
p
=
h
[
o
++
];
M
=
D
[
p
*
2
];
p
=
D
[
p
*
2
+
1
];
s
[
E
]
=
new
THREE
.
UV
(
M
,
p
)}
d
.
faceVertexUvs
[
e
][
J
]
=
s
}
if
(
B
){
B
=
h
[
o
++
]
*
3
;
p
=
new
THREE
.
Vector3
;
p
.
x
=
j
[
B
++
];
p
.
y
=
j
[
B
++
];
p
.
z
=
j
[
B
];
q
.
normal
=
p
}
if
(
r
)
for
(
e
=
0
;
e
<
u
;
e
++
){
B
=
h
[
o
++
]
*
3
;
p
=
new
THREE
.
Vector3
;
p
.
x
=
j
[
B
++
];
p
.
y
=
j
[
B
++
];
p
.
z
=
j
[
B
];
q
.
vertexNormals
.
push
(
p
)}
if
(
A
){
r
=
h
[
o
++
];
q
.
color
=
new
THREE
.
Color
(
k
[
r
])}
if
(
n
)
for
(
e
=
0
;
e
<
u
;
e
++
){
r
=
h
[
o
++
];
q
.
vertexColors
.
push
(
new
THREE
.
Color
(
k
[
r
]))}
d
.
faces
.
push
(
q
)}
if
(
a
.
skinWeights
){
e
=
0
;
for
(
h
=
a
.
skinWeights
.
length
;
e
<
h
;
e
=
e
+
2
)
d
.
skinWeights
.
push
(
new
THREE
.
Vector4
(
a
.
skinWeights
[
e
],
a
.
skinWeights
[
e
+
1
],
0
,
0
))}
if
(
a
.
skinIndices
){
e
=
0
;
for
(
h
=
a
.
skinIndices
.
length
;
e
<
h
;
e
=
e
+
2
){
j
=
0
;
d
.
skinIndices
.
push
(
new
THREE
.
Vector4
(
a
.
skinIndices
[
e
],
a
.
skinIndices
[
e
+
1
],
j
,
0
))}}
d
.
bones
=
a
.
bones
;
d
.
animation
=
a
.
animation
;
if
(
a
.
morphTargets
){
e
=
0
;
for
(
h
=
a
.
morphTargets
.
length
;
e
<
h
;
e
++
){
d
.
morphTargets
[
e
]
=
{};
d
.
morphTargets
[
e
].
name
=
a
.
morphTargets
[
e
].
name
;
d
.
morphTargets
[
e
].
vertices
=
[];
j
=
d
.
morphTargets
[
e
].
vertices
;
k
=
a
.
morphTargets
[
e
].
vertices
;
p
=
0
;
for
(
i
=
k
.
length
;
p
<
i
;
p
=
p
+
3
){
n
=
new
THREE
.
Vector3
;
n
.
x
=
k
[
p
]
*
f
;
n
.
y
=
k
[
p
+
1
]
*
f
;
n
.
z
=
k
[
p
+
2
]
*
f
;
j
.
push
(
n
)}}}
if
(
a
.
morphColors
){
e
=
0
;
for
(
h
=
a
.
morphColors
.
length
;
e
<
h
;
e
++
){
d
.
morphColors
[
e
]
=
{};
d
.
morphColors
[
e
].
name
=
a
.
morphColors
[
e
].
name
;
d
.
morphColors
[
e
].
colors
=
[];
f
=
d
.
morphColors
[
e
].
colors
;
k
=
a
.
morphColors
[
e
].
colors
;
j
=
0
;
for
(
i
=
k
.
length
;
j
<
i
;
j
=
j
+
3
){
o
=
new
THREE
.
Color
(
16755200
);
o
.
setRGB
(
k
[
j
],
k
[
j
+
1
],
k
[
j
+
2
]);
f
.
push
(
o
)}}}
d
.
computeCentroids
();
d
.
computeFaceNormals
();
return
d
}};
THREE
.
SceneLoader
=
function
(){
this
.
onLoadStart
=
function
(){};
this
.
onLoadProgress
=
function
(){};
this
.
onLoadComplete
=
function
(){};
this
.
callbackSync
=
function
(){};
this
.
callbackProgress
=
function
(){}}
;
THREE
.
SceneLoader
.
prototype
.
constructor
=
THREE
.
SceneLoader
;
THREE
.
SceneLoader
.
prototype
.
load
=
function
(
a
,
b
){
var
c
=
this
,
d
=
new
XMLHttpRequest
;
d
.
onreadystatechange
=
function
(){
if
(
d
.
readyState
==
4
)
if
(
d
.
status
==
200
||
d
.
status
==
0
){
var
f
=
JSON
.
parse
(
d
.
responseText
);
c
.
createScene
(
f
,
b
,
a
)}
else
console
.
error
(
"
THREE.SceneLoader: Couldn't load [
"
+
a
+
"
] [
"
+
d
.
status
+
"
]
"
)};
d
.
open
(
"
GET
"
,
a
,
true
);
d
.
overrideMimeType
&&
d
.
overrideMimeType
(
"
text/plain; charset=x-user-defined
"
);
d
.
setRequestHeader
(
"
Content-Type
"
,
"
text/plain
"
);
d
.
send
(
null
)};
THREE
.
SceneLoader
.
prototype
.
createScene
=
function
(
a
,
b
,
c
){
function
d
(
a
,
b
){
return
b
==
"
relativeToHTML
"
?
a
:
k
+
"
/
"
+
a
}
function
f
(){
var
a
;
for
(
j
in
y
.
objects
)
if
(
!
I
.
objects
[
j
]){
p
=
y
.
objects
[
j
];
if
(
p
.
geometry
!==
void
0
){
if
(
G
=
I
.
geometries
[
p
.
geometry
]){
a
=
false
;
R
=
I
.
materials
[
p
.
materials
[
0
]];(
a
=
R
instanceof
THREE
.
ShaderMaterial
)
&&
G
.
computeTangents
();
u
=
p
.
position
;
J
=
p
.
rotation
;
D
=
p
.
quaternion
;
M
=
p
.
scale
;
s
=
p
.
matrix
;
D
=
0
;
p
.
materials
.
length
==
0
&&
(
R
=
new
THREE
.
MeshFaceMaterial
);
p
.
materials
.
length
>
1
&&
(
R
=
new
THREE
.
MeshFaceMaterial
);
a
=
new
THREE
.
Mesh
(
G
,
R
);
a
.
name
=
j
;
if
(
s
){
a
.
matrixAutoUpdate
=
false
;
a
.
matrix
.
set
(
s
[
0
],
s
[
1
],
s
[
2
],
s
[
3
],
s
[
4
],
s
[
5
],
s
[
6
],
s
[
7
],
s
[
8
],
s
[
9
],
s
[
10
],
s
[
11
],
s
[
12
],
s
[
13
],
s
[
14
],
s
[
15
])}
else
{
a
.
position
.
set
(
u
[
0
],
u
[
1
],
u
[
2
]);
if
(
D
){
a
.
quaternion
.
set
(
D
[
0
],
D
[
1
],
D
[
2
],
D
[
3
]);
a
.
useQuaternion
=
true
}
else
a
.
rotation
.
set
(
J
[
0
],
J
[
1
],
J
[
2
]);
a
.
scale
.
set
(
M
[
0
],
M
[
1
],
M
[
2
])}
a
.
visible
=
p
.
visible
;
a
.
doubleSided
=
p
.
doubleSided
;
a
.
castShadow
=
p
.
castShadow
;
a
.
receiveShadow
=
p
.
receiveShadow
;
I
.
scene
.
add
(
a
);
I
.
objects
[
j
]
=
a
}}
else
{
u
=
p
.
position
;
J
=
p
.
rotation
;
D
=
p
.
quaternion
;
M
=
p
.
scale
;
D
=
0
;
a
=
new
THREE
.
Object3D
;
a
.
name
=
j
;
a
.
position
.
set
(
u
[
0
],
u
[
1
],
u
[
2
]);
if
(
D
){
a
.
quaternion
.
set
(
D
[
0
],
D
[
1
],
D
[
2
],
D
[
3
]);
a
.
useQuaternion
=
true
}
else
a
.
rotation
.
set
(
J
[
0
],
J
[
1
],
J
[
2
]);
a
.
scale
.
set
(
M
[
0
],
M
[
1
],
M
[
2
]);
a
.
visible
=
p
.
visible
!==
void
0
?
p
.
visible
:
false
;
I
.
scene
.
add
(
a
);
I
.
objects
[
j
]
=
a
;
I
.
empties
[
j
]
=
a
}}}
function
e
(
a
){
return
function
(
b
){
I
.
geometries
[
a
]
=
b
;
f
();
Z
=
Z
-
1
;
m
.
onLoadComplete
();
l
()}}
function
h
(
a
){
return
function
(
b
){
I
.
geometries
[
a
]
=
b
}}
function
l
(){
m
.
callbackProgress
({
totalModels
:
g
,
totalTextures
:
W
,
loadedModels
:
g
-
...
...
gui/js/ui/Sidebar.Properties.Geometry.js
浏览文件 @
08c8108d
...
...
@@ -106,6 +106,37 @@ Sidebar.Properties.Geometry = function ( signals ) {
}
json
.
faces
=
[];
for
(
var
i
=
0
;
i
<
geometry
.
faces
.
length
;
i
++
)
{
var
face
=
geometry
.
faces
[
i
];
var
faceType
=
0
faceType
=
setBit
(
faceType
,
0
,
face
instanceof
THREE
.
Face4
);
json
.
faces
.
push
(
faceType
);
if
(
face
instanceof
THREE
.
Face3
)
{
json
.
faces
.
push
(
face
.
a
,
face
.
b
,
face
.
c
);
}
else
if
(
face
instanceof
THREE
.
Face4
)
{
json
.
faces
.
push
(
face
.
a
,
face
.
b
,
face
.
c
,
face
.
d
);
}
}
function
setBit
(
value
,
position
,
enabled
)
{
return
enabled
?
value
|
(
1
<<
position
)
:
value
&
(
~
(
1
<<
position
)
);
}
//
var
file
=
new
BlobBuilder
();
file
.
append
(
JSON
.
stringify
(
json
)
);
...
...
src/loaders/GeometryLoader.js
浏览文件 @
08c8108d
...
...
@@ -79,285 +79,288 @@ THREE.GeometryLoader.prototype = {
// materials
geometry
.
materials
=
[];
if
(
data
.
materials
)
{
for
(
var
i
=
0
;
i
<
data
.
materials
.
length
;
++
i
)
{
geometry
.
materials
=
[];
var
m
=
data
.
materials
[
i
];
for
(
var
i
=
0
;
i
<
data
.
materials
.
length
;
++
i
)
{
function
isPow2
(
n
)
{
var
m
=
data
.
materials
[
i
];
var
l
=
Math
.
log
(
n
)
/
Math
.
LN2
;
return
Math
.
floor
(
l
)
==
l
;
function
isPow2
(
n
)
{
}
var
l
=
Math
.
log
(
n
)
/
Math
.
LN2
;
return
Math
.
floor
(
l
)
==
l
;
function
nearestPow2
(
n
)
{
}
var
l
=
Math
.
log
(
n
)
/
Math
.
LN2
;
return
Math
.
pow
(
2
,
Math
.
round
(
l
)
);
function
nearestPow2
(
n
)
{
}
var
l
=
Math
.
log
(
n
)
/
Math
.
LN2
;
return
Math
.
pow
(
2
,
Math
.
round
(
l
)
);
function
createTexture
(
where
,
name
,
sourceFile
,
repeat
,
offset
,
wrap
)
{
}
where
[
name
]
=
new
THREE
.
Texture
();
where
[
name
].
sourceFile
=
sourceFile
;
function
createTexture
(
where
,
name
,
sourceFile
,
repeat
,
offset
,
wrap
)
{
if
(
repeat
)
{
where
[
name
]
=
new
THREE
.
Texture
();
where
[
name
].
sourceFile
=
sourceFile
;
where
[
name
].
repeat
.
set
(
repeat
[
0
],
repeat
[
1
]
);
if
(
repeat
)
{
if
(
repeat
[
0
]
!=
1
)
where
[
name
].
wrapS
=
THREE
.
RepeatWrapping
;
if
(
repeat
[
1
]
!=
1
)
where
[
name
].
wrapT
=
THREE
.
RepeatWrapping
;
where
[
name
].
repeat
.
set
(
repeat
[
0
],
repeat
[
1
]
);
}
if
(
repeat
[
0
]
!=
1
)
where
[
name
].
wrapS
=
THREE
.
RepeatWrapping
;
if
(
repeat
[
1
]
!=
1
)
where
[
name
].
wrapT
=
THREE
.
RepeatWrapping
;
if
(
offset
)
{
}
where
[
name
].
offset
.
set
(
offset
[
0
],
offset
[
1
]
);
if
(
offset
)
{
}
where
[
name
].
offset
.
set
(
offset
[
0
],
offset
[
1
]
);
if
(
wrap
)
{
}
var
wrapMap
=
{
if
(
wrap
)
{
"
repeat
"
:
THREE
.
RepeatWrapping
,
"
mirror
"
:
THREE
.
MirroredRepeatWrapping
var
wrapMap
=
{
}
"
repeat
"
:
THREE
.
RepeatWrapping
,
"
mirror
"
:
THREE
.
MirroredRepeatWrapping
if
(
wrapMap
[
wrap
[
0
]
]
!==
undefined
)
where
[
name
].
wrapS
=
wrapMap
[
wrap
[
0
]
];
if
(
wrapMap
[
wrap
[
1
]
]
!==
undefined
)
where
[
name
].
wrapT
=
wrapMap
[
wrap
[
1
]
];
}
}
if
(
wrapMap
[
wrap
[
0
]
]
!==
undefined
)
where
[
name
].
wrapS
=
wrapMap
[
wrap
[
0
]
];
if
(
wrapMap
[
wrap
[
1
]
]
!==
undefined
)
where
[
name
].
wrapT
=
wrapMap
[
wrap
[
1
]
];
// load image
}
var
texture
=
where
[
name
];
// load image
var
loader
=
new
THREE
.
ImageLoader
();
loader
.
addEventListener
(
'
load
'
,
function
(
event
)
{
var
texture
=
where
[
name
];
var
image
=
event
.
content
;
var
loader
=
new
THREE
.
ImageLoader
();
loader
.
addEventListener
(
'
load
'
,
function
(
event
)
{
if
(
!
isPow2
(
image
.
width
)
||
!
isPow2
(
image
.
height
)
)
{
var
image
=
event
.
content
;
var
width
=
nearestPow2
(
image
.
width
);
var
height
=
nearestPow2
(
image
.
height
);
if
(
!
isPow2
(
image
.
width
)
||
!
isPow2
(
image
.
height
)
)
{
texture
.
image
=
document
.
createElement
(
'
canvas
'
);
texture
.
image
.
width
=
width
;
texture
.
image
.
height
=
height
;
texture
.
image
.
getContext
(
'
2d
'
).
drawImage
(
image
,
0
,
0
,
width
,
height
);
var
width
=
nearestPow2
(
image
.
width
);
var
height
=
nearestPow2
(
image
.
height
);
}
else
{
texture
.
image
=
document
.
createElement
(
'
canvas
'
);
texture
.
image
.
width
=
width
;
texture
.
image
.
height
=
height
;
texture
.
image
.
getContext
(
'
2d
'
).
drawImage
(
image
,
0
,
0
,
width
,
height
);
texture
.
image
=
image
;
}
else
{
}
texture
.
image
=
image
;
texture
.
needsUpdate
=
true
;
}
}
);
loader
.
crossOrigin
=
scope
.
crossOrigin
;
loader
.
load
(
scope
.
path
+
'
/
'
+
sourceFile
);
texture
.
needsUpdate
=
true
;
if
(
monitor
)
monitor
.
add
(
loader
);
}
);
loader
.
crossOrigin
=
scope
.
crossOrigin
;
loader
.
load
(
scope
.
path
+
'
/
'
+
sourceFile
);
}
if
(
monitor
)
monitor
.
add
(
loader
);
function
rgb2hex
(
rgb
)
{
}
return
(
rgb
[
0
]
*
255
<<
16
)
+
(
rgb
[
1
]
*
255
<<
8
)
+
rgb
[
2
]
*
255
;
function
rgb2hex
(
rgb
)
{
}
return
(
rgb
[
0
]
*
255
<<
16
)
+
(
rgb
[
1
]
*
255
<<
8
)
+
rgb
[
2
]
*
255
;
// defaults
}
var
mtype
=
"
MeshLambertMaterial
"
;
var
mpars
=
{
color
:
0xeeeeee
,
opacity
:
1.0
,
map
:
null
,
lightMap
:
null
,
normalMap
:
null
,
wireframe
:
m
.
wireframe
};
// defaults
// parameters from model file
var
mtype
=
"
MeshLambertMaterial
"
;
var
mpars
=
{
color
:
0xeeeeee
,
opacity
:
1.0
,
map
:
null
,
lightMap
:
null
,
normalMap
:
null
,
wireframe
:
m
.
wireframe
};
if
(
m
.
shading
)
{
// parameters from model file
var
shading
=
m
.
shading
.
toLowerCase
();
if
(
m
.
shading
)
{
if
(
shading
===
"
phong
"
)
mtype
=
"
MeshPhongMaterial
"
;
else
if
(
shading
===
"
basic
"
)
mtype
=
"
MeshBasicMaterial
"
;
var
shading
=
m
.
shading
.
toLowerCase
();
}
if
(
shading
===
"
phong
"
)
mtype
=
"
MeshPhongMaterial
"
;
else
if
(
shading
===
"
basic
"
)
mtype
=
"
MeshBasicMaterial
"
;
if
(
m
.
blending
!==
undefined
&&
THREE
[
m
.
blending
]
!==
undefined
)
{
}
mpars
.
blending
=
THREE
[
m
.
blending
];
if
(
m
.
blending
!==
undefined
&&
THREE
[
m
.
blending
]
!==
undefined
)
{
}
mpars
.
blending
=
THREE
[
m
.
blending
];
if
(
m
.
transparent
!==
undefined
||
m
.
opacity
<
1.0
)
{
}
mpars
.
transparent
=
m
.
transparent
;
if
(
m
.
transparent
!==
undefined
||
m
.
opacity
<
1.0
)
{
}
mpars
.
transparent
=
m
.
transparent
;
if
(
m
.
depthTest
!==
undefined
)
{
}
mpars
.
depthTest
=
m
.
depthTest
;
if
(
m
.
depthTest
!==
undefined
)
{
}
mpars
.
depthTest
=
m
.
depthTest
;
if
(
m
.
depthWrite
!==
undefined
)
{
}
mpars
.
depthWrite
=
m
.
depthWrite
;
if
(
m
.
depthWrite
!==
undefined
)
{
}
mpars
.
depthWrite
=
m
.
depthWrite
;
if
(
m
.
vertexColors
!==
undefined
)
{
}
if
(
m
.
vertexColors
!==
undefined
)
{
if
(
m
.
vertexColors
==
"
face
"
)
{
if
(
m
.
vertexColors
==
"
face
"
)
{
mpars
.
vertexColors
=
THREE
.
FaceColors
;
mpars
.
vertexColors
=
THREE
.
FaceColors
;
}
else
if
(
m
.
vertexColors
)
{
}
else
if
(
m
.
vertexColors
)
{
mpars
.
vertexColors
=
THREE
.
VertexColors
;
mpars
.
vertexColors
=
THREE
.
VertexColors
;
}
}
}
// colors
// colors
if
(
m
.
colorDiffuse
)
{
if
(
m
.
colorDiffuse
)
{
mpars
.
color
=
rgb2hex
(
m
.
colorDiffuse
);
mpars
.
color
=
rgb2hex
(
m
.
colorDiffuse
);
}
else
if
(
m
.
DbgColor
)
{
}
else
if
(
m
.
DbgColor
)
{
mpars
.
color
=
m
.
DbgColor
;
mpars
.
color
=
m
.
DbgColor
;
}
}
if
(
m
.
colorSpecular
)
{
if
(
m
.
colorSpecular
)
{
mpars
.
specular
=
rgb2hex
(
m
.
colorSpecular
);
mpars
.
specular
=
rgb2hex
(
m
.
colorSpecular
);
}
}
if
(
m
.
colorAmbient
)
{
if
(
m
.
colorAmbient
)
{
mpars
.
ambient
=
rgb2hex
(
m
.
colorAmbient
);
mpars
.
ambient
=
rgb2hex
(
m
.
colorAmbient
);
}
}
// modifiers
// modifiers
if
(
m
.
transparency
)
{
if
(
m
.
transparency
)
{
mpars
.
opacity
=
m
.
transparency
;
mpars
.
opacity
=
m
.
transparency
;
}
}
if
(
m
.
specularCoef
)
{
if
(
m
.
specularCoef
)
{
mpars
.
shininess
=
m
.
specularCoef
;
mpars
.
shininess
=
m
.
specularCoef
;
}
}
// textures
// textures
if
(
m
.
mapDiffuse
)
{
if
(
m
.
mapDiffuse
)
{
createTexture
(
mpars
,
"
map
"
,
m
.
mapDiffuse
,
m
.
mapDiffuseRepeat
,
m
.
mapDiffuseOffset
,
m
.
mapDiffuseWrap
);
createTexture
(
mpars
,
"
map
"
,
m
.
mapDiffuse
,
m
.
mapDiffuseRepeat
,
m
.
mapDiffuseOffset
,
m
.
mapDiffuseWrap
);
}
}
if
(
m
.
mapLight
)
{
if
(
m
.
mapLight
)
{
createTexture
(
mpars
,
"
lightMap
"
,
m
.
mapLight
,
m
.
mapLightRepeat
,
m
.
mapLightOffset
,
m
.
mapLightWrap
);
createTexture
(
mpars
,
"
lightMap
"
,
m
.
mapLight
,
m
.
mapLightRepeat
,
m
.
mapLightOffset
,
m
.
mapLightWrap
);
}
}
if
(
m
.
mapNormal
)
{
if
(
m
.
mapNormal
)
{
createTexture
(
mpars
,
"
normalMap
"
,
m
.
mapNormal
,
m
.
mapNormalRepeat
,
m
.
mapNormalOffset
,
m
.
mapNormalWrap
);
createTexture
(
mpars
,
"
normalMap
"
,
m
.
mapNormal
,
m
.
mapNormalRepeat
,
m
.
mapNormalOffset
,
m
.
mapNormalWrap
);
}
}
if
(
m
.
mapSpecular
)
{
if
(
m
.
mapSpecular
)
{
createTexture
(
mpars
,
"
specularMap
"
,
m
.
mapSpecular
,
m
.
mapSpecularRepeat
,
m
.
mapSpecularOffset
,
m
.
mapSpecularWrap
);
createTexture
(
mpars
,
"
specularMap
"
,
m
.
mapSpecular
,
m
.
mapSpecularRepeat
,
m
.
mapSpecularOffset
,
m
.
mapSpecularWrap
);
}
}
// special case for normal mapped material
// special case for normal mapped material
if
(
m
.
mapNormal
)
{
if
(
m
.
mapNormal
)
{
var
shader
=
THREE
.
ShaderUtils
.
lib
[
"
normal
"
];
var
uniforms
=
THREE
.
UniformsUtils
.
clone
(
shader
.
uniforms
);
var
shader
=
THREE
.
ShaderUtils
.
lib
[
"
normal
"
];
var
uniforms
=
THREE
.
UniformsUtils
.
clone
(
shader
.
uniforms
);
uniforms
[
"
tNormal
"
].
texture
=
mpars
.
normalMap
;
uniforms
[
"
tNormal
"
].
texture
=
mpars
.
normalMap
;
if
(
m
.
mapNormalFactor
)
{
if
(
m
.
mapNormalFactor
)
{
uniforms
[
"
uNormalScale
"
].
value
=
m
.
mapNormalFactor
;
uniforms
[
"
uNormalScale
"
].
value
=
m
.
mapNormalFactor
;
}
}
if
(
mpars
.
map
)
{
if
(
mpars
.
map
)
{
uniforms
[
"
tDiffuse
"
].
texture
=
mpars
.
map
;
uniforms
[
"
enableDiffuse
"
].
value
=
true
;
uniforms
[
"
tDiffuse
"
].
texture
=
mpars
.
map
;
uniforms
[
"
enableDiffuse
"
].
value
=
true
;
}
}
if
(
mpars
.
specularMap
)
{
if
(
mpars
.
specularMap
)
{
uniforms
[
"
tSpecular
"
].
texture
=
mpars
.
specularMap
;
uniforms
[
"
enableSpecular
"
].
value
=
true
;
uniforms
[
"
tSpecular
"
].
texture
=
mpars
.
specularMap
;
uniforms
[
"
enableSpecular
"
].
value
=
true
;
}
}
if
(
mpars
.
lightMap
)
{
if
(
mpars
.
lightMap
)
{
uniforms
[
"
tAO
"
].
texture
=
mpars
.
lightMap
;
uniforms
[
"
enableAO
"
].
value
=
true
;
uniforms
[
"
tAO
"
].
texture
=
mpars
.
lightMap
;
uniforms
[
"
enableAO
"
].
value
=
true
;
}
}
// for the moment don't handle displacement texture
// for the moment don't handle displacement texture
uniforms
[
"
uDiffuseColor
"
].
value
.
setHex
(
mpars
.
color
);
uniforms
[
"
uSpecularColor
"
].
value
.
setHex
(
mpars
.
specular
);
uniforms
[
"
uAmbientColor
"
].
value
.
setHex
(
mpars
.
ambient
);
uniforms
[
"
uDiffuseColor
"
].
value
.
setHex
(
mpars
.
color
);
uniforms
[
"
uSpecularColor
"
].
value
.
setHex
(
mpars
.
specular
);
uniforms
[
"
uAmbientColor
"
].
value
.
setHex
(
mpars
.
ambient
);
uniforms
[
"
uShininess
"
].
value
=
mpars
.
shininess
;
uniforms
[
"
uShininess
"
].
value
=
mpars
.
shininess
;
if
(
mpars
.
opacity
!==
undefined
)
{
if
(
mpars
.
opacity
!==
undefined
)
{
uniforms
[
"
uOpacity
"
].
value
=
mpars
.
opacity
;
uniforms
[
"
uOpacity
"
].
value
=
mpars
.
opacity
;
}
}
var
parameters
=
{
fragmentShader
:
shader
.
fragmentShader
,
vertexShader
:
shader
.
vertexShader
,
uniforms
:
uniforms
,
lights
:
true
,
fog
:
true
};
var
material
=
new
THREE
.
ShaderMaterial
(
parameters
);
var
parameters
=
{
fragmentShader
:
shader
.
fragmentShader
,
vertexShader
:
shader
.
vertexShader
,
uniforms
:
uniforms
,
lights
:
true
,
fog
:
true
};
var
material
=
new
THREE
.
ShaderMaterial
(
parameters
);
}
else
{
}
else
{
var
material
=
new
THREE
[
mtype
](
mpars
);
var
material
=
new
THREE
[
mtype
](
mpars
);
}
}
if
(
m
.
DbgName
!==
undefined
)
material
.
name
=
m
.
DbgName
;
if
(
m
.
DbgName
!==
undefined
)
material
.
name
=
m
.
DbgName
;
geometry
.
materials
[
i
]
=
material
;
geometry
.
materials
[
i
]
=
material
;
}
}
// geometry
function
isBitSet
(
value
,
position
)
{
...
...
@@ -374,9 +377,13 @@ THREE.GeometryLoader.prototype = {
// disregard empty arrays
for
(
var
i
=
0
;
i
<
data
.
uvs
.
length
;
i
++
)
{
if
(
data
.
uvs
)
{
for
(
var
i
=
0
;
i
<
data
.
uvs
.
length
;
i
++
)
{
if
(
data
.
uvs
[
i
].
length
)
nUvLayers
++
;
if
(
data
.
uvs
[
i
].
length
)
nUvLayers
++
;
}
}
...
...
@@ -594,7 +601,7 @@ THREE.GeometryLoader.prototype = {
// morphing
if
(
data
.
morphTargets
!==
undefined
)
{
if
(
data
.
morphTargets
)
{
for
(
var
i
=
0
,
l
=
data
.
morphTargets
.
length
;
i
<
l
;
i
++
)
{
...
...
@@ -620,7 +627,7 @@ THREE.GeometryLoader.prototype = {
}
if
(
data
.
morphColors
!==
undefined
)
{
if
(
data
.
morphColors
)
{
for
(
var
i
=
0
,
l
=
data
.
morphColors
.
length
;
i
<
l
;
i
++
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录