Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
10e21dde
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,发现更多精彩内容 >>
提交
10e21dde
编写于
12月 08, 2010
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
`Geometry::computeNormals` → `Geometry::computeFaceNormals`
上级
1053ab24
变更
15
展开全部
显示空白变更内容
内联
并排
Showing
15 changed file
with
614 addition
and
620 deletion
+614
-620
build/Three.js
build/Three.js
+172
-172
build/ThreeDebug.js
build/ThreeDebug.js
+173
-173
build/ThreeExtras.js
build/ThreeExtras.js
+212
-212
examples/geometry_terrain.html
examples/geometry_terrain.html
+0
-1
examples/geometry_terrain_gl.html
examples/geometry_terrain_gl.html
+0
-4
examples/obj/Bird.js
examples/obj/Bird.js
+2
-2
examples/obj/Qrcode.js
examples/obj/Qrcode.js
+1
-1
examples/obj/WaltHead.js
examples/obj/WaltHead.js
+2
-2
examples/uqbiquity_test.html
examples/uqbiquity_test.html
+1
-1
src/core/Geometry.js
src/core/Geometry.js
+1
-1
src/extras/io/Loader.js
src/extras/io/Loader.js
+2
-2
src/extras/primitives/Cube.js
src/extras/primitives/Cube.js
+9
-9
src/extras/primitives/Cylinder.js
src/extras/primitives/Cylinder.js
+31
-33
src/extras/primitives/Plane.js
src/extras/primitives/Plane.js
+1
-1
src/extras/primitives/Sphere.js
src/extras/primitives/Sphere.js
+7
-6
未找到文件。
build/Three.js
浏览文件 @
10e21dde
...
...
@@ -44,7 +44,7 @@ THREE.Face3=function(a,b,d,g,j){this.a=a;this.b=b;this.c=d;this.centroid=new THR
THREE
.
Face4
=
function
(
a
,
b
,
d
,
g
,
j
,
n
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
d
;
this
.
d
=
g
;
this
.
centroid
=
new
THREE
.
Vector3
;
this
.
normal
=
j
instanceof
THREE
.
Vector3
?
j
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
j
instanceof
Array
?
j
:[];
this
.
material
=
n
instanceof
Array
?
n
:[
n
]};
THREE
.
Face4
.
prototype
=
{
toString
:
function
(){
return
"
THREE.Face4 (
"
+
this
.
a
+
"
,
"
+
this
.
b
+
"
,
"
+
this
.
c
+
"
"
+
this
.
d
+
"
)
"
}};
THREE
.
UV
=
function
(
a
,
b
){
this
.
u
=
a
||
0
;
this
.
v
=
b
||
0
};
THREE
.
UV
.
prototype
=
{
copy
:
function
(
a
){
this
.
u
=
a
.
u
;
this
.
v
=
a
.
v
},
toString
:
function
(){
return
"
THREE.UV (
"
+
this
.
u
+
"
,
"
+
this
.
v
+
"
)
"
}};
THREE
.
Geometry
=
function
(){
this
.
vertices
=
[];
this
.
faces
=
[];
this
.
uvs
=
[];
this
.
geometryChunks
=
{}};
THREE
.
Geometry
.
prototype
=
{
computeCentroids
:
function
(){
var
a
,
b
,
d
;
a
=
0
;
for
(
b
=
this
.
faces
.
length
;
a
<
b
;
a
++
){
d
=
this
.
faces
[
a
];
d
.
centroid
.
set
(
0
,
0
,
0
);
if
(
d
instanceof
THREE
.
Face3
){
d
.
centroid
.
addSelf
(
this
.
vertices
[
d
.
a
].
position
);
d
.
centroid
.
addSelf
(
this
.
vertices
[
d
.
b
].
position
);
d
.
centroid
.
addSelf
(
this
.
vertices
[
d
.
c
].
position
);
d
.
centroid
.
divideScalar
(
3
)}
else
if
(
d
instanceof
THREE
.
Face4
){
d
.
centroid
.
addSelf
(
this
.
vertices
[
d
.
a
].
position
);
d
.
centroid
.
addSelf
(
this
.
vertices
[
d
.
b
].
position
);
d
.
centroid
.
addSelf
(
this
.
vertices
[
d
.
c
].
position
);
d
.
centroid
.
addSelf
(
this
.
vertices
[
d
.
d
].
position
);
d
.
centroid
.
divideScalar
(
4
)}}},
compute
Normals
:
function
(
a
){
var
b
,
d
,
g
,
j
,
n
,
m
,
l
=
new
THREE
.
Vector3
,
o
=
new
THREE
.
Vector3
;
g
=
0
;
for
(
j
=
this
.
vertices
.
length
;
g
<
j
;
g
++
){
n
=
this
.
vertices
[
g
];
n
.
normal
.
set
(
0
,
0
,
0
)}
g
=
0
;
for
(
j
=
this
.
faces
.
length
;
g
<
j
;
g
++
){
n
=
this
.
faces
[
g
];
if
(
a
&&
n
.
vertexNormals
.
length
){
l
.
set
(
0
,
0
,
0
);
b
=
0
;
for
(
d
=
n
.
normal
.
length
;
b
<
d
;
b
++
)
l
.
addSelf
(
n
.
vertexNormals
[
b
]);
l
.
divideScalar
(
3
)}
else
{
b
=
this
.
vertices
[
n
.
a
];
d
=
this
.
vertices
[
n
.
b
];
m
=
this
.
vertices
[
n
.
c
];
l
.
sub
(
m
.
position
,
d
.
centroid
.
addSelf
(
this
.
vertices
[
d
.
d
].
position
);
d
.
centroid
.
divideScalar
(
4
)}}},
compute
FaceNormals
:
function
(
a
){
var
b
,
d
,
g
,
j
,
n
,
m
,
l
=
new
THREE
.
Vector3
,
o
=
new
THREE
.
Vector3
;
g
=
0
;
for
(
j
=
this
.
vertices
.
length
;
g
<
j
;
g
++
){
n
=
this
.
vertices
[
g
];
n
.
normal
.
set
(
0
,
0
,
0
)}
g
=
0
;
for
(
j
=
this
.
faces
.
length
;
g
<
j
;
g
++
){
n
=
this
.
faces
[
g
];
if
(
a
&&
n
.
vertexNormals
.
length
){
l
.
set
(
0
,
0
,
0
);
b
=
0
;
for
(
d
=
n
.
normal
.
length
;
b
<
d
;
b
++
)
l
.
addSelf
(
n
.
vertexNormals
[
b
]);
l
.
divideScalar
(
3
)}
else
{
b
=
this
.
vertices
[
n
.
a
];
d
=
this
.
vertices
[
n
.
b
];
m
=
this
.
vertices
[
n
.
c
];
l
.
sub
(
m
.
position
,
d
.
position
);
o
.
sub
(
b
.
position
,
d
.
position
);
l
.
crossSelf
(
o
)}
l
.
isZero
()
||
l
.
normalize
();
n
.
normal
.
copy
(
l
)}},
computeVertexNormals
:
function
(){
var
a
,
b
=
[],
d
,
g
;
a
=
0
;
for
(
vl
=
this
.
vertices
.
length
;
a
<
vl
;
a
++
)
b
[
a
]
=
new
THREE
.
Vector3
;
a
=
0
;
for
(
d
=
this
.
faces
.
length
;
a
<
d
;
a
++
){
g
=
this
.
faces
[
a
];
if
(
g
instanceof
THREE
.
Face3
){
b
[
g
.
a
].
addSelf
(
g
.
normal
);
b
[
g
.
b
].
addSelf
(
g
.
normal
);
b
[
g
.
c
].
addSelf
(
g
.
normal
)}
else
if
(
g
instanceof
THREE
.
Face4
){
b
[
g
.
a
].
addSelf
(
g
.
normal
);
b
[
g
.
b
].
addSelf
(
g
.
normal
);
b
[
g
.
c
].
addSelf
(
g
.
normal
);
b
[
g
.
d
].
addSelf
(
g
.
normal
)}}
a
=
0
;
for
(
vl
=
this
.
vertices
.
length
;
a
<
vl
;
a
++
)
b
[
a
].
normalize
();
a
=
0
;
for
(
d
=
this
.
faces
.
length
;
a
<
d
;
a
++
){
g
=
this
.
faces
[
a
];
if
(
g
instanceof
THREE
.
Face3
){
g
.
vertexNormals
[
0
]
=
b
[
g
.
a
].
clone
();
g
.
vertexNormals
[
1
]
=
b
[
g
.
b
].
clone
();
g
.
vertexNormals
[
2
]
=
b
[
g
.
c
].
clone
()}
else
if
(
g
instanceof
THREE
.
Face4
){
g
.
vertexNormals
[
0
]
=
b
[
g
.
a
].
clone
();
g
.
vertexNormals
[
1
]
=
b
[
g
.
b
].
clone
();
g
.
vertexNormals
[
2
]
=
b
[
g
.
c
].
clone
();
g
.
vertexNormals
[
3
]
=
b
[
g
.
d
].
clone
()}}},
computeBoundingBox
:
function
(){
if
(
this
.
vertices
.
length
>
0
){
this
.
bbox
=
{
x
:[
this
.
vertices
[
0
].
position
.
x
,
this
.
vertices
[
0
].
position
.
x
],
y
:[
this
.
vertices
[
0
].
position
.
y
,
this
.
vertices
[
0
].
position
.
y
],
z
:[
this
.
vertices
[
0
].
position
.
z
,
this
.
vertices
[
0
].
position
.
z
]};
for
(
var
a
=
1
,
b
=
this
.
vertices
.
length
;
a
<
b
;
a
++
){
vertex
=
this
.
vertices
[
a
];
if
(
vertex
.
position
.
x
<
this
.
bbox
.
x
[
0
])
this
.
bbox
.
x
[
0
]
=
vertex
.
position
.
x
;
else
if
(
vertex
.
position
.
x
>
this
.
bbox
.
x
[
1
])
this
.
bbox
.
x
[
1
]
=
vertex
.
position
.
x
;
if
(
vertex
.
position
.
y
<
this
.
bbox
.
y
[
0
])
this
.
bbox
.
y
[
0
]
=
vertex
.
position
.
y
;
else
if
(
vertex
.
position
.
y
>
this
.
bbox
.
y
[
1
])
this
.
bbox
.
y
[
1
]
=
vertex
.
position
.
y
;
...
...
build/ThreeDebug.js
浏览文件 @
10e21dde
...
...
@@ -44,7 +44,7 @@ THREE.Face3=function(a,b,d,g,j){this.a=a;this.b=b;this.c=d;this.centroid=new THR
THREE
.
Face4
=
function
(
a
,
b
,
d
,
g
,
j
,
n
){
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
d
;
this
.
d
=
g
;
this
.
centroid
=
new
THREE
.
Vector3
;
this
.
normal
=
j
instanceof
THREE
.
Vector3
?
j
:
new
THREE
.
Vector3
;
this
.
vertexNormals
=
j
instanceof
Array
?
j
:[];
this
.
material
=
n
instanceof
Array
?
n
:[
n
]};
THREE
.
Face4
.
prototype
=
{
toString
:
function
(){
return
"
THREE.Face4 (
"
+
this
.
a
+
"
,
"
+
this
.
b
+
"
,
"
+
this
.
c
+
"
"
+
this
.
d
+
"
)
"
}};
THREE
.
UV
=
function
(
a
,
b
){
this
.
u
=
a
||
0
;
this
.
v
=
b
||
0
};
THREE
.
UV
.
prototype
=
{
copy
:
function
(
a
){
this
.
u
=
a
.
u
;
this
.
v
=
a
.
v
},
toString
:
function
(){
return
"
THREE.UV (
"
+
this
.
u
+
"
,
"
+
this
.
v
+
"
)
"
}};
THREE
.
Geometry
=
function
(){
this
.
vertices
=
[];
this
.
faces
=
[];
this
.
uvs
=
[];
this
.
geometryChunks
=
{}};
THREE
.
Geometry
.
prototype
=
{
computeCentroids
:
function
(){
var
a
,
b
,
d
;
a
=
0
;
for
(
b
=
this
.
faces
.
length
;
a
<
b
;
a
++
){
d
=
this
.
faces
[
a
];
d
.
centroid
.
set
(
0
,
0
,
0
);
if
(
d
instanceof
THREE
.
Face3
){
d
.
centroid
.
addSelf
(
this
.
vertices
[
d
.
a
].
position
);
d
.
centroid
.
addSelf
(
this
.
vertices
[
d
.
b
].
position
);
d
.
centroid
.
addSelf
(
this
.
vertices
[
d
.
c
].
position
);
d
.
centroid
.
divideScalar
(
3
)}
else
if
(
d
instanceof
THREE
.
Face4
){
d
.
centroid
.
addSelf
(
this
.
vertices
[
d
.
a
].
position
);
d
.
centroid
.
addSelf
(
this
.
vertices
[
d
.
b
].
position
);
d
.
centroid
.
addSelf
(
this
.
vertices
[
d
.
c
].
position
);
d
.
centroid
.
addSelf
(
this
.
vertices
[
d
.
d
].
position
);
d
.
centroid
.
divideScalar
(
4
)}}},
compute
Normals
:
function
(
a
){
var
b
,
d
,
g
,
j
,
n
,
m
,
k
=
new
THREE
.
Vector3
,
o
=
new
THREE
.
Vector3
;
g
=
0
;
for
(
j
=
this
.
vertices
.
length
;
g
<
j
;
g
++
){
n
=
this
.
vertices
[
g
];
n
.
normal
.
set
(
0
,
0
,
0
)}
g
=
0
;
for
(
j
=
this
.
faces
.
length
;
g
<
j
;
g
++
){
n
=
this
.
faces
[
g
];
if
(
a
&&
n
.
vertexNormals
.
length
){
k
.
set
(
0
,
0
,
0
);
b
=
0
;
for
(
d
=
n
.
normal
.
length
;
b
<
d
;
b
++
)
k
.
addSelf
(
n
.
vertexNormals
[
b
]);
k
.
divideScalar
(
3
)}
else
{
b
=
this
.
vertices
[
n
.
a
];
d
=
this
.
vertices
[
n
.
b
];
m
=
this
.
vertices
[
n
.
c
];
k
.
sub
(
m
.
position
,
d
.
centroid
.
addSelf
(
this
.
vertices
[
d
.
d
].
position
);
d
.
centroid
.
divideScalar
(
4
)}}},
compute
FaceNormals
:
function
(
a
){
var
b
,
d
,
g
,
j
,
n
,
m
,
k
=
new
THREE
.
Vector3
,
o
=
new
THREE
.
Vector3
;
g
=
0
;
for
(
j
=
this
.
vertices
.
length
;
g
<
j
;
g
++
){
n
=
this
.
vertices
[
g
];
n
.
normal
.
set
(
0
,
0
,
0
)}
g
=
0
;
for
(
j
=
this
.
faces
.
length
;
g
<
j
;
g
++
){
n
=
this
.
faces
[
g
];
if
(
a
&&
n
.
vertexNormals
.
length
){
k
.
set
(
0
,
0
,
0
);
b
=
0
;
for
(
d
=
n
.
normal
.
length
;
b
<
d
;
b
++
)
k
.
addSelf
(
n
.
vertexNormals
[
b
]);
k
.
divideScalar
(
3
)}
else
{
b
=
this
.
vertices
[
n
.
a
];
d
=
this
.
vertices
[
n
.
b
];
m
=
this
.
vertices
[
n
.
c
];
k
.
sub
(
m
.
position
,
d
.
position
);
o
.
sub
(
b
.
position
,
d
.
position
);
k
.
crossSelf
(
o
)}
k
.
isZero
()
||
k
.
normalize
();
n
.
normal
.
copy
(
k
)}},
computeVertexNormals
:
function
(){
var
a
,
b
=
[],
d
,
g
;
a
=
0
;
for
(
vl
=
this
.
vertices
.
length
;
a
<
vl
;
a
++
)
b
[
a
]
=
new
THREE
.
Vector3
;
a
=
0
;
for
(
d
=
this
.
faces
.
length
;
a
<
d
;
a
++
){
g
=
this
.
faces
[
a
];
if
(
g
instanceof
THREE
.
Face3
){
b
[
g
.
a
].
addSelf
(
g
.
normal
);
b
[
g
.
b
].
addSelf
(
g
.
normal
);
b
[
g
.
c
].
addSelf
(
g
.
normal
)}
else
if
(
g
instanceof
THREE
.
Face4
){
b
[
g
.
a
].
addSelf
(
g
.
normal
);
b
[
g
.
b
].
addSelf
(
g
.
normal
);
b
[
g
.
c
].
addSelf
(
g
.
normal
);
b
[
g
.
d
].
addSelf
(
g
.
normal
)}}
a
=
0
;
for
(
vl
=
this
.
vertices
.
length
;
a
<
vl
;
a
++
)
b
[
a
].
normalize
();
a
=
0
;
for
(
d
=
this
.
faces
.
length
;
a
<
d
;
a
++
){
g
=
this
.
faces
[
a
];
if
(
g
instanceof
THREE
.
Face3
){
g
.
vertexNormals
[
0
]
=
b
[
g
.
a
].
clone
();
g
.
vertexNormals
[
1
]
=
b
[
g
.
b
].
clone
();
g
.
vertexNormals
[
2
]
=
b
[
g
.
c
].
clone
()}
else
if
(
g
instanceof
THREE
.
Face4
){
g
.
vertexNormals
[
0
]
=
b
[
g
.
a
].
clone
();
g
.
vertexNormals
[
1
]
=
b
[
g
.
b
].
clone
();
g
.
vertexNormals
[
2
]
=
b
[
g
.
c
].
clone
();
g
.
vertexNormals
[
3
]
=
b
[
g
.
d
].
clone
()}}},
computeBoundingBox
:
function
(){
if
(
this
.
vertices
.
length
>
0
){
this
.
bbox
=
{
x
:[
this
.
vertices
[
0
].
position
.
x
,
this
.
vertices
[
0
].
position
.
x
],
y
:[
this
.
vertices
[
0
].
position
.
y
,
this
.
vertices
[
0
].
position
.
y
],
z
:[
this
.
vertices
[
0
].
position
.
z
,
this
.
vertices
[
0
].
position
.
z
]};
for
(
var
a
=
1
,
b
=
this
.
vertices
.
length
;
a
<
b
;
a
++
){
vertex
=
this
.
vertices
[
a
];
if
(
vertex
.
position
.
x
<
this
.
bbox
.
x
[
0
])
this
.
bbox
.
x
[
0
]
=
vertex
.
position
.
x
;
else
if
(
vertex
.
position
.
x
>
this
.
bbox
.
x
[
1
])
this
.
bbox
.
x
[
1
]
=
vertex
.
position
.
x
;
if
(
vertex
.
position
.
y
<
this
.
bbox
.
y
[
0
])
this
.
bbox
.
y
[
0
]
=
vertex
.
position
.
y
;
else
if
(
vertex
.
position
.
y
>
this
.
bbox
.
y
[
1
])
this
.
bbox
.
y
[
1
]
=
vertex
.
position
.
y
;
...
...
build/ThreeExtras.js
浏览文件 @
10e21dde
此差异已折叠。
点击以展开。
examples/geometry_terrain.html
浏览文件 @
10e21dde
...
...
@@ -80,7 +80,6 @@
}
plane
.
computeNormals
();
plane
.
computeCentroids
();
mesh
=
new
THREE
.
Mesh
(
plane
,
material
);
...
...
examples/geometry_terrain_gl.html
浏览文件 @
10e21dde
...
...
@@ -87,10 +87,6 @@
}
// geometry.computeNormals();
// geometry.computeVertexNormals();
// geometry.sortFacesByMaterial();
texture
=
new
THREE
.
Texture
(
generateTexture
(
data
,
worldWidth
,
worldDepth
),
new
THREE
.
UVMapping
(),
THREE
.
ClampToEdgeWrapping
,
THREE
.
ClampToEdgeWrapping
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
MeshBasicMaterial
(
{
map
:
texture
}
)
);
...
...
examples/obj/Bird.js
浏览文件 @
10e21dde
...
...
@@ -2,7 +2,7 @@ var Bird = function () {
var
scope
=
this
;
THREE
.
Geometry
.
call
(
this
);
THREE
.
Geometry
.
call
(
this
);
v
(
5
,
0
,
0
);
v
(
-
5
,
-
2
,
1
);
...
...
@@ -21,7 +21,7 @@ var Bird = function () {
f3
(
5
,
6
,
7
);
this
.
computeCentroids
();
this
.
computeNormals
();
this
.
compute
Face
Normals
();
this
.
sortFacesByMaterial
();
function
v
(
x
,
y
,
z
)
{
...
...
examples/obj/Qrcode.js
浏览文件 @
10e21dde
...
...
@@ -1434,7 +1434,7 @@ var Qrcode = function () {
f4
(
19
,
20
,
362
,
361
,
m2
);
this
.
computeCentroids
();
this
.
computeNormals
();
this
.
compute
Face
Normals
();
this
.
sortFacesByMaterial
();
function
v
(
x
,
y
,
z
)
{
...
...
examples/obj/WaltHead.js
浏览文件 @
10e21dde
...
...
@@ -4884,7 +4884,7 @@ var WaltHead = function () {
f3
(
1222
,
991
,
646
);
this
.
computeCentroids
();
this
.
computeNormals
();
this
.
compute
Face
Normals
();
this
.
sortFacesByMaterial
();
function
v
(
x
,
y
,
z
)
{
...
...
examples/uqbiquity_test.html
浏览文件 @
10e21dde
...
...
@@ -185,7 +185,7 @@
geometry
.
faces
.
push
(
face
);
}
geometry
.
computeNormals
();
geometry
.
compute
Face
Normals
();
geometry
.
computeCentroids
();
geometry
.
sortFacesByMaterial
();
...
...
src/core/Geometry.js
浏览文件 @
10e21dde
...
...
@@ -46,7 +46,7 @@ THREE.Geometry.prototype = {
},
computeNormals
:
function
(
useVertexNormals
)
{
compute
Face
Normals
:
function
(
useVertexNormals
)
{
var
n
,
nl
,
v
,
vl
,
vertex
,
f
,
fl
,
face
,
vA
,
vB
,
vC
,
cb
=
new
THREE
.
Vector3
(),
ab
=
new
THREE
.
Vector3
();
...
...
src/extras/io/Loader.js
浏览文件 @
10e21dde
...
...
@@ -244,7 +244,7 @@ THREE.Loader.prototype = {
currentOffset
+=
init_quads_smooth_uv
(
currentOffset
);
this
.
computeCentroids
();
this
.
computeNormals
();
this
.
compute
Face
Normals
();
this
.
sortFacesByMaterial
();
//var e = (new Date).getTime();
...
...
@@ -706,7 +706,7 @@ THREE.Loader.prototype = {
init_faces
();
this
.
computeCentroids
();
this
.
computeNormals
();
this
.
compute
Face
Normals
();
this
.
sortFacesByMaterial
();
function
init_vertices
()
{
...
...
src/extras/primitives/Cube.js
浏览文件 @
10e21dde
...
...
@@ -173,7 +173,7 @@ var Cube = function ( width, height, depth, segments_width, segments_height, mat
}
this
.
computeCentroids
();
this
.
computeNormals
();
this
.
compute
Face
Normals
();
this
.
sortFacesByMaterial
();
}
...
...
src/extras/primitives/Cylinder.js
浏览文件 @
10e21dde
...
...
@@ -2,82 +2,80 @@
* @author kile / http://kile.stravaganza.org/
*/
var
Cylinder
=
function
(
numSegs
,
topRad
,
botRad
,
height
,
topOffset
,
botOffset
)
{
var
Cylinder
=
function
(
numSegs
,
topRad
,
botRad
,
height
,
topOffset
,
botOffset
)
{
THREE
.
Geometry
.
call
(
this
);
THREE
.
Geometry
.
call
(
this
);
var
scope
=
this
,
i
;
var
scope
=
this
,
pi
=
Math
.
PI
,
i
;
// VERTICES
// Top circle vertices
for
(
i
=
0
;
i
<
numSegs
;
i
++
)
{
for
(
i
=
0
;
i
<
numSegs
;
i
++
)
{
v
(
Math
.
sin
(
2
*
pi
*
i
/
numSegs
)
*
topRad
,
Math
.
cos
(
2
*
pi
*
i
/
numSegs
)
*
topRad
,
0
);
v
(
Math
.
sin
(
2
*
3.1415
*
i
/
numSegs
)
*
topRad
,
Math
.
cos
(
2
*
3.1415
*
i
/
numSegs
)
*
topRad
,
0
);
}
// Bottom circle vertices
for
(
i
=
0
;
i
<
numSegs
;
i
++
)
{
for
(
i
=
0
;
i
<
numSegs
;
i
++
)
{
v
(
Math
.
sin
(
2
*
pi
*
i
/
numSegs
)
*
botRad
,
Math
.
cos
(
2
*
pi
*
i
/
numSegs
)
*
botRad
,
height
);
v
(
Math
.
sin
(
2
*
3.1415
*
i
/
numSegs
)
*
botRad
,
Math
.
cos
(
2
*
3.1415
*
i
/
numSegs
)
*
botRad
,
height
);
}
// FACES
// Body
for
(
i
=
0
;
i
<
numSegs
;
i
++
)
{
for
(
i
=
0
;
i
<
numSegs
;
i
++
)
{
f4
(
i
,
i
+
numSegs
,
numSegs
+
(
i
+
1
)
%
numSegs
,
(
i
+
1
)
%
numSegs
,
'
#ff0000
'
);
f4
(
i
,
i
+
numSegs
,
numSegs
+
(
i
+
1
)
%
numSegs
,
(
i
+
1
)
%
numSegs
,
'
#ff0000
'
);
}
// Bottom circle
if
(
botRad
!=
0
)
{
if
(
botRad
!=
0
)
{
v
(
0
,
0
,
-
topOffset
);
v
(
0
,
0
,
-
topOffset
);
for
(
i
=
numSegs
;
i
<
numSegs
+
(
numSegs
/
2
);
i
++
)
{
for
(
i
=
numSegs
;
i
<
numSegs
+
(
numSegs
/
2
);
i
++
)
{
f4
(
2
*
numSegs
,
(
2
*
i
-
2
*
numSegs
)
%
numSegs
,
(
2
*
i
-
2
*
numSegs
+
1
)
%
numSegs
,
(
2
*
i
-
2
*
numSegs
+
2
)
%
numSegs
);
f4
(
2
*
numSegs
,
(
2
*
i
-
2
*
numSegs
)
%
numSegs
,
(
2
*
i
-
2
*
numSegs
+
1
)
%
numSegs
,
(
2
*
i
-
2
*
numSegs
+
2
)
%
numSegs
);
}
}
// Top circle
if
(
topRad
!=
0
)
{
if
(
topRad
!=
0
)
{
v
(
0
,
0
,
height
+
topOffset
);
v
(
0
,
0
,
height
+
topOffset
);
for
(
i
=
numSegs
+
(
numSegs
/
2
);
i
<
2
*
numSegs
;
i
++
)
{
for
(
i
=
numSegs
+
(
numSegs
/
2
);
i
<
2
*
numSegs
;
i
++
)
{
f4
(
(
2
*
i
-
2
*
numSegs
+
2
)
%
numSegs
+
numSegs
,
(
2
*
i
-
2
*
numSegs
+
1
)
%
numSegs
+
numSegs
,
(
2
*
i
-
2
*
numSegs
)
%
numSegs
+
numSegs
,
2
*
numSegs
+
1
);
f4
(
(
2
*
i
-
2
*
numSegs
+
2
)
%
numSegs
+
numSegs
,
(
2
*
i
-
2
*
numSegs
+
1
)
%
numSegs
+
numSegs
,
(
2
*
i
-
2
*
numSegs
)
%
numSegs
+
numSegs
,
2
*
numSegs
+
1
);
}
}
this
.
computeCentroids
();
this
.
computeNormals
();
this
.
compute
Face
Normals
();
this
.
sortFacesByMaterial
();
function
v
(
x
,
y
,
z
)
{
function
v
(
x
,
y
,
z
)
{
scope
.
vertices
.
push
(
new
THREE
.
Vertex
(
new
THREE
.
Vector3
(
x
,
y
,
z
)
)
);
}
function
f4
(
a
,
b
,
c
,
d
)
{
function
f4
(
a
,
b
,
c
,
d
)
{
scope
.
faces
.
push
(
new
THREE
.
Face4
(
a
,
b
,
c
,
d
)
);
}
}
Cylinder
.
prototype
=
new
THREE
.
Geometry
();
...
...
src/extras/primitives/Plane.js
浏览文件 @
10e21dde
...
...
@@ -53,7 +53,7 @@ var Plane = function ( width, height, segments_width, segments_height ) {
}
this
.
computeCentroids
();
this
.
computeNormals
();
this
.
compute
Face
Normals
();
this
.
sortFacesByMaterial
();
}
...
...
src/extras/primitives/Sphere.js
浏览文件 @
10e21dde
...
...
@@ -10,7 +10,7 @@ var Sphere = function ( radius, segments_width, segments_height ) {
var
gridX
=
segments_width
||
8
,
gridY
=
segments_height
||
6
;
var
i
,
j
;
var
i
,
j
,
pi
=
Math
.
PI
;
var
iHor
=
Math
.
max
(
3
,
gridX
);
var
iVer
=
Math
.
max
(
2
,
gridY
);
var
aVtc
=
[];
...
...
@@ -18,16 +18,16 @@ var Sphere = function ( radius, segments_width, segments_height ) {
for
(
j
=
0
;
j
<
(
iVer
+
1
)
;
j
++
)
{
var
fRad1
=
j
/
iVer
;
var
fZ
=
radius
*
Math
.
cos
(
fRad1
*
Math
.
PI
);
var
fRds
=
radius
*
Math
.
sin
(
fRad1
*
Math
.
PI
);
var
fZ
=
radius
*
Math
.
cos
(
fRad1
*
pi
);
var
fRds
=
radius
*
Math
.
sin
(
fRad1
*
pi
);
var
aRow
=
[];
var
oVtx
=
0
;
for
(
i
=
0
;
i
<
iHor
;
i
++
)
{
var
fRad2
=
2
*
i
/
iHor
;
var
fX
=
fRds
*
Math
.
sin
(
fRad2
*
Math
.
PI
);
var
fY
=
fRds
*
Math
.
cos
(
fRad2
*
Math
.
PI
);
var
fX
=
fRds
*
Math
.
sin
(
fRad2
*
pi
);
var
fY
=
fRds
*
Math
.
cos
(
fRad2
*
pi
);
if
(
!
(
(
j
==
0
||
j
==
iVer
)
&&
i
>
0
)
)
{
...
...
@@ -104,7 +104,8 @@ var Sphere = function ( radius, segments_width, segments_height ) {
}
this
.
computeCentroids
();
this
.
computeNormals
();
this
.
computeFaceNormals
();
this
.
computeVertexNormals
();
this
.
sortFacesByMaterial
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录