Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
2b7a5a8d
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,发现更多精彩内容 >>
提交
2b7a5a8d
编写于
9月 04, 2015
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SphereGeometry: Use SphereBufferGeometry internally.
上级
50d547b0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
1 addition
and
90 deletion
+1
-90
src/extras/geometries/SphereGeometry.js
src/extras/geometries/SphereGeometry.js
+1
-90
未找到文件。
src/extras/geometries/SphereGeometry.js
浏览文件 @
2b7a5a8d
...
...
@@ -4,8 +4,6 @@
THREE
.
SphereGeometry
=
function
(
radius
,
widthSegments
,
heightSegments
,
phiStart
,
phiLength
,
thetaStart
,
thetaLength
)
{
console
.
log
(
'
THREE.SphereGeometry: Consider using THREE.SphereBufferGeometry for lower memory footprint.
'
);
THREE
.
Geometry
.
call
(
this
);
this
.
type
=
'
SphereGeometry
'
;
...
...
@@ -20,94 +18,7 @@ THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStar
thetaLength
:
thetaLength
};
radius
=
radius
||
50
;
widthSegments
=
Math
.
max
(
3
,
Math
.
floor
(
widthSegments
)
||
8
);
heightSegments
=
Math
.
max
(
2
,
Math
.
floor
(
heightSegments
)
||
6
);
phiStart
=
phiStart
!==
undefined
?
phiStart
:
0
;
phiLength
=
phiLength
!==
undefined
?
phiLength
:
Math
.
PI
*
2
;
thetaStart
=
thetaStart
!==
undefined
?
thetaStart
:
0
;
thetaLength
=
thetaLength
!==
undefined
?
thetaLength
:
Math
.
PI
;
var
x
,
y
,
vertices
=
[],
uvs
=
[];
for
(
y
=
0
;
y
<=
heightSegments
;
y
++
)
{
var
verticesRow
=
[];
var
uvsRow
=
[];
for
(
x
=
0
;
x
<=
widthSegments
;
x
++
)
{
var
u
=
x
/
widthSegments
;
var
v
=
y
/
heightSegments
;
var
vertex
=
new
THREE
.
Vector3
();
vertex
.
x
=
-
radius
*
Math
.
cos
(
phiStart
+
u
*
phiLength
)
*
Math
.
sin
(
thetaStart
+
v
*
thetaLength
);
vertex
.
y
=
radius
*
Math
.
cos
(
thetaStart
+
v
*
thetaLength
);
vertex
.
z
=
radius
*
Math
.
sin
(
phiStart
+
u
*
phiLength
)
*
Math
.
sin
(
thetaStart
+
v
*
thetaLength
);
this
.
vertices
.
push
(
vertex
);
verticesRow
.
push
(
this
.
vertices
.
length
-
1
);
uvsRow
.
push
(
new
THREE
.
Vector2
(
u
,
1
-
v
)
);
}
vertices
.
push
(
verticesRow
);
uvs
.
push
(
uvsRow
);
}
for
(
y
=
0
;
y
<
heightSegments
;
y
++
)
{
for
(
x
=
0
;
x
<
widthSegments
;
x
++
)
{
var
v1
=
vertices
[
y
][
x
+
1
];
var
v2
=
vertices
[
y
][
x
];
var
v3
=
vertices
[
y
+
1
][
x
];
var
v4
=
vertices
[
y
+
1
][
x
+
1
];
var
n1
=
this
.
vertices
[
v1
].
clone
().
normalize
();
var
n2
=
this
.
vertices
[
v2
].
clone
().
normalize
();
var
n3
=
this
.
vertices
[
v3
].
clone
().
normalize
();
var
n4
=
this
.
vertices
[
v4
].
clone
().
normalize
();
var
uv1
=
uvs
[
y
][
x
+
1
].
clone
();
var
uv2
=
uvs
[
y
][
x
].
clone
();
var
uv3
=
uvs
[
y
+
1
][
x
].
clone
();
var
uv4
=
uvs
[
y
+
1
][
x
+
1
].
clone
();
if
(
Math
.
abs
(
this
.
vertices
[
v1
].
y
)
===
radius
)
{
uv1
.
x
=
(
uv1
.
x
+
uv2
.
x
)
/
2
;
this
.
faces
.
push
(
new
THREE
.
Face3
(
v1
,
v3
,
v4
,
[
n1
,
n3
,
n4
]
)
);
this
.
faceVertexUvs
[
0
].
push
(
[
uv1
,
uv3
,
uv4
]
);
}
else
if
(
Math
.
abs
(
this
.
vertices
[
v3
].
y
)
===
radius
)
{
uv3
.
x
=
(
uv3
.
x
+
uv4
.
x
)
/
2
;
this
.
faces
.
push
(
new
THREE
.
Face3
(
v1
,
v2
,
v3
,
[
n1
,
n2
,
n3
]
)
);
this
.
faceVertexUvs
[
0
].
push
(
[
uv1
,
uv2
,
uv3
]
);
}
else
{
this
.
faces
.
push
(
new
THREE
.
Face3
(
v1
,
v2
,
v4
,
[
n1
,
n2
,
n4
]
)
);
this
.
faceVertexUvs
[
0
].
push
(
[
uv1
,
uv2
,
uv4
]
);
this
.
faces
.
push
(
new
THREE
.
Face3
(
v2
,
v3
,
v4
,
[
n2
.
clone
(),
n3
,
n4
.
clone
()
]
)
);
this
.
faceVertexUvs
[
0
].
push
(
[
uv2
.
clone
(),
uv3
,
uv4
.
clone
()
]
);
}
}
}
this
.
computeFaceNormals
();
this
.
boundingSphere
=
new
THREE
.
Sphere
(
new
THREE
.
Vector3
(),
radius
);
this
.
fromBufferGeometry
(
new
THREE
.
SphereBufferGeometry
(
radius
,
widthSegments
,
heightSegments
,
phiStart
,
phiLength
,
thetaStart
,
thetaLength
)
);
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录