Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
c70714de
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,发现更多精彩内容 >>
提交
c70714de
编写于
12月 03, 2012
作者:
B
Ben Houston
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
many more unit tests passing, still ~30 failing.
上级
3e20c628
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
93 addition
and
31 deletion
+93
-31
src/core/Box2.js
src/core/Box2.js
+10
-7
src/core/Box3.js
src/core/Box3.js
+9
-6
src/core/Plane.js
src/core/Plane.js
+13
-4
src/core/Sphere.js
src/core/Sphere.js
+13
-3
test/core/Box2.js
test/core/Box2.js
+42
-5
test/core/Constants.js
test/core/Constants.js
+1
-1
test/core/Plane.js
test/core/Plane.js
+2
-2
test/core/Sphere.js
test/core/Sphere.js
+3
-3
未找到文件。
src/core/Box2.js
浏览文件 @
c70714de
...
...
@@ -11,10 +11,13 @@ THREE.Box2 = function ( min, max ) {
this
.
makeEmpty
();
}
else
{
this
.
min
=
min
||
new
THREE
.
Vector2
();
this
.
max
=
max
||
new
THREE
.
Vector2
().
copy
(
this
.
min
);
// This is done on purpose so you can make a box using a single point and then expand it.
this
.
min
=
min
.
clone
();
if
(
max
===
undefined
)
{
this
.
max
=
new
THREE
.
Vector2
().
copy
(
this
.
min
);
// This is done on purpose so you can make a box using a single point and then expand it.
}
else
{
this
.
max
=
max
.
clone
();
}
}
};
...
...
@@ -25,8 +28,8 @@ THREE.Box2.prototype = {
set
:
function
(
min
,
max
)
{
this
.
min
=
min
;
this
.
max
=
max
;
this
.
min
.
copy
(
min
)
;
this
.
max
.
copy
(
max
)
;
return
this
;
},
...
...
@@ -112,7 +115,7 @@ THREE.Box2.prototype = {
},
area
:
function
()
{
volume
:
function
()
{
return
(
this
.
max
.
x
-
this
.
min
.
x
)
*
(
this
.
max
.
y
-
this
.
min
.
y
);
...
...
src/core/Box3.js
浏览文件 @
c70714de
...
...
@@ -11,10 +11,13 @@ THREE.Box3 = function ( min, max ) {
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
.
min
=
min
.
clone
();
if
(
max
===
undefined
)
{
this
.
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.
}
else
{
this
.
max
=
max
.
clone
();
}
}
};
...
...
@@ -25,8 +28,8 @@ THREE.Box3.prototype = {
set
:
function
(
min
,
max
)
{
this
.
min
=
min
;
this
.
max
=
max
;
this
.
min
.
copy
(
min
)
;
this
.
max
.
copy
(
max
)
;
return
this
;
...
...
src/core/Plane.js
浏览文件 @
c70714de
...
...
@@ -4,8 +4,17 @@
THREE
.
Plane
=
function
(
normal
,
constant
)
{
this
.
normal
=
normal
||
new
THREE
.
Vector3
();
this
.
constant
=
constant
||
0
;
if
(
normal
===
undefined
&&
constant
===
undefined
)
{
this
.
normal
=
new
THREE
.
Vector3
();
this
.
constant
=
0
;
}
else
{
this
.
normal
=
normal
.
clone
();
this
.
constant
=
constant
||
0
;
}
};
...
...
@@ -15,7 +24,7 @@ THREE.Plane.prototype = {
set
:
function
(
normal
,
constant
)
{
this
.
normal
=
normal
;
this
.
normal
.
copy
(
normal
)
;
this
.
constant
=
constant
;
return
this
;
...
...
@@ -33,7 +42,7 @@ THREE.Plane.prototype = {
setFromNormalAndCoplanarPoint
:
function
(
normal
,
point
)
{
this
.
normal
=
normal
;
this
.
normal
.
copy
(
normal
)
;
this
.
constant
=
-
point
.
dot
(
normal
);
return
this
;
...
...
src/core/Sphere.js
浏览文件 @
c70714de
...
...
@@ -4,9 +4,19 @@
THREE
.
Sphere
=
function
(
center
,
radius
)
{
this
.
center
=
center
||
new
THREE
.
Vector3
();
this
.
radius
=
radius
||
0
;
if
(
center
===
undefined
&&
radius
===
undefined
)
{
this
.
center
=
new
THREE
.
Vector3
();
this
.
radius
=
0
;
}
else
{
this
.
center
=
center
.
clone
();
this
.
radius
=
radius
||
0
;
}
};
THREE
.
Sphere
.
prototype
=
{
...
...
@@ -15,7 +25,7 @@ THREE.Sphere.prototype = {
set
:
function
(
center
,
radius
)
{
this
.
center
=
center
;
this
.
center
.
copy
(
center
)
;
this
.
radius
=
radius
;
return
this
;
...
...
test/core/Box2.js
浏览文件 @
c70714de
...
...
@@ -4,6 +4,14 @@
module
(
"
Box2
"
);
test
(
"
verifyConstants=beginning
"
,
function
()
{
ok
(
negInf
.
equals
(
new
THREE
.
Vector3
(
-
Infinity
,
-
Infinity
)
),
"
Passed!
"
);
ok
(
posInf
.
equals
(
new
THREE
.
Vector3
(
Infinity
,
Infinity
)
),
"
Passed!
"
);
ok
(
zero
.
equals
(
new
THREE
.
Vector3
(
0
,
0
,
0
)
),
"
Passed!
"
);
ok
(
one
.
equals
(
new
THREE
.
Vector3
(
1
,
1
,
1
)
),
"
Passed!
"
);
ok
(
two
.
equals
(
new
THREE
.
Vector3
(
2
,
2
,
2
)
),
"
Passed!
"
);
});
test
(
"
constructor
"
,
function
()
{
var
a
=
new
THREE
.
Box2
();
ok
(
a
.
min
.
equals
(
posInf
),
"
Passed!
"
);
...
...
@@ -15,9 +23,13 @@ test( "constructor", function() {
a
=
new
THREE
.
Box2
(
zero
,
one
);
ok
(
a
.
min
.
equals
(
zero
),
"
Passed!
"
);
console
.
log
(
"
constructor
"
);
console
.
log
(
a
);
console
.
log
(
one
);
ok
(
a
.
max
.
equals
(
one
),
"
Passed!
"
);
});
test
(
"
copy
"
,
function
()
{
var
a
=
new
THREE
.
Box2
(
zero
,
one
);
var
b
=
new
THREE
.
Box2
().
copy
(
a
);
...
...
@@ -51,9 +63,12 @@ test( "empty/makeEmpty", function() {
ok
(
a
.
empty
(),
"
Passed!
"
);
});
test
(
"
area
"
,
function
()
{
test
(
"
volume
"
,
function
()
{
var
a
=
new
THREE
.
Box2
(
zero
,
one
);
ok
(
a
.
area
()
==
1
,
"
Passed!
"
);
ok
(
a
.
volume
()
==
1
,
"
Passed!
"
);
a
=
new
THREE
.
Box2
(
one
.
clone
().
negate
(),
zero
);
ok
(
a
.
volume
()
==
1
,
"
Passed!
"
);
});
test
(
"
center
"
,
function
()
{
...
...
@@ -66,6 +81,14 @@ test( "center", function() {
ok
(
a
.
center
().
equals
(
midpoint
),
"
Passed!
"
);
});
test
(
"
verifyConstants1
"
,
function
()
{
ok
(
negInf
.
equals
(
new
THREE
.
Vector3
(
-
Infinity
,
-
Infinity
)
),
"
Passed!
"
);
ok
(
posInf
.
equals
(
new
THREE
.
Vector3
(
Infinity
,
Infinity
)
),
"
Passed!
"
);
ok
(
zero
.
equals
(
new
THREE
.
Vector3
(
0
,
0
,
0
)
),
"
Passed!
"
);
ok
(
one
.
equals
(
new
THREE
.
Vector3
(
1
,
1
,
1
)
),
"
Passed!
"
);
ok
(
two
.
equals
(
new
THREE
.
Vector3
(
2
,
2
,
2
)
),
"
Passed!
"
);
});
test
(
"
size
"
,
function
()
{
var
a
=
new
THREE
.
Box2
(
zero
);
...
...
@@ -86,8 +109,10 @@ test( "expandByPoint", function() {
a
.
expandByPoint
(
one
.
clone
().
negate
()
);
ok
(
a
.
size
().
equals
(
one
.
clone
().
multiplyScalar
(
2
)
),
"
Passed!
"
);
console
.
log
(
"
expandByPoint
"
);
console
.
log
(
a
);
console
.
log
(
a
.
center
()
);
console
.
log
(
zero
);
ok
(
a
.
center
().
equals
(
zero
),
"
Passed!
"
);
});
...
...
@@ -155,7 +180,7 @@ test( "getParameter", function() {
});
test
(
"
clampPoint
"
,
function
()
{
var
a
=
new
THREE
.
Box2
(
zero
,
one
);
var
a
=
new
THREE
.
Box2
(
zero
,
zero
);
var
b
=
new
THREE
.
Box2
(
one
.
clone
().
negate
(),
one
);
ok
(
a
.
clampPoint
(
new
THREE
.
Vector2
(
0
,
0
)
).
equals
(
new
THREE
.
Vector2
(
0
,
0
)
),
"
Passed!
"
);
...
...
@@ -170,7 +195,7 @@ test( "clampPoint", function() {
});
test
(
"
distanceToPoint
"
,
function
()
{
var
a
=
new
THREE
.
Box2
(
zero
,
one
);
var
a
=
new
THREE
.
Box2
(
zero
,
zero
);
var
b
=
new
THREE
.
Box2
(
one
.
clone
().
negate
(),
one
);
ok
(
a
.
distanceToPoint
(
new
THREE
.
Vector2
(
0
,
0
)
)
==
0
,
"
Passed!
"
);
...
...
@@ -185,7 +210,7 @@ test( "distanceToPoint", function() {
});
test
(
"
distanceToPoint
"
,
function
()
{
var
a
=
new
THREE
.
Box2
(
zero
,
one
);
var
a
=
new
THREE
.
Box2
(
zero
,
zero
);
var
b
=
new
THREE
.
Box2
(
one
.
clone
().
negate
(),
one
);
ok
(
a
.
distanceToPoint
(
new
THREE
.
Vector2
(
0
,
0
)
)
==
0
,
"
Passed!
"
);
...
...
@@ -213,6 +238,10 @@ test( "isIntersection", function() {
ok
(
b
.
isIntersection
(
c
),
"
Passed!
"
);
b
.
translate
(
new
THREE
.
Vector2
(
2
,
2
)
);
console
.
log
(
"
isIntersection
"
);
console
.
log
(
a
);
console
.
log
(
b
);
console
.
log
(
c
);
ok
(
!
a
.
isIntersection
(
b
),
"
Passed!
"
);
ok
(
!
b
.
isIntersection
(
a
),
"
Passed!
"
);
ok
(
!
c
.
isIntersection
(
a
),
"
Passed!
"
);
...
...
@@ -265,3 +294,11 @@ test( "scale", function() {
ok
(
b
.
clone
().
scale
(
2
).
equals
(
new
THREE
.
Box2
(
zero
,
new
THREE
.
Vector2
(
2
,
2
)
)
),
"
Passed!
"
);
ok
(
d
.
clone
().
scale
(
2
).
equals
(
new
THREE
.
Box2
(
new
THREE
.
Vector2
(
2
,
2
).
negate
(),
zero
)
),
"
Passed!
"
);
});
test
(
"
verifyConstants-end
"
,
function
()
{
ok
(
negInf
.
equals
(
new
THREE
.
Vector3
(
-
Infinity
,
-
Infinity
)
),
"
Passed!
"
);
ok
(
posInf
.
equals
(
new
THREE
.
Vector3
(
Infinity
,
Infinity
)
),
"
Passed!
"
);
ok
(
zero
.
equals
(
new
THREE
.
Vector3
(
0
,
0
,
0
)
),
"
Passed!
"
);
ok
(
one
.
equals
(
new
THREE
.
Vector3
(
1
,
1
,
1
)
),
"
Passed!
"
);
ok
(
two
.
equals
(
new
THREE
.
Vector3
(
2
,
2
,
2
)
),
"
Passed!
"
);
});
test/core/Constants.js
浏览文件 @
c70714de
...
...
@@ -12,4 +12,4 @@ var posInf = new THREE.Vector3( Infinity, Infinity );
var
zero
=
new
THREE
.
Vector3
();
var
one
=
new
THREE
.
Vector3
(
1
,
1
,
1
);
var
two
=
new
THREE
.
Vector3
(
1
,
1
,
1
);
var
two
=
new
THREE
.
Vector3
(
2
,
2
,
2
);
test/core/Plane.js
浏览文件 @
c70714de
...
...
@@ -87,10 +87,10 @@ test( "flip", function() {
});
test
(
"
normalize
"
,
function
()
{
var
a
=
new
THREE
.
Plane
(
two
,
2
);
var
a
=
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
2
,
0
,
0
)
,
2
);
a
.
normalize
();
ok
(
a
.
normal
.
length
()
==
1
,
"
Passed!
"
);
ok
(
a
.
normal
.
equals
(
one
),
"
Passed!
"
);
ok
(
a
.
normal
.
equals
(
new
THREE
.
Vector3
(
1
,
0
,
0
)
),
"
Passed!
"
);
ok
(
a
.
constant
==
1
,
"
Passed!
"
);
});
test/core/Sphere.js
浏览文件 @
c70714de
...
...
@@ -11,7 +11,7 @@ test( "constructor", function() {
a
=
new
THREE
.
Sphere
(
one
,
1
);
ok
(
a
.
center
.
equals
(
one
),
"
Passed!
"
);
ok
(
a
.
radius
==
0
,
"
Passed!
"
);
ok
(
a
.
radius
==
1
,
"
Passed!
"
);
});
test
(
"
copy
"
,
function
()
{
...
...
@@ -19,13 +19,13 @@ test( "copy", function() {
var
b
=
new
THREE
.
Sphere
().
copy
(
a
);
ok
(
b
.
center
.
equals
(
one
),
"
Passed!
"
);
ok
(
b
.
radius
==
0
,
"
Passed!
"
);
ok
(
b
.
radius
==
1
,
"
Passed!
"
);
// ensure that it is a true copy
a
.
center
=
zero
;
a
.
radius
=
0
;
ok
(
b
.
center
.
equals
(
one
),
"
Passed!
"
);
ok
(
b
.
radius
==
0
,
"
Passed!
"
);
ok
(
b
.
radius
==
1
,
"
Passed!
"
);
});
test
(
"
set
"
,
function
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录