Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
4cde914c
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,发现更多精彩内容 >>
提交
4cde914c
编写于
1月 27, 2014
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removed THREE.Shape.Utils.removeHoles.
上级
1062c88f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
0 addition
and
201 deletion
+0
-201
src/extras/core/Shape.js
src/extras/core/Shape.js
+0
-201
未找到文件。
src/extras/core/Shape.js
浏览文件 @
4cde914c
...
...
@@ -123,207 +123,6 @@ THREE.Shape.prototype.extractAllSpacedPoints = function ( divisions ) {
THREE
.
Shape
.
Utils
=
{
/*
contour - array of vector2 for contour
holes - array of array of vector2
*/
removeHoles
:
function
(
contour
,
holes
)
{
var
shape
=
contour
.
concat
();
// work on this shape
var
allpoints
=
shape
.
concat
();
/* For each isolated shape, find the closest points and break to the hole to allow triangulation */
var
prevShapeVert
,
nextShapeVert
,
prevHoleVert
,
nextHoleVert
,
holeIndex
,
shapeIndex
,
shapeId
,
shapeGroup
,
h
,
h2
,
hole
,
shortest
,
d
,
p
,
pts1
,
pts2
,
tmpShape1
,
tmpShape2
,
tmpHole1
,
tmpHole2
,
verts
=
[];
for
(
h
=
0
;
h
<
holes
.
length
;
h
++
)
{
hole
=
holes
[
h
];
/*
shapeholes[ h ].concat(); // preserves original
holes.push( hole );
*/
Array
.
prototype
.
push
.
apply
(
allpoints
,
hole
);
shortest
=
Number
.
POSITIVE_INFINITY
;
// Find the shortest pair of pts between shape and hole
// Note: Actually, I'm not sure now if we could optimize this to be faster than O(m*n)
// Using distanceToSquared() intead of distanceTo() should speed a little
// since running square roots operations are reduced.
for
(
h2
=
0
;
h2
<
hole
.
length
;
h2
++
)
{
pts1
=
hole
[
h2
];
var
dist
=
[];
for
(
p
=
0
;
p
<
shape
.
length
;
p
++
)
{
pts2
=
shape
[
p
];
d
=
pts1
.
distanceToSquared
(
pts2
);
dist
.
push
(
d
);
if
(
d
<
shortest
)
{
shortest
=
d
;
holeIndex
=
h2
;
shapeIndex
=
p
;
}
}
}
//console.log("shortest", shortest, dist);
prevShapeVert
=
(
shapeIndex
-
1
)
>=
0
?
shapeIndex
-
1
:
shape
.
length
-
1
;
prevHoleVert
=
(
holeIndex
-
1
)
>=
0
?
holeIndex
-
1
:
hole
.
length
-
1
;
var
areaapts
=
[
hole
[
holeIndex
],
shape
[
shapeIndex
],
shape
[
prevShapeVert
]
];
var
areaa
=
THREE
.
FontUtils
.
Triangulate
.
area
(
areaapts
);
var
areabpts
=
[
hole
[
holeIndex
],
hole
[
prevHoleVert
],
shape
[
shapeIndex
]
];
var
areab
=
THREE
.
FontUtils
.
Triangulate
.
area
(
areabpts
);
var
shapeOffset
=
1
;
var
holeOffset
=
-
1
;
var
oldShapeIndex
=
shapeIndex
,
oldHoleIndex
=
holeIndex
;
shapeIndex
+=
shapeOffset
;
holeIndex
+=
holeOffset
;
if
(
shapeIndex
<
0
)
{
shapeIndex
+=
shape
.
length
;
}
shapeIndex
%=
shape
.
length
;
if
(
holeIndex
<
0
)
{
holeIndex
+=
hole
.
length
;
}
holeIndex
%=
hole
.
length
;
prevShapeVert
=
(
shapeIndex
-
1
)
>=
0
?
shapeIndex
-
1
:
shape
.
length
-
1
;
prevHoleVert
=
(
holeIndex
-
1
)
>=
0
?
holeIndex
-
1
:
hole
.
length
-
1
;
areaapts
=
[
hole
[
holeIndex
],
shape
[
shapeIndex
],
shape
[
prevShapeVert
]
];
var
areaa2
=
THREE
.
FontUtils
.
Triangulate
.
area
(
areaapts
);
areabpts
=
[
hole
[
holeIndex
],
hole
[
prevHoleVert
],
shape
[
shapeIndex
]
];
var
areab2
=
THREE
.
FontUtils
.
Triangulate
.
area
(
areabpts
);
//console.log(areaa,areab ,areaa2,areab2, ( areaa + areab ), ( areaa2 + areab2 ));
if
(
(
areaa
+
areab
)
>
(
areaa2
+
areab2
)
)
{
// In case areas are not correct.
//console.log("USE THIS");
shapeIndex
=
oldShapeIndex
;
holeIndex
=
oldHoleIndex
;
if
(
shapeIndex
<
0
)
{
shapeIndex
+=
shape
.
length
;
}
shapeIndex
%=
shape
.
length
;
if
(
holeIndex
<
0
)
{
holeIndex
+=
hole
.
length
;
}
holeIndex
%=
hole
.
length
;
prevShapeVert
=
(
shapeIndex
-
1
)
>=
0
?
shapeIndex
-
1
:
shape
.
length
-
1
;
prevHoleVert
=
(
holeIndex
-
1
)
>=
0
?
holeIndex
-
1
:
hole
.
length
-
1
;
}
else
{
//console.log("USE THAT ")
}
tmpShape1
=
shape
.
slice
(
0
,
shapeIndex
);
tmpShape2
=
shape
.
slice
(
shapeIndex
);
tmpHole1
=
hole
.
slice
(
holeIndex
);
tmpHole2
=
hole
.
slice
(
0
,
holeIndex
);
// Should check orders here again?
var
trianglea
=
[
hole
[
holeIndex
],
shape
[
shapeIndex
],
shape
[
prevShapeVert
]
];
var
triangleb
=
[
hole
[
holeIndex
]
,
hole
[
prevHoleVert
],
shape
[
shapeIndex
]
];
verts
.
push
(
trianglea
);
verts
.
push
(
triangleb
);
shape
=
tmpShape1
.
concat
(
tmpHole1
).
concat
(
tmpHole2
).
concat
(
tmpShape2
);
}
return
{
shape
:
shape
,
/* shape with no holes */
isolatedPts
:
verts
,
/* isolated faces */
allpoints
:
allpoints
}
},
/*
* Modified Triangulation.
*
* basically rewritten 'removeHoles':
* - doesn't cut out an area anymore, but slices from shape to hole by adding two edges
* - ATTENTION: this requires small change to 'THREE.FontUtils.snip' to account for duplicate coordinates
* - checks whether such a cut line lies inside the shape doesn't intersect any other edge (shape and holes)
*/
triangulateShape
:
function
(
contour
,
holes
)
{
function
point_in_segment_2D
(
inSegPt1
,
inSegPt2
,
inOtherPt
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录