Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
723d3f40
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,发现更多精彩内容 >>
提交
723d3f40
编写于
4月 13, 2015
作者:
B
Ben Adams
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SphereBufferGeometry
上级
479432b9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
118 addition
and
4 deletion
+118
-4
examples/webgl_materials2.html
examples/webgl_materials2.html
+4
-4
src/extras/geometries/SphereBufferGeometry.js
src/extras/geometries/SphereBufferGeometry.js
+111
-0
src/extras/geometries/SphereGeometry.js
src/extras/geometries/SphereGeometry.js
+2
-0
utils/build/includes/extras.json
utils/build/includes/extras.json
+1
-0
未找到文件。
examples/webgl_materials2.html
浏览文件 @
723d3f40
<!DOCTYPE html>
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<title>
three.js webgl - materials
</title>
...
...
@@ -76,8 +76,8 @@
// Spheres geometry
var
geometry_smooth
=
new
THREE
.
SphereGeometry
(
70
,
32
,
16
);
var
geometry_flat
=
new
THREE
.
SphereGeometry
(
70
,
32
,
16
);
var
geometry_smooth
=
new
THREE
.
Sphere
Buffer
Geometry
(
70
,
32
,
16
);
var
geometry_flat
=
new
THREE
.
Sphere
Buffer
Geometry
(
70
,
32
,
16
);
objects
=
[];
...
...
@@ -100,7 +100,7 @@
}
particleLight
=
new
THREE
.
Mesh
(
new
THREE
.
SphereGeometry
(
4
,
8
,
8
),
new
THREE
.
MeshBasicMaterial
(
{
color
:
0xffffff
}
)
);
particleLight
=
new
THREE
.
Mesh
(
new
THREE
.
Sphere
Buffer
Geometry
(
4
,
8
,
8
),
new
THREE
.
MeshBasicMaterial
(
{
color
:
0xffffff
}
)
);
scene
.
add
(
particleLight
);
// Lights
...
...
src/extras/geometries/SphereBufferGeometry.js
0 → 100644
浏览文件 @
723d3f40
/**
* @author benaadams / https://twitter.com/ben_a_adams
* based on THREE.SphereGeometry
*/
THREE
.
SphereBufferGeometry
=
function
(
radius
,
widthSegments
,
heightSegments
,
phiStart
,
phiLength
,
thetaStart
,
thetaLength
)
{
THREE
.
BufferGeometry
.
call
(
this
);
this
.
type
=
'
SphereBufferGeometry
'
;
this
.
parameters
=
{
radius
:
radius
,
widthSegments
:
widthSegments
,
heightSegments
:
heightSegments
,
phiStart
:
phiStart
,
phiLength
:
phiLength
,
thetaStart
:
thetaStart
,
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
stride
=
(
3
+
3
+
2
);
var
vertexBuffer
=
new
THREE
.
InterleavedBuffer
(
new
Float32Array
(
(
(
widthSegments
+
1
)
*
(
heightSegments
+
1
)
)
*
stride
),
stride
);
var
positions
=
new
THREE
.
InterleavedBufferAttribute
(
vertexBuffer
,
3
,
0
);
this
.
addAttribute
(
'
position
'
,
positions
);
var
normals
=
new
THREE
.
InterleavedBufferAttribute
(
vertexBuffer
,
3
,
3
);
this
.
addAttribute
(
'
normal
'
,
normals
);
var
uvs
=
new
THREE
.
InterleavedBufferAttribute
(
vertexBuffer
,
2
,
6
);
this
.
addAttribute
(
'
uv
'
,
uvs
);
var
x
,
y
,
u
,
v
,
px
,
py
,
px
,
index
=
0
,
vertices
=
[],
normal
=
new
THREE
.
Vector3
();
for
(
y
=
0
;
y
<=
heightSegments
;
y
++
)
{
var
verticesRow
=
[];
v
=
y
/
heightSegments
;
for
(
x
=
0
;
x
<=
widthSegments
;
x
++
)
{
u
=
x
/
widthSegments
;
px
=
-
radius
*
Math
.
cos
(
phiStart
+
u
*
phiLength
)
*
Math
.
sin
(
thetaStart
+
v
*
thetaLength
);
py
=
radius
*
Math
.
cos
(
thetaStart
+
v
*
thetaLength
);
pz
=
radius
*
Math
.
sin
(
phiStart
+
u
*
phiLength
)
*
Math
.
sin
(
thetaStart
+
v
*
thetaLength
);
normal
.
set
(
px
,
py
,
pz
).
normalize
();
positions
.
setXYZ
(
index
,
px
,
py
,
pz
);
normals
.
setXYZ
(
index
,
normal
.
x
,
normal
.
y
,
normal
.
z
);
uvs
.
setXY
(
index
,
u
,
1
-
v
);
verticesRow
.
push
(
index
);
index
++
;
}
vertices
.
push
(
verticesRow
);
}
var
indices
=
[];
for
(
y
=
0
,
ul
=
heightSegments
-
1
;
y
<
ul
;
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
];
if
(
y
!==
0
)
indices
.
push
(
v1
,
v2
,
v4
);
indices
.
push
(
v2
,
v3
,
v4
);
}
}
y
=
heightSegments
;
for
(
x
=
0
;
x
<
widthSegments
;
x
++
)
{
var
v2
=
vertices
[
y
][
x
];
var
v3
=
vertices
[
y
-
1
][
x
];
var
v4
=
vertices
[
y
-
1
][
x
+
1
];
indices
.
push
(
v2
,
v4
,
v3
);
}
this
.
addAttribute
(
'
index
'
,
new
THREE
.
BufferAttribute
(
new
Uint16Array
(
indices
),
1
)
);
this
.
boundingSphere
=
new
THREE
.
Sphere
(
new
THREE
.
Vector3
(),
radius
);
};
THREE
.
SphereBufferGeometry
.
prototype
=
Object
.
create
(
THREE
.
BufferGeometry
.
prototype
);
THREE
.
SphereBufferGeometry
.
prototype
.
constructor
=
THREE
.
SphereBufferGeometry
;
\ No newline at end of file
src/extras/geometries/SphereGeometry.js
浏览文件 @
723d3f40
...
...
@@ -4,6 +4,8 @@
THREE
.
SphereGeometry
=
function
(
radius
,
widthSegments
,
heightSegments
,
phiStart
,
phiLength
,
thetaStart
,
thetaLength
)
{
THREE
.
log
(
'
THREE.SphereGeometry: Consider using THREE.SphereBufferGeometry for lower memory footprint.
'
);
THREE
.
Geometry
.
call
(
this
);
this
.
type
=
'
SphereGeometry
'
;
...
...
utils/build/includes/extras.json
浏览文件 @
723d3f40
...
...
@@ -36,6 +36,7 @@
"src/extras/geometries/PlaneBufferGeometry.js"
,
"src/extras/geometries/RingGeometry.js"
,
"src/extras/geometries/SphereGeometry.js"
,
"src/extras/geometries/SphereBufferGeometry.js"
,
"src/extras/geometries/TextGeometry.js"
,
"src/extras/geometries/TorusGeometry.js"
,
"src/extras/geometries/TorusKnotGeometry.js"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录