Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
7d63a811
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,发现更多精彩内容 >>
提交
7d63a811
编写于
12月 03, 2012
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merging with @bhouston branch.
上级
4c83bf02
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
92 deletion
+51
-92
src/core/Box3.js
src/core/Box3.js
+51
-92
未找到文件。
src/core/Box3.js
浏览文件 @
7d63a811
...
...
@@ -4,18 +4,14 @@
THREE
.
Box3
=
function
(
min
,
max
)
{
if
(
min
==
undefined
&&
max
===
undefined
)
{
if
(
!
min
&&
!
max
)
{
this
.
min
=
new
THREE
.
Vector3
();
this
.
max
=
new
THREE
.
Vector3
();
this
.
min
.
x
=
this
.
min
.
y
=
this
.
min
.
z
=
Infinity
;
this
.
max
.
x
=
this
.
max
.
y
=
this
.
max
.
z
=
-
Infinity
;
console
.
log
(
this
);
}
else
{
this
.
makeEmpty
();
}
else
{
this
.
min
=
min
||
new
THREE
.
Vector3
();
this
.
max
=
max
||
new
THREE
.
Vector3
().
copy
(
this
.
min
);
// This is done on purpose so you can make a box using a single point and then expand it.
this
.
max
=
max
||
new
THREE
.
Vector3
().
copy
(
this
.
min
);
// This is done on purpose so you can make a box using a single point and then expand it.
}
};
...
...
@@ -29,58 +25,44 @@ THREE.Box3.prototype = {
this
.
max
=
max
;
return
this
;
},
setFromPoints
:
function
(
points
)
{
if
(
points
.
length
>
0
)
{
var
p
=
points
[
0
];
if
(
points
.
length
>
0
)
{
var
p
=
points
[
0
];
this
.
min
.
copy
(
p
);
this
.
max
.
copy
(
p
);
for
(
var
i
=
1
,
il
=
points
.
length
;
i
<
il
;
i
++
)
{
for
(
var
i
=
1
,
numPoints
=
points
.
length
;
i
<
numPoints
;
i
++
)
{
p
=
points
[
i
];
p
=
points
[
v
];
if
(
p
.
x
<
this
.
min
.
x
)
{
this
.
min
.
x
=
p
.
x
;
}
else
if
(
p
.
x
>
this
.
max
.
x
)
{
}
else
if
(
p
.
x
>
this
.
max
.
x
)
{
this
.
max
.
x
=
p
.
x
;
}
if
(
p
.
y
<
this
.
min
.
y
)
{
this
.
min
.
y
=
p
.
y
;
}
else
if
(
p
.
y
>
this
.
max
.
y
)
{
}
else
if
(
p
.
y
>
this
.
max
.
y
)
{
this
.
max
.
y
=
p
.
y
;
}
if
(
p
.
z
<
this
.
min
.
z
)
{
this
.
min
.
z
=
p
.
z
;
}
else
if
(
p
.
z
>
this
.
max
.
z
)
{
}
else
if
(
p
.
z
>
this
.
max
.
z
)
{
this
.
max
.
z
=
p
.
z
;
}
}
}
else
{
}
else
{
this
.
makeEmpty
();
}
return
this
;
...
...
@@ -89,12 +71,10 @@ THREE.Box3.prototype = {
setFromCenterAndSize
:
function
(
center
,
size
)
{
var
halfSize
=
THREE
.
Box3
.
__v1
.
copy
(
size
).
multiplyScalar
(
0.5
);
this
.
min
.
copy
(
center
).
subSelf
(
halfSize
);
this
.
max
.
copy
(
center
).
addSelf
(
halfSize
);
return
this
;
return
box
;
},
copy
:
function
(
box
)
{
...
...
@@ -103,7 +83,6 @@ THREE.Box3.prototype = {
this
.
max
.
copy
(
box
.
max
);
return
this
;
},
makeEmpty
:
function
()
{
...
...
@@ -112,41 +91,41 @@ THREE.Box3.prototype = {
this
.
max
.
x
=
this
.
max
.
y
=
this
.
max
.
z
=
-
Infinity
;
return
this
;
},
empty
:
function
()
{
// this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes
return
(
this
.
max
.
x
<
this
.
min
.
x
)
||
(
this
.
max
.
y
<
this
.
min
.
y
)
||
(
this
.
max
.
z
<
this
.
min
.
z
);
return
(
this
.
max
.
x
<
this
.
min
.
x
)
||
(
this
.
max
.
y
<
this
.
min
.
y
)
||
(
this
.
max
.
z
<
this
.
min
.
z
);
},
volume
:
function
()
{
return
(
this
.
max
.
x
-
this
.
min
.
x
)
*
(
this
.
max
.
y
-
this
.
min
.
y
)
*
(
this
.
max
.
z
-
this
.
min
.
z
);
return
(
this
.
max
.
x
-
this
.
min
.
x
)
*
(
this
.
max
.
y
-
this
.
min
.
y
)
*
(
this
.
max
.
z
-
this
.
min
.
z
);
},
center
:
function
()
{
return
new
THREE
.
Vector3
().
add
(
this
.
min
,
this
.
max
).
multiplyScalar
(
0.5
);
},
size
:
function
()
{
return
new
THREE
.
Vector3
().
sub
(
this
.
max
,
this
.
min
);
},
expandByPoint
:
function
(
point
)
{
this
.
min
.
minSelf
(
point
);
this
.
min
.
minSelf
(
point
);
this
.
max
.
maxSelf
(
point
);
return
this
;
},
expandByVector
:
function
(
vector
)
{
...
...
@@ -155,93 +134,76 @@ THREE.Box3.prototype = {
this
.
max
.
addSelf
(
vector
);
return
this
;
},
expandByScalar
:
function
(
scalar
)
{
this
.
min
.
addScalar
(
-
scalar
);
this
.
max
.
addScalar
(
scalar
);
return
this
;
},
containsPoint
:
function
(
point
)
{
if
(
(
this
.
min
.
x
<=
point
.
x
)
&&
(
point
.
x
<=
this
.
max
.
x
)
&&
if
(
(
this
.
min
.
x
<=
point
.
x
)
&&
(
point
.
x
<=
this
.
max
.
x
)
&&
(
this
.
min
.
y
<=
point
.
y
)
&&
(
point
.
y
<=
this
.
max
.
y
)
&&
(
this
.
min
.
z
<=
point
.
z
)
&&
(
point
.
z
<=
this
.
max
.
z
)
)
{
(
this
.
min
.
z
<=
point
.
z
)
&&
(
point
.
z
<=
this
.
max
.
z
)
)
{
return
true
;
}
return
false
;
},
containsBox
:
function
(
box
)
{
if
(
(
this
.
min
.
x
<=
box
.
min
.
x
)
&&
(
box
.
max
.
x
<=
this
.
max
.
x
)
&&
if
(
(
this
.
min
.
x
<=
box
.
min
.
x
)
&&
(
box
.
max
.
x
<=
this
.
max
.
x
)
&&
(
this
.
min
.
y
<=
box
.
min
.
y
)
&&
(
box
.
max
.
y
<=
this
.
max
.
y
)
&&
(
this
.
min
.
z
<=
box
.
min
.
z
)
&&
(
box
.
max
.
z
<=
this
.
max
.
z
)
)
{
(
this
.
min
.
z
<=
box
.
min
.
z
)
&&
(
box
.
max
.
z
<=
this
.
max
.
z
)
)
{
return
true
;
}
return
false
;
},
getParameter
:
function
(
point
)
{
// This can potentially have a divide by zero if the box
// has a size dimension of 0.
return
new
THREE
.
Vector3
(
(
point
.
x
-
this
.
min
.
x
)
/
(
this
.
max
.
x
-
this
.
min
.
x
),
(
point
.
y
-
this
.
min
.
y
)
/
(
this
.
max
.
y
-
this
.
min
.
y
),
(
point
.
z
-
this
.
min
.
z
)
/
(
this
.
max
.
z
-
this
.
min
.
z
)
);
},
isIntersection
:
function
(
box
)
{
// using 6 splitting planes to rule out intersections.
if
(
(
this
.
max
.
x
<
box
.
min
.
x
)
||
(
box
.
min
.
x
>
this
.
max
.
x
)
||
(
this
.
max
.
y
<
box
.
min
.
y
)
||
(
box
.
min
.
y
>
this
.
max
.
y
)
||
(
this
.
max
.
z
<
box
.
min
.
z
)
||
(
box
.
min
.
z
>
this
.
max
.
z
)
)
{
return
false
;
}
return
true
;
);
},
clampPoint
:
function
(
point
)
{
return
new
THREE
.
Vector3
().
copy
(
point
).
clampSelf
(
this
.
min
,
this
.
max
);
},
distanceToPoint
:
function
(
point
)
{
return
this
.
clampPoint
(
point
).
subSelf
(
point
).
length
();
},
isIntersection
:
function
(
box
)
{
// using 6 splitting planes to rule out intersections.
if
(
(
this
.
max
.
x
<
box
.
min
.
x
)
||
(
box
.
min
.
x
>
this
.
max
.
x
)
||
(
this
.
max
.
y
<
box
.
min
.
y
)
||
(
box
.
min
.
y
>
this
.
max
.
y
)
||
(
this
.
max
.
z
<
box
.
min
.
z
)
||
(
box
.
min
.
z
>
this
.
max
.
z
)
)
{
return
false
;
}
return
true
;
},
intersect
:
function
(
box
)
{
this
.
min
.
maxSelf
(
box
.
min
);
this
.
max
.
minSelf
(
box
.
max
);
return
this
;
},
union
:
function
(
box
)
{
...
...
@@ -250,7 +212,6 @@ THREE.Box3.prototype = {
this
.
max
.
maxSelf
(
box
.
max
);
return
this
;
},
translate
:
function
(
offset
)
{
...
...
@@ -259,7 +220,6 @@ THREE.Box3.prototype = {
this
.
max
.
addSelf
(
offset
);
return
this
;
},
scale
:
function
(
factor
)
{
...
...
@@ -268,7 +228,6 @@ THREE.Box3.prototype = {
this
.
expandByVector
(
sizeDeltaHalf
);
return
this
;
},
equals
:
function
(
box
)
{
...
...
@@ -282,7 +241,7 @@ THREE.Box3.prototype = {
return
new
THREE
.
Box3
().
copy
(
this
);
}
};
THREE
.
Box3
.
__v1
=
new
THREE
.
Vector3
();
THREE
.
Box3
.
__v1
=
new
THREE
.
Vector3
();
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录