Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
8e6339f5
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,发现更多精彩内容 >>
提交
8e6339f5
编写于
3月 09, 2017
作者:
M
Mugen87
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
QuickHull3: Enhance API
上级
d3655968
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
113 addition
and
34 deletion
+113
-34
src/math/convexhull/Face.js
src/math/convexhull/Face.js
+8
-8
src/math/convexhull/QuickHull3.js
src/math/convexhull/QuickHull3.js
+104
-24
src/math/convexhull/Vertex.js
src/math/convexhull/Vertex.js
+1
-2
未找到文件。
src/math/convexhull/Face.js
浏览文件 @
8e6339f5
...
@@ -120,16 +120,16 @@ Object.assign( Face.prototype, {
...
@@ -120,16 +120,16 @@ Object.assign( Face.prototype, {
}
}
twinEdge
=
next
.
twin
.
prev
.
twin
;
twinEdge
=
next
.
twin
.
prev
.
twin
;
oppositeFace
.
mark
=
Deleted
;
oppositeFace
.
mark
=
Deleted
;
discardedFace
=
oppositeFace
;
discardedFace
=
oppositeFace
;
next
.
prev
=
prev
.
prev
;
next
.
prev
=
prev
.
prev
;
next
.
prev
.
next
=
next
;
next
.
prev
.
next
=
next
;
next
.
setTwin
(
twinEdge
);
next
.
setTwin
(
twinEdge
);
oppositeFace
.
compute
();
oppositeFace
.
compute
();
}
else
{
}
else
{
...
@@ -168,7 +168,7 @@ Object.assign( Face.prototype, {
...
@@ -168,7 +168,7 @@ Object.assign( Face.prototype, {
// right edge
// right edge
while
(
adjacentEdgeNext
.
opposite
.
face
===
oppositeFace
)
{
while
(
adjacentEdgeNext
.
twin
.
face
===
oppositeFace
)
{
adjacentEdgeNext
=
adjacentEdgeNext
.
next
;
adjacentEdgeNext
=
adjacentEdgeNext
.
next
;
twinEdgePrev
=
twinEdgePrev
.
prev
;
twinEdgePrev
=
twinEdgePrev
.
prev
;
...
...
src/math/convexhull/QuickHull3.js
浏览文件 @
8e6339f5
...
@@ -12,19 +12,9 @@ import { MergeNonConvexLargerFace, MergeNonConvex } from '../../constants';
...
@@ -12,19 +12,9 @@ import { MergeNonConvexLargerFace, MergeNonConvex } from '../../constants';
*
*
*/
*/
function
QuickHull3
(
points
)
{
var
c
=
0
;
if
(
Array
.
isArray
(
points
)
!==
true
)
{
function
QuickHull3
()
{
console
.
error
(
'
THREE.QuickHull3: Points parameter is not an array.
'
);
}
if
(
points
.
length
<
4
)
{
console
.
error
(
'
THREE.QuickHull3: The algorithm needs at least four points.
'
);
}
this
.
tolerance
=
-
1
;
this
.
tolerance
=
-
1
;
...
@@ -36,15 +26,105 @@ function QuickHull3( points ) {
...
@@ -36,15 +26,105 @@ function QuickHull3( points ) {
this
.
vertices
=
[];
// vertices of the hull (internal representation of given points)
this
.
vertices
=
[];
// vertices of the hull (internal representation of given points)
for
(
var
i
=
0
,
l
=
points
.
length
;
i
<
l
;
i
++
)
{
}
Object
.
assign
(
QuickHull3
.
prototype
,
{
this
.
vertices
.
push
(
new
Vertex
(
points
[
i
],
i
)
);
setFromPoints
:
function
(
points
)
{
}
if
(
Array
.
isArray
(
points
)
!==
true
)
{
}
console
.
error
(
'
THREE.QuickHull3: Points parameter is not an array.
'
);
Object
.
assign
(
QuickHull3
.
prototype
,
{
}
if
(
points
.
length
<
4
)
{
console
.
error
(
'
THREE.QuickHull3: The algorithm needs at least four points.
'
);
}
this
.
makeEmpty
();
for
(
var
i
=
0
,
l
=
points
.
length
;
i
<
l
;
i
++
)
{
this
.
vertices
.
push
(
new
Vertex
(
points
[
i
]
)
);
}
this
.
compute
();
return
this
;
},
setFromObject
:
function
(
object
)
{
var
scope
=
this
;
this
.
makeEmpty
();
object
.
updateMatrixWorld
(
true
);
object
.
traverse
(
function
(
node
)
{
var
i
,
l
,
point
;
var
geometry
=
node
.
geometry
;
if
(
geometry
!==
undefined
)
{
if
(
geometry
.
isGeometry
)
{
var
vertices
=
geometry
.
vertices
;
for
(
i
=
0
,
l
=
vertices
.
length
;
i
<
l
;
i
++
)
{
point
=
vertices
[
i
].
clone
();
point
.
applyMatrix4
(
node
.
matrixWorld
);
scope
.
vertices
.
push
(
new
Vertex
(
point
)
);
}
}
else
if
(
geometry
.
isBufferGeometry
)
{
var
attribute
=
geometry
.
attributes
.
position
;
if
(
attribute
!==
undefined
)
{
for
(
i
=
0
,
l
=
attribute
.
count
;
i
<
l
;
i
++
)
{
point
=
new
Vector3
();
point
.
fromBufferAttribute
(
attribute
,
i
).
applyMatrix4
(
node
.
matrixWorld
);
scope
.
vertices
.
push
(
new
Vertex
(
point
)
);
}
}
}
}
}
);
this
.
compute
();
return
this
;
},
makeEmpty
:
function
()
{
this
.
faces
=
[];
this
.
vertices
=
[];
return
this
;
},
// Adds a 'vertex' to the 'assigned' list of vertices and assigns it to the given face.
// Adds a 'vertex' to the 'assigned' list of vertices and assigns it to the given face.
...
@@ -699,8 +779,8 @@ Object.assign( QuickHull3.prototype, {
...
@@ -699,8 +779,8 @@ Object.assign( QuickHull3.prototype, {
// The result is:
// The result is:
//
//
// - a positive number when the
centroid
of the opposite face is above the face i.e. when the faces are concave
// - a positive number when the
midpoint
of the opposite face is above the face i.e. when the faces are concave
// - a negative number when the
centroid
of the opposite face is below the face i.e. when the faces are convex
// - a negative number when the
midpoint
of the opposite face is below the face i.e. when the faces are convex
return
edge
.
face
.
distanceToPoint
(
edge
.
twin
.
face
.
midpoint
);
return
edge
.
face
.
distanceToPoint
(
edge
.
twin
.
face
.
midpoint
);
...
@@ -720,7 +800,7 @@ Object.assign( QuickHull3.prototype, {
...
@@ -720,7 +800,7 @@ Object.assign( QuickHull3.prototype, {
if
(
mergeType
===
MergeNonConvex
)
{
if
(
mergeType
===
MergeNonConvex
)
{
if
(
this
.
oppositeFaceDistance
(
edge
)
>
this
.
tolerance
||
if
(
this
.
oppositeFaceDistance
(
edge
)
>
-
this
.
tolerance
||
this
.
oppositeFaceDistance
(
edge
.
twin
)
>
-
this
.
tolerance
)
{
this
.
oppositeFaceDistance
(
edge
.
twin
)
>
-
this
.
tolerance
)
{
merge
=
true
;
merge
=
true
;
...
@@ -757,7 +837,7 @@ Object.assign( QuickHull3.prototype, {
...
@@ -757,7 +837,7 @@ Object.assign( QuickHull3.prototype, {
if
(
merge
===
true
)
{
if
(
merge
===
true
)
{
var
discardedFaces
=
this
.
mergeAdjacentFaces
(
edge
,
[]
);
var
discardedFaces
=
face
.
mergeAdjacentFaces
(
edge
,
[]
);
for
(
var
i
=
0
;
i
<
discardedFaces
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
discardedFaces
.
length
;
i
++
)
{
...
@@ -811,7 +891,7 @@ Object.assign( QuickHull3.prototype, {
...
@@ -811,7 +891,7 @@ Object.assign( QuickHull3.prototype, {
if
(
face
.
mark
===
Visible
)
{
if
(
face
.
mark
===
Visible
)
{
while
(
this
.
doAdjacentMerge
(
face
,
MergeNonConvexLargerFace
)
)
{}
//
while ( this.doAdjacentMerge( face, MergeNonConvexLargerFace ) ) {}
}
}
...
@@ -828,7 +908,7 @@ Object.assign( QuickHull3.prototype, {
...
@@ -828,7 +908,7 @@ Object.assign( QuickHull3.prototype, {
face
.
mark
=
Visible
;
face
.
mark
=
Visible
;
while
(
this
.
doAdjacentMerge
(
face
,
MergeNonConvex
)
)
{}
//
while ( this.doAdjacentMerge( face, MergeNonConvex ) ) {}
}
}
...
@@ -848,7 +928,7 @@ Object.assign( QuickHull3.prototype, {
...
@@ -848,7 +928,7 @@ Object.assign( QuickHull3.prototype, {
},
},
build
:
function
()
{
compute
:
function
()
{
var
vertex
;
var
vertex
;
...
...
src/math/convexhull/Vertex.js
浏览文件 @
8e6339f5
...
@@ -5,10 +5,9 @@
...
@@ -5,10 +5,9 @@
*
*
*/
*/
function
Vertex
(
point
,
index
)
{
function
Vertex
(
point
)
{
this
.
point
=
point
;
this
.
point
=
point
;
this
.
index
=
index
;
// index in the input array of points
this
.
next
=
null
;
this
.
next
=
null
;
this
.
prev
=
null
;
this
.
prev
=
null
;
this
.
face
=
null
;
// the face that is able to see this point
this
.
face
=
null
;
// the face that is able to see this point
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录