Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
c7b0e651
T
three.js
项目概览
车家大少爷
/
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,发现更多精彩内容 >>
提交
c7b0e651
编写于
8月 16, 2013
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/zz85/three.js
into dev
上级
433d1bd5
c8781fae
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
73 addition
and
4 deletion
+73
-4
examples/js/modifiers/SubdivisionModifier.js
examples/js/modifiers/SubdivisionModifier.js
+73
-4
未找到文件。
examples/js/modifiers/SubdivisionModifier.js
浏览文件 @
c7b0e651
...
...
@@ -26,6 +26,68 @@
* selective subdivision
*/
THREE
.
Face4Stub
=
function
(
a
,
b
,
c
,
d
,
normal
,
color
,
materialIndex
)
{
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
d
=
d
;
this
.
normal
=
normal
instanceof
THREE
.
Vector3
?
normal
:
new
THREE
.
Vector3
();
this
.
vertexNormals
=
normal
instanceof
Array
?
normal
:
[
];
this
.
color
=
color
instanceof
THREE
.
Color
?
color
:
new
THREE
.
Color
();
this
.
vertexColors
=
color
instanceof
Array
?
color
:
[];
this
.
vertexTangents
=
[];
this
.
materialIndex
=
materialIndex
!==
undefined
?
materialIndex
:
0
;
this
.
centroid
=
new
THREE
.
Vector3
();
};
THREE
.
GeometryUtils
.
convertFace4s
=
function
(
geometry
)
{
// return geometry;
var
faces
=
geometry
.
faces
;
var
faceVertexUvs
=
geometry
.
faceVertexUvs
[
0
];
var
newfaces
=
[];
var
newfaceVertexUvs
=
[];
var
f
,
fl
,
face
,
uv
;
for
(
f
=
0
,
fl
=
faces
.
length
;
f
<
fl
;
f
++
)
{
face
=
faces
[
f
];
uv
=
faceVertexUvs
[
f
];
if
(
face
instanceof
THREE
.
Face3
)
{
newfaces
.
push
(
face
);
if
(
uv
)
newfaceVertexUvs
.
push
(
uv
);
}
else
{
newfaces
.
push
(
new
THREE
.
Face3
(
face
.
a
,
face
.
b
,
face
.
c
,
null
,
face
.
color
,
face
.
materialIndex
)
);
newfaces
.
push
(
new
THREE
.
Face3
(
face
.
d
,
face
.
a
,
face
.
c
,
null
,
face
.
color
,
face
.
materialIndex
)
);
if
(
uv
)
newfaceVertexUvs
.
push
([
uv
[
0
],
uv
[
1
],
uv
[
2
]]);
if
(
uv
)
newfaceVertexUvs
.
push
([
uv
[
3
],
uv
[
0
],
uv
[
2
]]);
}
}
geometry
.
faces
=
newfaces
;
geometry
.
faceVertexUvs
=
[
newfaceVertexUvs
];
}
THREE
.
SubdivisionModifier
=
function
(
subdivisions
)
{
...
...
@@ -47,6 +109,13 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
this
.
smooth
(
geometry
);
}
THREE
.
GeometryUtils
.
convertFace4s
(
geometry
);
delete
geometry
.
__tmpVertices
;
geometry
.
computeCentroids
();
geometry
.
computeFaceNormals
();
geometry
.
computeVertexNormals
();
};
/// REFACTORING THIS OUT
...
...
@@ -98,7 +167,7 @@ THREE.GeometryUtils.computeEdgeFaces = function ( geometry ) {
hash
=
orderedKey
(
face
.
c
,
face
.
a
);
mapEdgeHash
(
hash
,
i
);
}
else
if
(
face
instanceof
THREE
.
Face4
)
{
}
else
if
(
face
instanceof
THREE
.
Face4
Stub
)
{
hash
=
orderedKey
(
face
.
a
,
face
.
b
);
mapEdgeHash
(
hash
,
i
);
...
...
@@ -176,7 +245,7 @@ THREE.SubdivisionModifier.prototype.smooth = function ( oldGeometry ) {
// TODO move vertex selection over here!
var
newFace
=
new
THREE
.
Face4
(
a
,
b
,
c
,
d
,
null
,
oldFace
.
color
,
oldFace
.
materialIndex
);
var
newFace
=
new
THREE
.
Face4
Stub
(
a
,
b
,
c
,
d
,
null
,
oldFace
.
color
,
oldFace
.
materialIndex
);
if
(
scope
.
useOldVertexColors
)
{
...
...
@@ -345,7 +414,7 @@ THREE.SubdivisionModifier.prototype.smooth = function ( oldGeometry ) {
avgUv
.
x
/=
3
;
avgUv
.
y
/=
3
;
}
else
if
(
face
instanceof
THREE
.
Face4
)
{
}
else
if
(
face
instanceof
THREE
.
Face4
Stub
)
{
avgUv
.
x
=
getUV
(
face
.
a
,
i
).
x
+
getUV
(
face
.
b
,
i
).
x
+
getUV
(
face
.
c
,
i
).
x
+
getUV
(
face
.
d
,
i
).
x
;
avgUv
.
y
=
getUV
(
face
.
a
,
i
).
y
+
getUV
(
face
.
b
,
i
).
y
+
getUV
(
face
.
c
,
i
).
y
+
getUV
(
face
.
d
,
i
).
y
;
...
...
@@ -540,7 +609,7 @@ THREE.SubdivisionModifier.prototype.smooth = function ( oldGeometry ) {
f4
(
currentVerticeIndex
,
edgePoints
[
hashBC
],
face
.
c
,
edgePoints
[
hashCA
],
face
,
bca123
,
i
);
f4
(
currentVerticeIndex
,
edgePoints
[
hashCA
],
face
.
a
,
edgePoints
[
hashAB
],
face
,
cab123
,
i
);
}
else
if
(
face
instanceof
THREE
.
Face4
)
{
}
else
if
(
face
instanceof
THREE
.
Face4
Stub
)
{
// create 4 face4s
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录