Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
29da25e7
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,发现更多精彩内容 >>
提交
29da25e7
编写于
4月 01, 2011
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WebGLRenderer: Added internal cache for compiled shaders. Already compiled shaders get reused.
上级
b6aa8c84
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
429 addition
and
397 deletion
+429
-397
README.md
README.md
+2
-1
build/Three.js
build/Three.js
+249
-248
build/custom/ThreeCanvas.js
build/custom/ThreeCanvas.js
+1
-1
build/custom/ThreeDOM.js
build/custom/ThreeDOM.js
+1
-1
build/custom/ThreeExtras.js
build/custom/ThreeExtras.js
+3
-3
build/custom/ThreeSVG.js
build/custom/ThreeSVG.js
+1
-1
build/custom/ThreeWebGL.js
build/custom/ThreeWebGL.js
+141
-141
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+31
-1
未找到文件。
README.md
浏览文件 @
29da25e7
...
...
@@ -141,7 +141,7 @@ This code creates a camera, then creates a scene, adds a cube on it, creates a &
### Change Log ###
2011 03 31 -
**r38**
(225.
720 KB, gzip: 55.881
KB)
2011 03 31 -
**r38**
(225.
442 KB, gzip: 55.908
KB)
*
Added
`LensFlare`
light. (
[
empaempa
](
http://github.com/empaempa
)
)
*
Added
`ShadowVolume`
object (stencil shadows). (
[
empaempa
](
http://github.com/empaempa
)
)
...
...
@@ -151,6 +151,7 @@ This code creates a camera, then creates a scene, adds a cube on it, creates a &
*
Minor WebGL blend mode clean up. (
[
mrdoob
](
http://github.com/mrdoob
)
)
*
*
Materials now extend Material (
[
mrdoob
](
http://github.com/mrdoob
)
)
*
`material.transparent`
define whether material is transparent or not (before we were guessing). (
[
mrdoob
](
http://github.com/mrdoob
)
)
*
Added internal program cache to WebGLRenderer (reuse already available programs). (
[
mrdoob
](
http://github.com/mrdoob
)
)
2011 03 22 -
**r37**
(208.495 KB, gzip: 51.376 KB)
...
...
build/Three.js
浏览文件 @
29da25e7
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
build/custom/ThreeCanvas.js
浏览文件 @
29da25e7
...
...
@@ -48,7 +48,7 @@ b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?
THREE
.
Quaternion
.
prototype
=
{
set
:
function
(
a
,
b
,
c
,
e
){
this
.
x
=
a
;
this
.
y
=
b
;
this
.
z
=
c
;
this
.
w
=
e
;
return
this
},
setFromEuler
:
function
(
a
){
var
b
=
0.5
*
Math
.
PI
/
360
,
c
=
a
.
x
*
b
,
e
=
a
.
y
*
b
,
d
=
a
.
z
*
b
;
a
=
Math
.
cos
(
e
);
e
=
Math
.
sin
(
e
);
b
=
Math
.
cos
(
-
d
);
d
=
Math
.
sin
(
-
d
);
var
f
=
Math
.
cos
(
c
);
c
=
Math
.
sin
(
c
);
var
g
=
a
*
b
,
i
=
e
*
d
;
this
.
w
=
g
*
f
-
i
*
c
;
this
.
x
=
g
*
c
+
i
*
f
;
this
.
y
=
e
*
b
*
f
+
a
*
d
*
c
;
this
.
z
=
a
*
d
*
f
-
e
*
b
*
c
;
return
this
},
calculateW
:
function
(){
this
.
w
=-
Math
.
sqrt
(
Math
.
abs
(
1
-
this
.
x
*
this
.
x
-
this
.
y
*
this
.
y
-
this
.
z
*
this
.
z
));
return
this
},
inverse
:
function
(){
this
.
x
*=-
1
;
this
.
y
*=
-
1
;
this
.
z
*=-
1
;
return
this
},
length
:
function
(){
return
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
+
this
.
w
*
this
.
w
)},
normalize
:
function
(){
var
a
=
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
+
this
.
w
*
this
.
w
);
if
(
a
==
0
)
this
.
w
=
this
.
z
=
this
.
y
=
this
.
x
=
0
;
else
{
a
=
1
/
a
;
this
.
x
*=
a
;
this
.
y
*=
a
;
this
.
z
*=
a
;
this
.
w
*=
a
}
return
this
},
multiplySelf
:
function
(
a
){
var
b
=
this
.
x
,
c
=
this
.
y
,
e
=
this
.
z
,
d
=
this
.
w
,
f
=
a
.
x
,
g
=
a
.
y
,
i
=
a
.
z
;
a
=
a
.
w
;
this
.
x
=
b
*
a
+
d
*
f
+
c
*
i
-
e
*
g
;
this
.
y
=
c
*
a
+
d
*
g
+
e
*
f
-
b
*
i
;
this
.
z
=
e
*
a
+
d
*
i
+
b
*
g
-
c
*
f
;
this
.
w
=
d
*
a
-
b
*
f
-
c
*
g
-
e
*
i
;
return
this
},
multiplyVector3
:
function
(
a
,
b
){
b
||
(
b
=
a
);
var
c
=
a
.
x
,
e
=
a
.
y
,
d
=
a
.
z
,
f
=
this
.
x
,
g
=
this
.
y
,
i
=
this
.
z
,
h
=
this
.
w
,
j
=
h
*
c
+
g
*
d
-
i
*
e
,
k
=
h
*
e
+
i
*
c
-
f
*
d
,
n
=
h
*
d
+
f
*
e
-
g
*
c
;
c
=-
f
*
c
-
g
*
e
-
i
*
d
;
b
.
x
=
j
*
h
+
c
*-
f
+
k
*-
i
-
n
*-
g
;
b
.
y
=
k
*
h
+
c
*-
g
+
n
*-
f
-
j
*-
i
;
b
.
z
=
n
*
h
+
c
*-
i
+
j
*-
g
-
k
*-
f
;
return
b
}};
THREE
.
Quaternion
.
slerp
=
function
(
a
,
b
,
c
,
e
){
var
d
=
a
.
w
*
b
.
w
+
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
+
a
.
z
*
b
.
z
;
if
(
Math
.
abs
(
d
)
>=
1
){
c
.
w
=
a
.
w
;
c
.
x
=
a
.
x
;
c
.
y
=
a
.
y
;
c
.
z
=
a
.
z
;
return
c
}
var
f
=
Math
.
acos
(
d
),
g
=
Math
.
sqrt
(
1
-
d
*
d
);
if
(
Math
.
abs
(
g
)
<
0.001
0
){
c
.
w
=
0.5
*
(
a
.
w
+
b
.
w
);
c
.
x
=
0.5
*
(
a
.
x
+
b
.
x
);
c
.
y
=
0.5
*
(
a
.
y
+
b
.
y
);
c
.
z
=
0.5
*
(
a
.
z
+
b
.
z
);
return
c
}
d
=
Math
.
sin
((
1
-
e
)
*
f
)
/
g
;
e
=
Math
.
sin
(
e
*
f
)
/
g
;
c
.
w
=
a
.
w
*
d
+
b
.
w
*
e
;
c
.
x
=
a
.
x
*
d
+
b
.
x
*
e
;
c
.
y
=
a
.
y
*
d
+
b
.
y
*
e
;
c
.
z
=
a
.
z
*
d
+
b
.
z
*
e
;
return
c
};
THREE
.
Vertex
=
function
(
a
){
this
.
position
=
a
||
new
THREE
.
Vector3
};
THREE
.
Quaternion
.
slerp
=
function
(
a
,
b
,
c
,
e
){
var
d
=
a
.
w
*
b
.
w
+
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
+
a
.
z
*
b
.
z
;
if
(
Math
.
abs
(
d
)
>=
1
){
c
.
w
=
a
.
w
;
c
.
x
=
a
.
x
;
c
.
y
=
a
.
y
;
c
.
z
=
a
.
z
;
return
c
}
var
f
=
Math
.
acos
(
d
),
g
=
Math
.
sqrt
(
1
-
d
*
d
);
if
(
Math
.
abs
(
g
)
<
0.001
){
c
.
w
=
0.5
*
(
a
.
w
+
b
.
w
);
c
.
x
=
0.5
*
(
a
.
x
+
b
.
x
);
c
.
y
=
0.5
*
(
a
.
y
+
b
.
y
);
c
.
z
=
0.5
*
(
a
.
z
+
b
.
z
);
return
c
}
d
=
Math
.
sin
((
1
-
e
)
*
f
)
/
g
;
e
=
Math
.
sin
(
e
*
f
)
/
g
;
c
.
w
=
a
.
w
*
d
+
b
.
w
*
e
;
c
.
x
=
a
.
x
*
d
+
b
.
x
*
e
;
c
.
y
=
a
.
y
*
d
+
b
.
y
*
e
;
c
.
z
=
a
.
z
*
d
+
b
.
z
*
e
;
return
c
};
THREE
.
Vertex
=
function
(
a
){
this
.
position
=
a
||
new
THREE
.
Vector3
};
THREE
.
Face3
=
function
(
a
,
b
,
c
,
e
,
d
,
f
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
normal
=
e
instanceof
THREE
.
Vector3
?
e
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
e
instanceof
Array
?
e
:[];
this
.
color
=
d
instanceof
THREE
.
Color
?
d
:
new
THREE
.
Color
;
this
.
vertexColors
=
d
instanceof
Array
?
d
:[];
this
.
vertexTangents
=
[];
this
.
materials
=
f
instanceof
Array
?
f
:[
f
];
this
.
centroid
=
new
THREE
.
Vector3
};
THREE
.
Face4
=
function
(
a
,
b
,
c
,
e
,
d
,
f
,
g
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
d
=
e
;
this
.
normal
=
d
instanceof
THREE
.
Vector3
?
d
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
d
instanceof
Array
?
d
:[];
this
.
color
=
f
instanceof
THREE
.
Color
?
f
:
new
THREE
.
Color
;
this
.
vertexColors
=
f
instanceof
Array
?
f
:[];
this
.
vertexTangents
=
[];
this
.
materials
=
g
instanceof
Array
?
g
:[
g
];
this
.
centroid
=
new
THREE
.
Vector3
};
THREE
.
UV
=
function
(
a
,
b
){
this
.
set
(
a
||
0
,
b
||
0
)};
THREE
.
UV
.
prototype
=
{
set
:
function
(
a
,
b
){
this
.
u
=
a
;
this
.
v
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
set
(
a
.
u
,
a
.
v
);
return
this
}};
THREE
.
Geometry
=
function
(){
this
.
id
=
"
Geometry
"
+
THREE
.
GeometryIdCounter
++
;
this
.
vertices
=
[];
this
.
colors
=
[];
this
.
faces
=
[];
this
.
faceUvs
=
[[]];
this
.
faceVertexUvs
=
[[]];
this
.
morphTargets
=
[];
this
.
skinWeights
=
[];
this
.
skinIndices
=
[];
this
.
boundingSphere
=
this
.
boundingBox
=
null
;
this
.
hasTangents
=!
1
};
...
...
build/custom/ThreeDOM.js
浏览文件 @
29da25e7
...
...
@@ -48,7 +48,7 @@ b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?
THREE
.
Quaternion
.
prototype
=
{
set
:
function
(
a
,
b
,
c
,
e
){
this
.
x
=
a
;
this
.
y
=
b
;
this
.
z
=
c
;
this
.
w
=
e
;
return
this
},
setFromEuler
:
function
(
a
){
var
b
=
0.5
*
Math
.
PI
/
360
,
c
=
a
.
x
*
b
,
e
=
a
.
y
*
b
,
d
=
a
.
z
*
b
;
a
=
Math
.
cos
(
e
);
e
=
Math
.
sin
(
e
);
b
=
Math
.
cos
(
-
d
);
d
=
Math
.
sin
(
-
d
);
var
g
=
Math
.
cos
(
c
);
c
=
Math
.
sin
(
c
);
var
f
=
a
*
b
,
i
=
e
*
d
;
this
.
w
=
f
*
g
-
i
*
c
;
this
.
x
=
f
*
c
+
i
*
g
;
this
.
y
=
e
*
b
*
g
+
a
*
d
*
c
;
this
.
z
=
a
*
d
*
g
-
e
*
b
*
c
;
return
this
},
calculateW
:
function
(){
this
.
w
=-
Math
.
sqrt
(
Math
.
abs
(
1
-
this
.
x
*
this
.
x
-
this
.
y
*
this
.
y
-
this
.
z
*
this
.
z
));
return
this
},
inverse
:
function
(){
this
.
x
*=-
1
;
this
.
y
*=
-
1
;
this
.
z
*=-
1
;
return
this
},
length
:
function
(){
return
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
+
this
.
w
*
this
.
w
)},
normalize
:
function
(){
var
a
=
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
+
this
.
w
*
this
.
w
);
if
(
a
==
0
)
this
.
w
=
this
.
z
=
this
.
y
=
this
.
x
=
0
;
else
{
a
=
1
/
a
;
this
.
x
*=
a
;
this
.
y
*=
a
;
this
.
z
*=
a
;
this
.
w
*=
a
}
return
this
},
multiplySelf
:
function
(
a
){
var
b
=
this
.
x
,
c
=
this
.
y
,
e
=
this
.
z
,
d
=
this
.
w
,
g
=
a
.
x
,
f
=
a
.
y
,
i
=
a
.
z
;
a
=
a
.
w
;
this
.
x
=
b
*
a
+
d
*
g
+
c
*
i
-
e
*
f
;
this
.
y
=
c
*
a
+
d
*
f
+
e
*
g
-
b
*
i
;
this
.
z
=
e
*
a
+
d
*
i
+
b
*
f
-
c
*
g
;
this
.
w
=
d
*
a
-
b
*
g
-
c
*
f
-
e
*
i
;
return
this
},
multiplyVector3
:
function
(
a
,
b
){
b
||
(
b
=
a
);
var
c
=
a
.
x
,
e
=
a
.
y
,
d
=
a
.
z
,
g
=
this
.
x
,
f
=
this
.
y
,
i
=
this
.
z
,
h
=
this
.
w
,
j
=
h
*
c
+
f
*
d
-
i
*
e
,
m
=
h
*
e
+
i
*
c
-
g
*
d
,
l
=
h
*
d
+
g
*
e
-
f
*
c
;
c
=-
g
*
c
-
f
*
e
-
i
*
d
;
b
.
x
=
j
*
h
+
c
*-
g
+
m
*-
i
-
l
*-
f
;
b
.
y
=
m
*
h
+
c
*-
f
+
l
*-
g
-
j
*-
i
;
b
.
z
=
l
*
h
+
c
*-
i
+
j
*-
f
-
m
*-
g
;
return
b
}};
THREE
.
Quaternion
.
slerp
=
function
(
a
,
b
,
c
,
e
){
var
d
=
a
.
w
*
b
.
w
+
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
+
a
.
z
*
b
.
z
;
if
(
Math
.
abs
(
d
)
>=
1
){
c
.
w
=
a
.
w
;
c
.
x
=
a
.
x
;
c
.
y
=
a
.
y
;
c
.
z
=
a
.
z
;
return
c
}
var
g
=
Math
.
acos
(
d
),
f
=
Math
.
sqrt
(
1
-
d
*
d
);
if
(
Math
.
abs
(
f
)
<
0.001
0
){
c
.
w
=
0.5
*
(
a
.
w
+
b
.
w
);
c
.
x
=
0.5
*
(
a
.
x
+
b
.
x
);
c
.
y
=
0.5
*
(
a
.
y
+
b
.
y
);
c
.
z
=
0.5
*
(
a
.
z
+
b
.
z
);
return
c
}
d
=
Math
.
sin
((
1
-
e
)
*
g
)
/
f
;
e
=
Math
.
sin
(
e
*
g
)
/
f
;
c
.
w
=
a
.
w
*
d
+
b
.
w
*
e
;
c
.
x
=
a
.
x
*
d
+
b
.
x
*
e
;
c
.
y
=
a
.
y
*
d
+
b
.
y
*
e
;
c
.
z
=
a
.
z
*
d
+
b
.
z
*
e
;
return
c
};
THREE
.
Vertex
=
function
(
a
){
this
.
position
=
a
||
new
THREE
.
Vector3
};
THREE
.
Quaternion
.
slerp
=
function
(
a
,
b
,
c
,
e
){
var
d
=
a
.
w
*
b
.
w
+
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
+
a
.
z
*
b
.
z
;
if
(
Math
.
abs
(
d
)
>=
1
){
c
.
w
=
a
.
w
;
c
.
x
=
a
.
x
;
c
.
y
=
a
.
y
;
c
.
z
=
a
.
z
;
return
c
}
var
g
=
Math
.
acos
(
d
),
f
=
Math
.
sqrt
(
1
-
d
*
d
);
if
(
Math
.
abs
(
f
)
<
0.001
){
c
.
w
=
0.5
*
(
a
.
w
+
b
.
w
);
c
.
x
=
0.5
*
(
a
.
x
+
b
.
x
);
c
.
y
=
0.5
*
(
a
.
y
+
b
.
y
);
c
.
z
=
0.5
*
(
a
.
z
+
b
.
z
);
return
c
}
d
=
Math
.
sin
((
1
-
e
)
*
g
)
/
f
;
e
=
Math
.
sin
(
e
*
g
)
/
f
;
c
.
w
=
a
.
w
*
d
+
b
.
w
*
e
;
c
.
x
=
a
.
x
*
d
+
b
.
x
*
e
;
c
.
y
=
a
.
y
*
d
+
b
.
y
*
e
;
c
.
z
=
a
.
z
*
d
+
b
.
z
*
e
;
return
c
};
THREE
.
Vertex
=
function
(
a
){
this
.
position
=
a
||
new
THREE
.
Vector3
};
THREE
.
Face3
=
function
(
a
,
b
,
c
,
e
,
d
,
g
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
normal
=
e
instanceof
THREE
.
Vector3
?
e
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
e
instanceof
Array
?
e
:[];
this
.
color
=
d
instanceof
THREE
.
Color
?
d
:
new
THREE
.
Color
;
this
.
vertexColors
=
d
instanceof
Array
?
d
:[];
this
.
vertexTangents
=
[];
this
.
materials
=
g
instanceof
Array
?
g
:[
g
];
this
.
centroid
=
new
THREE
.
Vector3
};
THREE
.
Face4
=
function
(
a
,
b
,
c
,
e
,
d
,
g
,
f
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
d
=
e
;
this
.
normal
=
d
instanceof
THREE
.
Vector3
?
d
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
d
instanceof
Array
?
d
:[];
this
.
color
=
g
instanceof
THREE
.
Color
?
g
:
new
THREE
.
Color
;
this
.
vertexColors
=
g
instanceof
Array
?
g
:[];
this
.
vertexTangents
=
[];
this
.
materials
=
f
instanceof
Array
?
f
:[
f
];
this
.
centroid
=
new
THREE
.
Vector3
};
THREE
.
UV
=
function
(
a
,
b
){
this
.
set
(
a
||
0
,
b
||
0
)};
THREE
.
UV
.
prototype
=
{
set
:
function
(
a
,
b
){
this
.
u
=
a
;
this
.
v
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
set
(
a
.
u
,
a
.
v
);
return
this
}};
...
...
build/custom/ThreeExtras.js
浏览文件 @
29da25e7
...
...
@@ -24,7 +24,7 @@ value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.00195
film
:{
uniforms
:{
tDiffuse
:{
type
:
"
t
"
,
value
:
0
,
texture
:
null
},
time
:{
type
:
"
f
"
,
value
:
0
},
nIntensity
:{
type
:
"
f
"
,
value
:
0.5
},
sIntensity
:{
type
:
"
f
"
,
value
:
0.05
},
sCount
:{
type
:
"
f
"
,
value
:
4096
},
grayscale
:{
type
:
"
i
"
,
value
:
1
}},
vertexShader
:
"
varying vec2 vUv;
\n
void main() {
\n
vUv = vec2( uv.x, 1.0 - uv.y );
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
\n
}
"
,
fragmentShader
:
"
varying vec2 vUv;
\n
uniform sampler2D tDiffuse;
\n
uniform float time;
\n
uniform bool grayscale;
\n
uniform float nIntensity;
\n
uniform float sIntensity;
\n
uniform float sCount;
\n
void main() {
\n
vec4 cTextureScreen = texture2D( tDiffuse, vUv );
\n
float x = vUv.x * vUv.y * time * 1000.0;
\n
x = mod( x, 13.0 ) * mod( x, 123.0 );
\n
float dx = mod( x, 0.01 );
\n
vec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );
\n
vec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );
\n
cResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;
\n
cResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );
\n
if( grayscale ) {
\n
cResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );
\n
}
\n
gl_FragColor = vec4( cResult, cTextureScreen.a );
\n
}
"
},
screen
:{
uniforms
:{
tDiffuse
:{
type
:
"
t
"
,
value
:
0
,
texture
:
null
},
opacity
:{
type
:
"
f
"
,
value
:
1
}},
vertexShader
:
"
varying vec2 vUv;
\n
void main() {
\n
vUv = vec2( uv.x, 1.0 - uv.y );
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
\n
}
"
,
fragmentShader
:
"
varying vec2 vUv;
\n
uniform sampler2D tDiffuse;
\n
uniform float opacity;
\n
void main() {
\n
vec4 texel = texture2D( tDiffuse, vUv );
\n
gl_FragColor = opacity * texel;
\n
}
"
},
basic
:{
uniforms
:{},
vertexShader
:
"
void main() {
\n
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
\n
}
"
,
fragmentShader
:
"
void main() {
\n
gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );
\n
}
"
}},
buildKernel
:
function
(
a
){
var
f
,
b
,
c
,
e
,
d
=
2
*
Math
.
ceil
(
a
*
3
)
+
1
;
d
>
25
&&
(
d
=
25
);
e
=
(
d
-
1
)
*
0.5
;
b
=
Array
(
d
);
for
(
f
=
c
=
0
;
f
<
d
;
++
f
){
b
[
f
]
=
Math
.
exp
(
-
((
f
-
e
)
*
(
f
-
e
))
/
(
2
*
a
*
a
));
c
+=
b
[
f
]}
for
(
f
=
0
;
f
<
d
;
++
f
)
b
[
f
]
/=
c
;
return
b
}};
THREE
.
QuakeCamera
=
function
(
a
){
function
f
(
b
,
c
){
return
function
(){
c
.
apply
(
b
,
arguments
)}}
THREE
.
Camera
.
call
(
this
,
a
.
fov
,
a
.
aspect
,
a
.
near
,
a
.
far
,
a
.
target
);
this
.
movementSpeed
=
1
;
this
.
lookSpeed
=
0.005
0
;
this
.
noFly
=!
1
;
this
.
lookVertical
=!
0
;
this
.
autoForward
=!
1
;
this
.
activeLook
=!
0
;
this
.
heightSpeed
=!
1
;
this
.
heightCoef
=
1
;
this
.
heightMin
=
0
;
this
.
domElement
=
document
;
if
(
a
){
if
(
a
.
movementSpeed
!==
undefined
)
this
.
movementSpeed
=
a
.
movementSpeed
;
if
(
a
.
lookSpeed
!==
undefined
)
this
.
lookSpeed
=
a
.
lookSpeed
;
if
(
a
.
noFly
!==
undefined
)
this
.
noFly
=
THREE
.
QuakeCamera
=
function
(
a
){
function
f
(
b
,
c
){
return
function
(){
c
.
apply
(
b
,
arguments
)}}
THREE
.
Camera
.
call
(
this
,
a
.
fov
,
a
.
aspect
,
a
.
near
,
a
.
far
,
a
.
target
);
this
.
movementSpeed
=
1
;
this
.
lookSpeed
=
0.005
;
this
.
noFly
=!
1
;
this
.
lookVertical
=!
0
;
this
.
autoForward
=!
1
;
this
.
activeLook
=!
0
;
this
.
heightSpeed
=!
1
;
this
.
heightCoef
=
1
;
this
.
heightMin
=
0
;
this
.
domElement
=
document
;
if
(
a
){
if
(
a
.
movementSpeed
!==
undefined
)
this
.
movementSpeed
=
a
.
movementSpeed
;
if
(
a
.
lookSpeed
!==
undefined
)
this
.
lookSpeed
=
a
.
lookSpeed
;
if
(
a
.
noFly
!==
undefined
)
this
.
noFly
=
a
.
noFly
;
if
(
a
.
lookVertical
!==
undefined
)
this
.
lookVertical
=
a
.
lookVertical
;
if
(
a
.
autoForward
!==
undefined
)
this
.
autoForward
=
a
.
autoForward
;
if
(
a
.
activeLook
!==
undefined
)
this
.
activeLook
=
a
.
activeLook
;
if
(
a
.
heightSpeed
!==
undefined
)
this
.
heightSpeed
=
a
.
heightSpeed
;
if
(
a
.
heightCoef
!==
undefined
)
this
.
heightCoef
=
a
.
heightCoef
;
if
(
a
.
heightMin
!==
undefined
)
this
.
heightMin
=
a
.
heightMin
;
if
(
a
.
heightMax
!==
undefined
)
this
.
heightMax
=
a
.
heightMax
;
if
(
a
.
domElement
!==
undefined
)
this
.
domElement
=
a
.
domElement
}
this
.
theta
=
this
.
phi
=
this
.
lon
=
this
.
lat
=
this
.
mouseY
=
this
.
mouseX
=
this
.
autoSpeedFactor
=
0
;
this
.
moveForward
=!
1
;
this
.
moveBackward
=!
1
;
this
.
moveLeft
=!
1
;
this
.
moveRight
=!
1
;
this
.
mouseDragOn
=!
1
;
this
.
windowHalfX
=
window
.
innerWidth
/
2
;
this
.
windowHalfY
=
window
.
innerHeight
/
2
;
this
.
onMouseDown
=
function
(
b
){
b
.
preventDefault
();
b
.
stopPropagation
();
if
(
this
.
activeLook
)
switch
(
b
.
button
){
case
0
:
this
.
moveForward
=!
0
;
break
;
case
2
:
this
.
moveBackward
=!
0
}
this
.
mouseDragOn
=!
0
};
this
.
onMouseUp
=
function
(
b
){
b
.
preventDefault
();
b
.
stopPropagation
();
if
(
this
.
activeLook
)
switch
(
b
.
button
){
case
0
:
this
.
moveForward
=
!
1
;
break
;
case
2
:
this
.
moveBackward
=!
1
}
this
.
mouseDragOn
=!
1
};
this
.
onMouseMove
=
function
(
b
){
this
.
mouseX
=
b
.
clientX
-
this
.
windowHalfX
;
this
.
mouseY
=
b
.
clientY
-
this
.
windowHalfY
};
this
.
onKeyDown
=
function
(
b
){
switch
(
b
.
keyCode
){
case
38
:
case
87
:
this
.
moveForward
=!
0
;
break
;
case
37
:
case
65
:
this
.
moveLeft
=!
0
;
break
;
case
40
:
case
83
:
this
.
moveBackward
=!
0
;
break
;
case
39
:
case
68
:
this
.
moveRight
=!
0
}};
this
.
onKeyUp
=
function
(
b
){
switch
(
b
.
keyCode
){
case
38
:
case
87
:
this
.
moveForward
=!
1
;
break
;
case
37
:
case
65
:
this
.
moveLeft
=!
1
;
break
;
case
40
:
case
83
:
this
.
moveBackward
=
...
...
@@ -34,7 +34,7 @@ var b=this.lookSpeed;this.activeLook||(b=0);this.lon+=this.mouseX*b;this.lookVer
THREE
.
QuakeCamera
.
prototype
.
translate
=
function
(
a
,
f
){
this
.
matrix
.
rotateAxis
(
f
);
if
(
this
.
noFly
)
f
.
y
=
0
;
this
.
position
.
addSelf
(
f
.
multiplyScalar
(
a
));
this
.
target
.
position
.
addSelf
(
f
.
multiplyScalar
(
a
))};
THREE
.
PathCamera
=
function
(
a
){
function
f
(
k
,
j
,
n
,
p
){
var
t
=
{
name
:
n
,
fps
:
0.6
,
length
:
p
,
hierarchy
:[]},
x
,
w
=
j
.
getControlPointsArray
(),
u
=
j
.
getLength
(),
B
=
w
.
length
,
y
=
0
;
x
=
B
-
1
;
j
=
{
parent
:
-
1
,
keys
:[]};
j
.
keys
[
0
]
=
{
time
:
0
,
pos
:
w
[
0
],
rot
:[
0
,
0
,
0
,
1
],
scl
:[
1
,
1
,
1
]};
j
.
keys
[
x
]
=
{
time
:
p
,
pos
:
w
[
x
],
rot
:[
0
,
0
,
0
,
1
],
scl
:[
1
,
1
,
1
]};
for
(
x
=
1
;
x
<
B
-
1
;
x
++
){
y
=
p
*
u
.
chunks
[
x
]
/
u
.
total
;
j
.
keys
[
x
]
=
{
time
:
y
,
pos
:
w
[
x
]}}
t
.
hierarchy
[
0
]
=
j
;
THREE
.
AnimationHandler
.
add
(
t
);
return
new
THREE
.
Animation
(
k
,
n
,
THREE
.
AnimationHandler
.
CATMULLROM_FORWARD
,
!
1
)}
function
b
(
k
,
j
){
var
n
,
p
,
t
=
new
THREE
.
Geometry
;
for
(
n
=
0
;
n
<
k
.
points
.
length
*
j
;
n
++
){
p
=
n
/
(
k
.
points
.
length
*
j
);
p
=
k
.
getPoint
(
p
);
t
.
vertices
[
n
]
=
new
THREE
.
Vertex
(
new
THREE
.
Vector3
(
p
.
x
,
p
.
y
,
p
.
z
))}
return
t
}
function
c
(
k
,
j
){
var
n
=
b
(
j
,
10
),
p
=
b
(
j
,
10
),
t
=
new
THREE
.
LineBasicMaterial
({
color
:
16711680
,
linewidth
:
3
});
lineObj
=
new
THREE
.
Line
(
n
,
t
);
particleObj
=
new
THREE
.
ParticleSystem
(
p
,
new
THREE
.
ParticleBasicMaterial
({
color
:
16755200
,
size
:
3
}));
lineObj
.
scale
.
set
(
1
,
1
,
1
);
k
.
addChild
(
lineObj
);
particleObj
.
scale
.
set
(
1
,
1
,
1
);
k
.
addChild
(
particleObj
);
p
=
new
Sphere
(
1
,
16
,
8
);
t
=
new
THREE
.
MeshBasicMaterial
({
color
:
65280
});
for
(
i
=
0
;
i
<
j
.
points
.
length
;
i
++
){
n
=
new
THREE
.
Mesh
(
p
,
t
);
n
.
position
.
copy
(
j
.
points
[
i
]);
n
.
updateMatrix
();
k
.
addChild
(
n
)}}
THREE
.
Camera
.
call
(
this
,
a
.
fov
,
a
.
aspect
,
a
.
near
,
a
.
far
,
a
.
target
);
this
.
id
=
"
PathCamera
"
+
THREE
.
PathCameraIdCounter
++
;
this
.
duration
=
1
E4
;
this
.
waypoints
=
[];
this
.
useConstantSpeed
=!
0
;
this
.
resamplingCoef
=
50
;
this
.
debugPath
=
new
THREE
.
Object3D
;
this
.
debugDummy
=
new
THREE
.
Object3D
;
this
.
animationParent
=
new
THREE
.
Object3D
;
this
.
lookSpeed
=
0.005
0
;
this
.
lookVertical
=
16
,
8
);
t
=
new
THREE
.
MeshBasicMaterial
({
color
:
65280
});
for
(
i
=
0
;
i
<
j
.
points
.
length
;
i
++
){
n
=
new
THREE
.
Mesh
(
p
,
t
);
n
.
position
.
copy
(
j
.
points
[
i
]);
n
.
updateMatrix
();
k
.
addChild
(
n
)}}
THREE
.
Camera
.
call
(
this
,
a
.
fov
,
a
.
aspect
,
a
.
near
,
a
.
far
,
a
.
target
);
this
.
id
=
"
PathCamera
"
+
THREE
.
PathCameraIdCounter
++
;
this
.
duration
=
1
E4
;
this
.
waypoints
=
[];
this
.
useConstantSpeed
=!
0
;
this
.
resamplingCoef
=
50
;
this
.
debugPath
=
new
THREE
.
Object3D
;
this
.
debugDummy
=
new
THREE
.
Object3D
;
this
.
animationParent
=
new
THREE
.
Object3D
;
this
.
lookSpeed
=
0.005
;
this
.
lookVertical
=
!
0
;
this
.
lookHorizontal
=!
0
;
this
.
verticalAngleMap
=
{
srcRange
:[
0
,
6.28
],
dstRange
:[
0
,
6.28
]};
this
.
horizontalAngleMap
=
{
srcRange
:[
0
,
6.28
],
dstRange
:[
0
,
6.28
]};
this
.
domElement
=
document
;
if
(
a
){
if
(
a
.
duration
!==
undefined
)
this
.
duration
=
a
.
duration
*
1
E3
;
if
(
a
.
waypoints
!==
undefined
)
this
.
waypoints
=
a
.
waypoints
;
if
(
a
.
useConstantSpeed
!==
undefined
)
this
.
useConstantSpeed
=
a
.
useConstantSpeed
;
if
(
a
.
resamplingCoef
!==
undefined
)
this
.
resamplingCoef
=
a
.
resamplingCoef
;
if
(
a
.
createDebugPath
!==
undefined
)
this
.
createDebugPath
=
a
.
createDebugPath
;
if
(
a
.
createDebugDummy
!==
undefined
)
this
.
createDebugDummy
=
a
.
createDebugDummy
;
if
(
a
.
lookSpeed
!==
undefined
)
this
.
lookSpeed
=
a
.
lookSpeed
;
if
(
a
.
lookVertical
!==
undefined
)
this
.
lookVertical
=
a
.
lookVertical
;
if
(
a
.
lookHorizontal
!==
undefined
)
this
.
lookHorizontal
=
a
.
lookHorizontal
;
if
(
a
.
verticalAngleMap
!==
undefined
)
this
.
verticalAngleMap
=
a
.
verticalAngleMap
;
if
(
a
.
horizontalAngleMap
!==
undefined
)
this
.
horizontalAngleMap
=
a
.
horizontalAngleMap
;
if
(
a
.
domElement
!==
undefined
)
this
.
domElement
=
a
.
domElement
}
this
.
theta
=
this
.
phi
=
this
.
lon
=
this
.
lat
=
this
.
mouseY
=
this
.
mouseX
=
0
;
this
.
windowHalfX
=
window
.
innerWidth
/
2
;
this
.
windowHalfY
=
window
.
innerHeight
/
2
;
var
e
=
Math
.
PI
*
2
,
d
=
Math
.
PI
/
180
;
this
.
update
=
function
(
k
,
j
,
n
){
var
p
,
t
;
this
.
lookHorizontal
&&
(
this
.
lon
+=
this
.
mouseX
*
this
.
lookSpeed
);
this
.
lookVertical
&&
(
this
.
lat
-=
this
.
mouseY
*
this
.
lookSpeed
);
this
.
lon
=
Math
.
max
(
0
,
Math
.
min
(
360
,
this
.
lon
));
this
.
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
this
.
lat
));
this
.
phi
=
(
90
-
this
.
lat
)
*
d
;
this
.
theta
=
this
.
lon
*
d
;
p
=
this
.
phi
%
e
;
this
.
phi
=
p
>=
0
?
p
:
p
+
e
;
p
=
this
.
verticalAngleMap
.
srcRange
;
t
=
this
.
verticalAngleMap
.
dstRange
;
...
...
@@ -50,7 +50,7 @@ for(c=a+a/2;c<2*a;c++)h.faces.push(new THREE.Face4(2*a+1,(2*c-2*a+2)%a+a,(2*c-2*
var
Icosahedron
=
function
(
a
){
function
f
(
n
,
p
,
t
){
var
x
=
Math
.
sqrt
(
n
*
n
+
p
*
p
+
t
*
t
);
return
e
.
vertices
.
push
(
new
THREE
.
Vertex
(
new
THREE
.
Vector3
(
n
/
x
,
p
/
x
,
t
/
x
)))
-
1
}
function
b
(
n
,
p
,
t
,
x
){
x
.
faces
.
push
(
new
THREE
.
Face3
(
n
,
p
,
t
))}
function
c
(
n
,
p
){
var
t
=
e
.
vertices
[
n
].
position
,
x
=
e
.
vertices
[
p
].
position
;
return
f
((
t
.
x
+
x
.
x
)
/
2
,(
t
.
y
+
x
.
y
)
/
2
,(
t
.
z
+
x
.
z
)
/
2
)}
var
e
=
this
,
d
=
new
THREE
.
Geometry
,
g
;
this
.
subdivisions
=
a
||
0
;
THREE
.
Geometry
.
call
(
this
);
a
=
(
1
+
Math
.
sqrt
(
5
))
/
2
;
f
(
-
1
,
a
,
0
);
f
(
1
,
a
,
0
);
f
(
-
1
,
-
a
,
0
);
f
(
1
,
-
a
,
0
);
f
(
0
,
-
1
,
a
);
f
(
0
,
1
,
a
);
f
(
0
,
-
1
,
-
a
);
f
(
0
,
1
,
-
a
);
f
(
a
,
0
,
-
1
);
f
(
a
,
0
,
1
);
f
(
-
a
,
0
,
-
1
);
f
(
-
a
,
0
,
1
);
b
(
0
,
11
,
5
,
d
);
b
(
0
,
5
,
1
,
d
);
b
(
0
,
1
,
7
,
d
);
b
(
0
,
7
,
10
,
d
);
b
(
0
,
10
,
11
,
d
);
b
(
1
,
5
,
9
,
d
);
b
(
5
,
11
,
4
,
d
);
b
(
11
,
10
,
2
,
d
);
b
(
10
,
7
,
6
,
d
);
b
(
7
,
1
,
8
,
d
);
b
(
3
,
9
,
4
,
d
);
b
(
3
,
4
,
2
,
d
);
b
(
3
,
2
,
6
,
d
);
b
(
3
,
6
,
8
,
d
);
b
(
3
,
8
,
9
,
d
);
b
(
4
,
9
,
5
,
d
);
b
(
2
,
4
,
11
,
d
);
b
(
6
,
2
,
10
,
d
);
b
(
8
,
6
,
7
,
d
);
b
(
9
,
8
,
1
,
d
);
for
(
a
=
0
;
a
<
this
.
subdivisions
;
a
++
){
g
=
new
THREE
.
Geometry
;
for
(
var
h
in
d
.
faces
){
var
m
=
c
(
d
.
faces
[
h
].
a
,
d
.
faces
[
h
].
b
),
k
=
c
(
d
.
faces
[
h
].
b
,
d
.
faces
[
h
].
c
),
j
=
c
(
d
.
faces
[
h
].
c
,
d
.
faces
[
h
].
a
);
b
(
d
.
faces
[
h
].
a
,
m
,
j
,
g
);
b
(
d
.
faces
[
h
].
b
,
k
,
m
,
g
);
b
(
d
.
faces
[
h
].
c
,
j
,
k
,
g
);
b
(
m
,
k
,
j
,
g
)}
d
.
faces
=
g
.
faces
}
e
.
faces
=
d
.
faces
;
delete
d
;
delete
g
;
this
.
computeCentroids
();
this
.
computeFaceNormals
();
this
.
computeVertexNormals
()};
Icosahedron
.
prototype
=
new
THREE
.
Geometry
;
Icosahedron
.
prototype
.
constructor
=
Icosahedron
;
function
Lathe
(
a
,
f
,
b
){
THREE
.
Geometry
.
call
(
this
);
this
.
steps
=
f
||
12
;
this
.
angle
=
b
||
2
*
Math
.
PI
;
f
=
this
.
angle
/
this
.
steps
;
for
(
var
c
=
[],
e
=
[],
d
=
[],
g
=
[],
h
=
0
;
h
<
a
.
length
;
h
++
){
this
.
vertices
.
push
(
new
THREE
.
Vertex
(
a
[
h
]));
c
[
h
]
=
a
[
h
].
clone
();
e
[
h
]
=
this
.
vertices
.
length
-
1
}
for
(
var
m
=
(
new
THREE
.
Matrix4
).
setRotationZ
(
f
),
k
=
0
;
k
<=
this
.
angle
+
0.001
0
;
k
+=
f
){
for
(
h
=
0
;
h
<
c
.
length
;
h
++
)
if
(
k
<
this
.
angle
){
c
[
h
]
=
m
.
multiplyVector3
(
c
[
h
].
clone
());
this
.
vertices
.
push
(
new
THREE
.
Vertex
(
c
[
h
]));
d
[
h
]
=
this
.
vertices
.
length
-
1
}
else
d
=
g
;
k
==
0
&&
(
g
=
e
);
for
(
h
=
function
Lathe
(
a
,
f
,
b
){
THREE
.
Geometry
.
call
(
this
);
this
.
steps
=
f
||
12
;
this
.
angle
=
b
||
2
*
Math
.
PI
;
f
=
this
.
angle
/
this
.
steps
;
for
(
var
c
=
[],
e
=
[],
d
=
[],
g
=
[],
h
=
0
;
h
<
a
.
length
;
h
++
){
this
.
vertices
.
push
(
new
THREE
.
Vertex
(
a
[
h
]));
c
[
h
]
=
a
[
h
].
clone
();
e
[
h
]
=
this
.
vertices
.
length
-
1
}
for
(
var
m
=
(
new
THREE
.
Matrix4
).
setRotationZ
(
f
),
k
=
0
;
k
<=
this
.
angle
+
0.001
;
k
+=
f
){
for
(
h
=
0
;
h
<
c
.
length
;
h
++
)
if
(
k
<
this
.
angle
){
c
[
h
]
=
m
.
multiplyVector3
(
c
[
h
].
clone
());
this
.
vertices
.
push
(
new
THREE
.
Vertex
(
c
[
h
]));
d
[
h
]
=
this
.
vertices
.
length
-
1
}
else
d
=
g
;
k
==
0
&&
(
g
=
e
);
for
(
h
=
0
;
h
<
e
.
length
-
1
;
h
++
){
this
.
faces
.
push
(
new
THREE
.
Face4
(
d
[
h
],
d
[
h
+
1
],
e
[
h
+
1
],
e
[
h
]));
this
.
faceVertexUvs
[
0
].
push
([
new
THREE
.
UV
(
k
/
b
,
h
/
a
.
length
),
new
THREE
.
UV
(
k
/
b
,(
h
+
1
)
/
a
.
length
),
new
THREE
.
UV
((
k
-
f
)
/
b
,(
h
+
1
)
/
a
.
length
),
new
THREE
.
UV
((
k
-
f
)
/
b
,
h
/
a
.
length
)])}
e
=
d
;
d
=
[]}
this
.
computeCentroids
();
this
.
computeFaceNormals
();
this
.
computeVertexNormals
()}
Lathe
.
prototype
=
new
THREE
.
Geometry
;
Lathe
.
prototype
.
constructor
=
Lathe
;
var
Plane
=
function
(
a
,
f
,
b
,
c
){
THREE
.
Geometry
.
call
(
this
);
var
e
,
d
=
a
/
2
,
g
=
f
/
2
;
b
=
b
||
1
;
c
=
c
||
1
;
var
h
=
b
+
1
,
m
=
c
+
1
;
a
/=
b
;
var
k
=
f
/
c
;
for
(
e
=
0
;
e
<
m
;
e
++
)
for
(
f
=
0
;
f
<
h
;
f
++
)
this
.
vertices
.
push
(
new
THREE
.
Vertex
(
new
THREE
.
Vector3
(
f
*
a
-
d
,
-
(
e
*
k
-
g
),
0
)));
for
(
e
=
0
;
e
<
c
;
e
++
)
for
(
f
=
0
;
f
<
b
;
f
++
){
this
.
faces
.
push
(
new
THREE
.
Face4
(
f
+
h
*
e
,
f
+
h
*
(
e
+
1
),
f
+
1
+
h
*
(
e
+
1
),
f
+
1
+
h
*
e
));
this
.
faceVertexUvs
[
0
].
push
([
new
THREE
.
UV
(
f
/
b
,
e
/
c
),
new
THREE
.
UV
(
f
/
b
,(
e
+
1
)
/
c
),
new
THREE
.
UV
((
f
+
1
)
/
b
,(
e
+
1
)
/
c
),
new
THREE
.
UV
((
f
+
1
)
/
b
,
e
/
c
)])}
this
.
computeCentroids
();
this
.
computeFaceNormals
()};
Plane
.
prototype
=
new
THREE
.
Geometry
;
Plane
.
prototype
.
constructor
=
Plane
;
...
...
build/custom/ThreeSVG.js
浏览文件 @
29da25e7
...
...
@@ -48,7 +48,7 @@ b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?
THREE
.
Quaternion
.
prototype
=
{
set
:
function
(
a
,
b
,
c
,
e
){
this
.
x
=
a
;
this
.
y
=
b
;
this
.
z
=
c
;
this
.
w
=
e
;
return
this
},
setFromEuler
:
function
(
a
){
var
b
=
0.5
*
Math
.
PI
/
360
,
c
=
a
.
x
*
b
,
e
=
a
.
y
*
b
,
d
=
a
.
z
*
b
;
a
=
Math
.
cos
(
e
);
e
=
Math
.
sin
(
e
);
b
=
Math
.
cos
(
-
d
);
d
=
Math
.
sin
(
-
d
);
var
f
=
Math
.
cos
(
c
);
c
=
Math
.
sin
(
c
);
var
g
=
a
*
b
,
i
=
e
*
d
;
this
.
w
=
g
*
f
-
i
*
c
;
this
.
x
=
g
*
c
+
i
*
f
;
this
.
y
=
e
*
b
*
f
+
a
*
d
*
c
;
this
.
z
=
a
*
d
*
f
-
e
*
b
*
c
;
return
this
},
calculateW
:
function
(){
this
.
w
=-
Math
.
sqrt
(
Math
.
abs
(
1
-
this
.
x
*
this
.
x
-
this
.
y
*
this
.
y
-
this
.
z
*
this
.
z
));
return
this
},
inverse
:
function
(){
this
.
x
*=-
1
;
this
.
y
*=
-
1
;
this
.
z
*=-
1
;
return
this
},
length
:
function
(){
return
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
+
this
.
w
*
this
.
w
)},
normalize
:
function
(){
var
a
=
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
+
this
.
w
*
this
.
w
);
if
(
a
==
0
)
this
.
w
=
this
.
z
=
this
.
y
=
this
.
x
=
0
;
else
{
a
=
1
/
a
;
this
.
x
*=
a
;
this
.
y
*=
a
;
this
.
z
*=
a
;
this
.
w
*=
a
}
return
this
},
multiplySelf
:
function
(
a
){
var
b
=
this
.
x
,
c
=
this
.
y
,
e
=
this
.
z
,
d
=
this
.
w
,
f
=
a
.
x
,
g
=
a
.
y
,
i
=
a
.
z
;
a
=
a
.
w
;
this
.
x
=
b
*
a
+
d
*
f
+
c
*
i
-
e
*
g
;
this
.
y
=
c
*
a
+
d
*
g
+
e
*
f
-
b
*
i
;
this
.
z
=
e
*
a
+
d
*
i
+
b
*
g
-
c
*
f
;
this
.
w
=
d
*
a
-
b
*
f
-
c
*
g
-
e
*
i
;
return
this
},
multiplyVector3
:
function
(
a
,
b
){
b
||
(
b
=
a
);
var
c
=
a
.
x
,
e
=
a
.
y
,
d
=
a
.
z
,
f
=
this
.
x
,
g
=
this
.
y
,
i
=
this
.
z
,
h
=
this
.
w
,
j
=
h
*
c
+
g
*
d
-
i
*
e
,
m
=
h
*
e
+
i
*
c
-
f
*
d
,
l
=
h
*
d
+
f
*
e
-
g
*
c
;
c
=-
f
*
c
-
g
*
e
-
i
*
d
;
b
.
x
=
j
*
h
+
c
*-
f
+
m
*-
i
-
l
*-
g
;
b
.
y
=
m
*
h
+
c
*-
g
+
l
*-
f
-
j
*-
i
;
b
.
z
=
l
*
h
+
c
*-
i
+
j
*-
g
-
m
*-
f
;
return
b
}};
THREE
.
Quaternion
.
slerp
=
function
(
a
,
b
,
c
,
e
){
var
d
=
a
.
w
*
b
.
w
+
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
+
a
.
z
*
b
.
z
;
if
(
Math
.
abs
(
d
)
>=
1
){
c
.
w
=
a
.
w
;
c
.
x
=
a
.
x
;
c
.
y
=
a
.
y
;
c
.
z
=
a
.
z
;
return
c
}
var
f
=
Math
.
acos
(
d
),
g
=
Math
.
sqrt
(
1
-
d
*
d
);
if
(
Math
.
abs
(
g
)
<
0.001
0
){
c
.
w
=
0.5
*
(
a
.
w
+
b
.
w
);
c
.
x
=
0.5
*
(
a
.
x
+
b
.
x
);
c
.
y
=
0.5
*
(
a
.
y
+
b
.
y
);
c
.
z
=
0.5
*
(
a
.
z
+
b
.
z
);
return
c
}
d
=
Math
.
sin
((
1
-
e
)
*
f
)
/
g
;
e
=
Math
.
sin
(
e
*
f
)
/
g
;
c
.
w
=
a
.
w
*
d
+
b
.
w
*
e
;
c
.
x
=
a
.
x
*
d
+
b
.
x
*
e
;
c
.
y
=
a
.
y
*
d
+
b
.
y
*
e
;
c
.
z
=
a
.
z
*
d
+
b
.
z
*
e
;
return
c
};
THREE
.
Vertex
=
function
(
a
){
this
.
position
=
a
||
new
THREE
.
Vector3
};
THREE
.
Quaternion
.
slerp
=
function
(
a
,
b
,
c
,
e
){
var
d
=
a
.
w
*
b
.
w
+
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
+
a
.
z
*
b
.
z
;
if
(
Math
.
abs
(
d
)
>=
1
){
c
.
w
=
a
.
w
;
c
.
x
=
a
.
x
;
c
.
y
=
a
.
y
;
c
.
z
=
a
.
z
;
return
c
}
var
f
=
Math
.
acos
(
d
),
g
=
Math
.
sqrt
(
1
-
d
*
d
);
if
(
Math
.
abs
(
g
)
<
0.001
){
c
.
w
=
0.5
*
(
a
.
w
+
b
.
w
);
c
.
x
=
0.5
*
(
a
.
x
+
b
.
x
);
c
.
y
=
0.5
*
(
a
.
y
+
b
.
y
);
c
.
z
=
0.5
*
(
a
.
z
+
b
.
z
);
return
c
}
d
=
Math
.
sin
((
1
-
e
)
*
f
)
/
g
;
e
=
Math
.
sin
(
e
*
f
)
/
g
;
c
.
w
=
a
.
w
*
d
+
b
.
w
*
e
;
c
.
x
=
a
.
x
*
d
+
b
.
x
*
e
;
c
.
y
=
a
.
y
*
d
+
b
.
y
*
e
;
c
.
z
=
a
.
z
*
d
+
b
.
z
*
e
;
return
c
};
THREE
.
Vertex
=
function
(
a
){
this
.
position
=
a
||
new
THREE
.
Vector3
};
THREE
.
Face3
=
function
(
a
,
b
,
c
,
e
,
d
,
f
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
normal
=
e
instanceof
THREE
.
Vector3
?
e
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
e
instanceof
Array
?
e
:[];
this
.
color
=
d
instanceof
THREE
.
Color
?
d
:
new
THREE
.
Color
;
this
.
vertexColors
=
d
instanceof
Array
?
d
:[];
this
.
vertexTangents
=
[];
this
.
materials
=
f
instanceof
Array
?
f
:[
f
];
this
.
centroid
=
new
THREE
.
Vector3
};
THREE
.
Face4
=
function
(
a
,
b
,
c
,
e
,
d
,
f
,
g
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
d
=
e
;
this
.
normal
=
d
instanceof
THREE
.
Vector3
?
d
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
d
instanceof
Array
?
d
:[];
this
.
color
=
f
instanceof
THREE
.
Color
?
f
:
new
THREE
.
Color
;
this
.
vertexColors
=
f
instanceof
Array
?
f
:[];
this
.
vertexTangents
=
[];
this
.
materials
=
g
instanceof
Array
?
g
:[
g
];
this
.
centroid
=
new
THREE
.
Vector3
};
THREE
.
UV
=
function
(
a
,
b
){
this
.
set
(
a
||
0
,
b
||
0
)};
THREE
.
UV
.
prototype
=
{
set
:
function
(
a
,
b
){
this
.
u
=
a
;
this
.
v
=
b
;
return
this
},
copy
:
function
(
a
){
this
.
set
(
a
.
u
,
a
.
v
);
return
this
}};
THREE
.
Geometry
=
function
(){
this
.
id
=
"
Geometry
"
+
THREE
.
GeometryIdCounter
++
;
this
.
vertices
=
[];
this
.
colors
=
[];
this
.
faces
=
[];
this
.
faceUvs
=
[[]];
this
.
faceVertexUvs
=
[[]];
this
.
morphTargets
=
[];
this
.
skinWeights
=
[];
this
.
skinIndices
=
[];
this
.
boundingSphere
=
this
.
boundingBox
=
null
;
this
.
hasTangents
=!
1
};
...
...
build/custom/ThreeWebGL.js
浏览文件 @
29da25e7
此差异已折叠。
点击以展开。
src/renderers/WebGLRenderer.js
浏览文件 @
29da25e7
...
...
@@ -22,6 +22,7 @@ THREE.WebGLRenderer = function ( parameters ) {
var
_gl
,
_canvas
=
document
.
createElement
(
'
canvas
'
),
_programs
=
[],
_currentProgram
=
null
,
_currentFramebuffer
=
null
,
_currentDepthMask
=
true
,
...
...
@@ -3761,7 +3762,34 @@ THREE.WebGLRenderer = function ( parameters ) {
function
buildProgram
(
fragmentShader
,
vertexShader
,
parameters
)
{
var
program
=
_gl
.
createProgram
(),
var
p
,
pl
,
program
,
code
;
// Generate code
code
=
fragmentShader
+
"
\n\n
"
+
vertexShader
+
"
\n\n
"
;
for
(
p
in
parameters
)
{
code
+=
p
+
"
:
"
+
parameters
[
p
]
+
"
,
\n
"
;
}
// Check if code has been already compiled
for
(
p
=
0
,
pl
=
_programs
.
length
;
p
<
pl
;
p
++
)
{
if
(
_programs
[
p
].
code
==
code
)
{
// console.log( "Code already compiled." /*: \n\n" + code*/ );
return
_programs
[
p
].
program
;
}
}
//
program
=
_gl
.
createProgram
(),
prefix_fragment
=
[
"
#ifdef GL_ES
"
,
...
...
@@ -3864,6 +3892,8 @@ THREE.WebGLRenderer = function ( parameters ) {
program
.
uniforms
=
{};
program
.
attributes
=
{};
_programs
.
push
(
{
program
:
program
,
code
:
code
}
);
return
program
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录