Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
4cebf07e
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,发现更多精彩内容 >>
提交
4cebf07e
编写于
3月 11, 2014
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
BufferGeometry based PlaneGeometry.
上级
054b9cee
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
44 addition
and
31 deletion
+44
-31
src/extras/geometries/PlaneGeometry.js
src/extras/geometries/PlaneGeometry.js
+44
-31
未找到文件。
src/extras/geometries/PlaneGeometry.js
浏览文件 @
4cebf07e
...
...
@@ -5,7 +5,7 @@
THREE
.
PlaneGeometry
=
function
(
width
,
height
,
widthSegments
,
heightSegments
)
{
THREE
.
Geometry
.
call
(
this
);
THREE
.
Buffer
Geometry
.
call
(
this
);
this
.
parameters
=
{
width
:
width
,
...
...
@@ -14,67 +14,80 @@ THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments )
heightSegments
:
heightSegments
};
var
ix
,
iz
;
var
width_half
=
width
/
2
;
var
height_half
=
height
/
2
;
var
gridX
=
widthSegments
||
1
;
var
grid
Z
=
heightSegments
||
1
;
var
grid
Y
=
heightSegments
||
1
;
var
gridX1
=
gridX
+
1
;
var
grid
Z1
=
gridZ
+
1
;
var
grid
Y1
=
gridY
+
1
;
var
segment_width
=
width
/
gridX
;
var
segment_height
=
height
/
grid
Z
;
var
segment_height
=
height
/
grid
Y
;
var
normal
=
new
THREE
.
Vector3
(
0
,
0
,
1
);
var
vertices
=
new
Float32Array
(
gridX1
*
gridY1
*
3
);
var
normals
=
new
Float32Array
(
gridX1
*
gridY1
*
3
);
var
uvs
=
new
Float32Array
(
gridX1
*
gridY1
*
2
);
for
(
iz
=
0
;
iz
<
gridZ1
;
iz
++
)
{
var
offset
=
0
;
var
offset2
=
0
;
var
y
=
iz
*
segment_height
-
height_half
;
for
(
var
iy
=
0
;
iy
<
gridY1
;
iy
++
)
{
for
(
ix
=
0
;
ix
<
gridX1
;
ix
++
)
{
var
y
=
iy
*
segment_height
-
height_half
;
for
(
var
ix
=
0
;
ix
<
gridX1
;
ix
++
)
{
var
x
=
ix
*
segment_width
-
width_half
;
this
.
vertices
.
push
(
new
THREE
.
Vector3
(
x
,
-
y
,
0
)
);
vertices
[
offset
]
=
x
;
vertices
[
offset
+
1
]
=
-
y
;
normals
[
offset
+
2
]
=
1
;
uvs
[
offset2
]
=
ix
/
gridX
;
uvs
[
offset2
+
1
]
=
1
-
(
iy
/
gridY
);
offset
+=
3
;
offset2
+=
2
;
}
}
for
(
iz
=
0
;
iz
<
gridZ
;
iz
++
)
{
offset
=
0
;
for
(
ix
=
0
;
ix
<
gridX
;
ix
++
)
{
var
indices
=
new
Uint16Array
(
gridX
*
gridY
*
6
);
var
a
=
ix
+
gridX1
*
iz
;
var
b
=
ix
+
gridX1
*
(
iz
+
1
);
var
c
=
(
ix
+
1
)
+
gridX1
*
(
iz
+
1
);
var
d
=
(
ix
+
1
)
+
gridX1
*
iz
;
for
(
var
iy
=
0
;
iy
<
gridY
;
iy
++
)
{
var
uva
=
new
THREE
.
Vector2
(
ix
/
gridX
,
1
-
iz
/
gridZ
);
var
uvb
=
new
THREE
.
Vector2
(
ix
/
gridX
,
1
-
(
iz
+
1
)
/
gridZ
);
var
uvc
=
new
THREE
.
Vector2
(
(
ix
+
1
)
/
gridX
,
1
-
(
iz
+
1
)
/
gridZ
);
var
uvd
=
new
THREE
.
Vector2
(
(
ix
+
1
)
/
gridX
,
1
-
iz
/
gridZ
);
for
(
var
ix
=
0
;
ix
<
gridX
;
ix
++
)
{
var
face
=
new
THREE
.
Face3
(
a
,
b
,
d
);
face
.
normal
.
copy
(
normal
);
face
.
vertexNormals
.
push
(
normal
.
clone
(),
normal
.
clone
(),
normal
.
clone
()
);
var
a
=
ix
+
gridX1
*
iy
;
var
b
=
ix
+
gridX1
*
(
iy
+
1
);
var
c
=
(
ix
+
1
)
+
gridX1
*
(
iy
+
1
);
var
d
=
(
ix
+
1
)
+
gridX1
*
iy
;
this
.
faces
.
push
(
face
);
this
.
faceVertexUvs
[
0
].
push
(
[
uva
,
uvb
,
uvd
]
);
indices
[
offset
]
=
a
;
indices
[
offset
+
1
]
=
b
;
indices
[
offset
+
2
]
=
d
;
face
=
new
THREE
.
Face3
(
b
,
c
,
d
)
;
face
.
normal
.
copy
(
normal
)
;
face
.
vertexNormals
.
push
(
normal
.
clone
(),
normal
.
clone
(),
normal
.
clone
()
)
;
indices
[
offset
+
3
]
=
b
;
indices
[
offset
+
4
]
=
c
;
indices
[
offset
+
5
]
=
d
;
this
.
faces
.
push
(
face
);
this
.
faceVertexUvs
[
0
].
push
(
[
uvb
.
clone
(),
uvc
,
uvd
.
clone
()
]
);
offset
+=
6
;
}
}
this
.
attributes
[
'
index
'
]
=
{
array
:
indices
,
itemSize
:
1
};
this
.
attributes
[
'
position
'
]
=
{
array
:
vertices
,
itemSize
:
3
};
this
.
attributes
[
'
normal
'
]
=
{
array
:
normals
,
itemSize
:
3
};
this
.
attributes
[
'
uv
'
]
=
{
array
:
uvs
,
itemSize
:
2
};
};
THREE
.
PlaneGeometry
.
prototype
=
Object
.
create
(
THREE
.
Geometry
.
prototype
);
THREE
.
PlaneGeometry
.
prototype
=
Object
.
create
(
THREE
.
Buffer
Geometry
.
prototype
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录