Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
c1fa178d
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,发现更多精彩内容 >>
提交
c1fa178d
编写于
12月 10, 2012
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'bhouston/transform' into dev
上级
af52210c
26b57b81
变更
27
隐藏空白更改
内联
并排
Showing
27 changed file
with
416 addition
and
119 deletion
+416
-119
examples/css3d_molecules.html
examples/css3d_molecules.html
+1
-1
examples/webgl_geometry_minecraft.html
examples/webgl_geometry_minecraft.html
+10
-5
examples/webgl_geometry_minecraft_ao.html
examples/webgl_geometry_minecraft_ao.html
+10
-5
examples/webgl_geometry_subdivision.html
examples/webgl_geometry_subdivision.html
+1
-1
src/core/Raycaster.js
src/core/Raycaster.js
+1
-1
src/extras/GeometryUtils.js
src/extras/GeometryUtils.js
+1
-1
src/math/Box2.js
src/math/Box2.js
+0
-9
src/math/Box3.js
src/math/Box3.js
+26
-7
src/math/Matrix4.js
src/math/Matrix4.js
+9
-9
src/math/Plane.js
src/math/Plane.js
+24
-5
src/math/Ray.js
src/math/Ray.js
+1
-1
src/math/Sphere.js
src/math/Sphere.js
+7
-6
test/math/Box2.js
test/math/Box2.js
+1
-13
test/math/Box3.js
test/math/Box3.js
+20
-10
test/math/Constants.js
test/math/Constants.js
+0
-0
test/math/Plane.js
test/math/Plane.js
+164
-0
test/math/Ray.js
test/math/Ray.js
+5
-5
test/math/Sphere.js
test/math/Sphere.js
+94
-0
test/math/Triangle.js
test/math/Triangle.js
+0
-0
test/math/Vector2.js
test/math/Vector2.js
+0
-0
test/math/Vector3.js
test/math/Vector3.js
+0
-0
test/math/Vector4.js
test/math/Vector4.js
+0
-0
test/sources.html
test/sources.html
+10
-10
test/three-math.html
test/three-math.html
+10
-10
test/three.html
test/three.html
+10
-10
test/three.min.html
test/three.min.html
+10
-10
utils/build_all.bat
utils/build_all.bat
+1
-0
未找到文件。
examples/css3d_molecules.html
浏览文件 @
c1fa178d
...
...
@@ -361,7 +361,7 @@
loader
.
load
(
url
,
function
(
geometry
,
geometryBonds
)
{
var
offset
=
THREE
.
GeometryUtils
.
center
(
geometry
);
geometryBonds
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
offset
.
x
,
offset
.
y
,
offset
.
z
)
);
geometryBonds
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
offset
)
);
for
(
var
i
=
0
;
i
<
geometry
.
vertices
.
length
;
i
++
)
{
...
...
examples/webgl_geometry_minecraft.html
浏览文件 @
c1fa178d
...
...
@@ -93,26 +93,31 @@
var
pxGeometry
=
new
THREE
.
PlaneGeometry
(
100
,
100
);
pxGeometry
.
faces
[
0
].
materialIndex
=
1
;
pxGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeRotationY
(
Math
.
PI
/
2
)
);
pxGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
50
,
0
,
0
)
);
pxGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
new
THREE
.
Vector3
(
50
,
0
,
0
)
)
);
var
nxGeometry
=
new
THREE
.
PlaneGeometry
(
100
,
100
);
nxGeometry
.
faces
[
0
].
materialIndex
=
1
;
nxGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeRotationY
(
-
Math
.
PI
/
2
)
);
nxGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
-
50
,
0
,
0
)
);
nxGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
new
THREE
.
Vector3
(
-
50
,
0
,
0
)
)
);
var
pyGeometry
=
new
THREE
.
PlaneGeometry
(
100
,
100
);
pyGeometry
.
faces
[
0
].
materialIndex
=
0
;
pyGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeRotationX
(
-
Math
.
PI
/
2
)
);
pyGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
0
,
50
,
0
)
);
pyGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
new
THREE
.
Vector3
(
0
,
50
,
0
)
)
);
var
pzGeometry
=
new
THREE
.
PlaneGeometry
(
100
,
100
);
pzGeometry
.
faces
[
0
].
materialIndex
=
1
;
pzGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
0
,
0
,
50
)
);
pzGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
new
THREE
.
Vector3
(
0
,
0
,
50
)
)
);
var
nzGeometry
=
new
THREE
.
PlaneGeometry
(
100
,
100
);
nzGeometry
.
faces
[
0
].
materialIndex
=
1
;
nzGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeRotationY
(
Math
.
PI
)
);
nzGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
0
,
0
,
-
50
)
);
nzGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
new
THREE
.
Vector3
(
0
,
0
,
-
50
)
)
);
//
...
...
examples/webgl_geometry_minecraft_ao.html
浏览文件 @
c1fa178d
...
...
@@ -104,30 +104,35 @@
pxGeometry
.
faces
[
0
].
materialIndex
=
1
;
pxGeometry
.
faces
[
0
].
vertexColors
=
[
light
,
shadow
,
shadow
,
light
];
pxGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeRotationY
(
Math
.
PI
/
2
)
);
pxGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
50
,
0
,
0
)
);
pxGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
new
THREE
.
Vector3
(
50
,
0
,
0
)
)
);
var
nxGeometry
=
new
THREE
.
PlaneGeometry
(
100
,
100
);
nxGeometry
.
faces
[
0
].
materialIndex
=
1
;
nxGeometry
.
faces
[
0
].
vertexColors
=
[
light
,
shadow
,
shadow
,
light
];
nxGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeRotationY
(
-
Math
.
PI
/
2
)
);
nxGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
-
50
,
0
,
0
)
);
nxGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
new
THREE
.
Vector3
(
-
50
,
0
,
0
)
)
);
var
pyGeometry
=
new
THREE
.
PlaneGeometry
(
100
,
100
);
pyGeometry
.
faces
[
0
].
materialIndex
=
0
;
pyGeometry
.
faces
[
0
].
vertexColors
=
[
light
,
light
,
light
,
light
];
pyGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeRotationX
(
-
Math
.
PI
/
2
)
);
pyGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
0
,
50
,
0
)
);
pyGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
new
THREE
.
Vector3
(
0
,
50
,
0
)
)
);
var
pzGeometry
=
new
THREE
.
PlaneGeometry
(
100
,
100
);
pzGeometry
.
faces
[
0
].
materialIndex
=
1
;
pzGeometry
.
faces
[
0
].
vertexColors
=
[
light
,
shadow
,
shadow
,
light
];
pzGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
0
,
0
,
50
)
);
pzGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
new
THREE
.
Vector3
(
0
,
0
,
50
)
)
);
var
nzGeometry
=
new
THREE
.
PlaneGeometry
(
100
,
100
);
nzGeometry
.
faces
[
0
].
materialIndex
=
1
;
nzGeometry
.
faces
[
0
].
vertexColors
=
[
light
,
shadow
,
shadow
,
light
];
nzGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeRotationY
(
Math
.
PI
)
);
nzGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
0
,
0
,
-
50
)
);
nzGeometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
new
THREE
.
Vector3
(
0
,
0
,
-
50
)
)
);
//
...
...
examples/webgl_geometry_subdivision.html
浏览文件 @
c1fa178d
...
...
@@ -212,7 +212,7 @@
if
(
params
.
scale
)
{
geometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeScale
(
params
.
scale
,
params
.
scale
,
params
.
scale
)
);
geometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeScale
(
new
THREE
.
Vector3
(
params
.
scale
,
params
.
scale
,
params
.
scale
)
)
);
}
...
...
src/core/Raycaster.js
浏览文件 @
c1fa178d
...
...
@@ -89,7 +89,7 @@
inverseMatrix
.
getInverse
(
object
.
matrixWorld
);
localRay
.
copy
(
raycaster
.
ray
).
transform
Self
(
inverseMatrix
);
localRay
.
copy
(
raycaster
.
ray
).
transform
(
inverseMatrix
);
for
(
var
f
=
0
,
fl
=
geometry
.
faces
.
length
;
f
<
fl
;
f
++
)
{
...
...
src/extras/GeometryUtils.js
浏览文件 @
c1fa178d
...
...
@@ -383,7 +383,7 @@ THREE.GeometryUtils = {
offset
.
add
(
bb
.
min
,
bb
.
max
);
offset
.
multiplyScalar
(
-
0.5
);
geometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
offset
.
x
,
offset
.
y
,
offset
.
z
)
);
geometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
makeTranslation
(
offset
)
);
geometry
.
computeBoundingBox
();
return
offset
;
...
...
src/math/Box2.js
浏览文件 @
c1fa178d
...
...
@@ -237,15 +237,6 @@ THREE.Box2.prototype = {
},
scale
:
function
(
factor
)
{
var
sizeDeltaHalf
=
this
.
size
().
multiplyScalar
(
(
factor
-
1
)
*
0.5
);
this
.
expandByVector
(
sizeDeltaHalf
);
return
this
;
},
equals
:
function
(
box
)
{
return
box
.
min
.
equals
(
this
.
min
)
&&
box
.
max
.
equals
(
this
.
max
);
...
...
src/math/Box3.js
浏览文件 @
c1fa178d
...
...
@@ -244,19 +244,31 @@ THREE.Box3.prototype = {
},
translate
:
function
(
offset
)
{
this
.
min
.
addSelf
(
offset
);
this
.
max
.
addSelf
(
offset
);
transform
:
function
(
matrix
)
{
// NOTE: I am using a binary pattern to specify all 2^3 combinations below
var
newPoints
=
[
matrix
.
multiplyVector3
(
THREE
.
Box3
.
__v0
.
set
(
this
.
min
.
x
,
this
.
min
.
y
,
this
.
min
.
z
)
),
// 000
matrix
.
multiplyVector3
(
THREE
.
Box3
.
__v1
.
set
(
this
.
min
.
x
,
this
.
min
.
y
,
this
.
max
.
z
)
),
// 001
matrix
.
multiplyVector3
(
THREE
.
Box3
.
__v2
.
set
(
this
.
min
.
x
,
this
.
max
.
y
,
this
.
min
.
z
)
),
// 010
matrix
.
multiplyVector3
(
THREE
.
Box3
.
__v3
.
set
(
this
.
min
.
x
,
this
.
max
.
y
,
this
.
max
.
z
)
),
// 011
matrix
.
multiplyVector3
(
THREE
.
Box3
.
__v4
.
set
(
this
.
max
.
x
,
this
.
min
.
y
,
this
.
min
.
z
)
),
// 100
matrix
.
multiplyVector3
(
THREE
.
Box3
.
__v5
.
set
(
this
.
max
.
x
,
this
.
min
.
y
,
this
.
max
.
z
)
),
// 101
matrix
.
multiplyVector3
(
THREE
.
Box3
.
__v6
.
set
(
this
.
max
.
x
,
this
.
max
.
y
,
this
.
min
.
z
)
),
// 110
matrix
.
multiplyVector3
(
THREE
.
Box3
.
__v7
.
set
(
this
.
max
.
x
,
this
.
max
.
y
,
this
.
max
.
z
)
)
// 111
];
this
.
makeEmpty
();
this
.
setFromPoints
(
newPoints
);
return
this
;
},
scale
:
function
(
factor
)
{
translate
:
function
(
offset
)
{
var
sizeDeltaHalf
=
this
.
size
().
multiplyScalar
(
(
factor
-
1
)
*
0.5
);
this
.
expandByVector
(
sizeDeltaHalf
);
this
.
min
.
addSelf
(
offset
);
this
.
max
.
addSelf
(
offset
);
return
this
;
...
...
@@ -276,4 +288,11 @@ THREE.Box3.prototype = {
};
THREE
.
Box3
.
__v0
=
new
THREE
.
Vector3
();
THREE
.
Box3
.
__v1
=
new
THREE
.
Vector3
();
THREE
.
Box3
.
__v2
=
new
THREE
.
Vector3
();
THREE
.
Box3
.
__v3
=
new
THREE
.
Vector3
();
THREE
.
Box3
.
__v4
=
new
THREE
.
Vector3
();
THREE
.
Box3
.
__v5
=
new
THREE
.
Vector3
();
THREE
.
Box3
.
__v6
=
new
THREE
.
Vector3
();
THREE
.
Box3
.
__v7
=
new
THREE
.
Vector3
();
src/math/Matrix4.js
浏览文件 @
c1fa178d
...
...
@@ -587,7 +587,7 @@ THREE.Matrix4.prototype = {
mRotation
.
identity
();
mRotation
.
setRotationFromQuaternion
(
rotation
);
mScale
.
makeScale
(
scale
.
x
,
scale
.
y
,
scale
.
z
);
mScale
.
makeScale
(
scale
);
this
.
multiply
(
mRotation
,
mScale
);
...
...
@@ -888,13 +888,13 @@ THREE.Matrix4.prototype = {
//
makeTranslation
:
function
(
x
,
y
,
z
)
{
makeTranslation
:
function
(
offset
)
{
this
.
set
(
1
,
0
,
0
,
x
,
0
,
1
,
0
,
y
,
0
,
0
,
1
,
z
,
1
,
0
,
0
,
offset
.
x
,
0
,
1
,
0
,
offset
.
y
,
0
,
0
,
1
,
offset
.
z
,
0
,
0
,
0
,
1
);
...
...
@@ -977,13 +977,13 @@ THREE.Matrix4.prototype = {
},
makeScale
:
function
(
x
,
y
,
z
)
{
makeScale
:
function
(
factor
)
{
this
.
set
(
x
,
0
,
0
,
0
,
0
,
y
,
0
,
0
,
0
,
0
,
z
,
0
,
factor
.
x
,
0
,
0
,
0
,
0
,
factor
.
y
,
0
,
0
,
0
,
0
,
factor
.
z
,
0
,
0
,
0
,
0
,
1
);
...
...
src/math/Plane.js
浏览文件 @
c1fa178d
...
...
@@ -4,7 +4,7 @@
THREE
.
Plane
=
function
(
normal
,
constant
)
{
this
.
normal
=
normal
!==
undefined
?
normal
.
clone
()
:
new
THREE
.
Vector3
();
this
.
normal
=
normal
!==
undefined
?
normal
.
clone
()
:
new
THREE
.
Vector3
(
1
,
0
,
0
);
this
.
constant
=
constant
!==
undefined
?
constant
:
0
;
};
...
...
@@ -33,8 +33,8 @@ THREE.Plane.prototype = {
setFromNormalAndCoplanarPoint
:
function
(
normal
,
point
)
{
this
.
normal
.
copy
(
normal
);
this
.
constant
=
-
point
.
dot
(
normal
);
this
.
normal
.
copy
(
normal
)
.
normalize
()
;
this
.
constant
=
-
point
.
dot
(
this
.
normal
);
// must be this.normal, not normal, as this.normal is normalized
return
this
;
...
...
@@ -43,7 +43,7 @@ THREE.Plane.prototype = {
setFromCoplanarPoints
:
function
(
a
,
b
,
c
)
{
var
normal
=
THREE
.
Plane
.
__v1
.
sub
(
c
,
b
).
crossSelf
(
THREE
.
Plane
.
__v2
.
sub
(
a
,
b
)
);
THREE
.
Plane
.
__v2
.
sub
(
a
,
b
)
)
.
normalize
()
;
// Q: should an error be thrown if normal is zero (e.g. degenerate plane)?
...
...
@@ -119,9 +119,27 @@ THREE.Plane.prototype = {
},
transform
:
function
(
matrix
,
optionalNormalMatrix
)
{
var
newNormal
=
THREE
.
Plane
.
__v1
,
newCoplanarPoint
=
THREE
.
Plane
.
__v2
;
// compute new normal based on theory here:
// http://www.songho.ca/opengl/gl_normaltransform.html
optionalNormalMatrix
=
optionalNormalMatrix
||
new
THREE
.
Matrix3
().
getInverse
(
matrix
).
transpose
();
newNormal
=
optionalNormalMatrix
.
multiplyVector3
(
newNormal
.
copy
(
this
.
normal
)
);
newCoplanarPoint
=
this
.
coplanarPoint
(
newCoplanarPoint
);
newCoplanarPoint
=
matrix
.
multiplyVector3
(
newCoplanarPoint
);
this
.
setFromNormalAndCoplanarPoint
(
newNormal
,
newCoplanarPoint
);
return
this
;
},
translate
:
function
(
offset
)
{
this
.
constant
=
-
offset
.
dot
(
this
.
normal
);
this
.
constant
=
this
.
constant
-
offset
.
dot
(
this
.
normal
);
return
this
;
...
...
@@ -141,5 +159,6 @@ THREE.Plane.prototype = {
};
THREE
.
Plane
.
__vZero
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
THREE
.
Plane
.
__v1
=
new
THREE
.
Vector3
();
THREE
.
Plane
.
__v2
=
new
THREE
.
Vector3
();
src/math/Ray.js
浏览文件 @
c1fa178d
...
...
@@ -131,7 +131,7 @@ THREE.Ray.prototype = {
},
transform
Self
:
function
(
matrix4
)
{
transform
:
function
(
matrix4
)
{
this
.
direction
=
matrix4
.
multiplyVector3
(
this
.
direction
.
addSelf
(
this
.
origin
)
);
this
.
origin
=
matrix4
.
multiplyVector3
(
this
.
origin
);
...
...
src/math/Sphere.js
浏览文件 @
c1fa178d
...
...
@@ -96,17 +96,18 @@ THREE.Sphere.prototype = {
},
translate
:
function
(
offset
)
{
this
.
center
.
addSelf
(
this
.
offset
);
transform
:
function
(
matrix
)
{
this
.
center
=
matrix
.
multiplyVector3
(
this
.
center
);
this
.
radius
=
this
.
radius
*
matrix
.
getMaxScaleOnAxis
();
return
this
;
},
scale
:
function
(
factor
)
{
translate
:
function
(
offset
)
{
this
.
radius
*=
factor
;
this
.
center
.
addSelf
(
offset
)
;
return
this
;
...
...
@@ -120,7 +121,7 @@ THREE.Sphere.prototype = {
clone
:
function
()
{
return
new
THREE
.
Sphere
3
().
copy
(
this
);
return
new
THREE
.
Sphere
().
copy
(
this
);
}
...
...
test/
core
/Box2.js
→
test/
math
/Box2.js
浏览文件 @
c1fa178d
...
...
@@ -242,16 +242,4 @@ test( "translate", function() {
ok
(
a
.
clone
().
translate
(
one2
).
translate
(
one2
.
clone
().
negate
()
).
equals
(
a
),
"
Passed!
"
);
ok
(
d
.
clone
().
translate
(
one2
).
equals
(
b
),
"
Passed!
"
);
ok
(
b
.
clone
().
translate
(
one2
.
clone
().
negate
()
).
equals
(
d
),
"
Passed!
"
);
});
test
(
"
scale
"
,
function
()
{
var
a
=
new
THREE
.
Box2
(
zero2
,
zero2
);
var
b
=
new
THREE
.
Box2
(
zero2
,
one2
);
var
c
=
new
THREE
.
Box2
(
one2
.
clone
().
negate
(),
one2
);
var
d
=
new
THREE
.
Box2
(
one2
.
clone
().
negate
(),
zero2
);
ok
(
a
.
clone
().
scale
(
0
).
equals
(
a
),
"
Passed!
"
);
ok
(
c
.
clone
().
scale
(
0
).
equals
(
a
),
"
Passed!
"
);
ok
(
b
.
clone
().
scale
(
3
).
equals
(
new
THREE
.
Box2
(
new
THREE
.
Vector2
(
-
1
,
-
1
,
-
1
),
new
THREE
.
Vector2
(
2
,
2
,
2
)
)
),
"
Passed!
"
);
ok
(
d
.
clone
().
scale
(
3
).
equals
(
new
THREE
.
Box2
(
new
THREE
.
Vector2
(
2
,
2
,
2
).
negate
(),
new
THREE
.
Vector2
(
1
,
1
,
1
)
)
),
"
Passed!
"
);
});
});
\ No newline at end of file
test/
core
/Box3.js
→
test/
math
/Box3.js
浏览文件 @
c1fa178d
...
...
@@ -232,26 +232,36 @@ test( "union", function() {
ok
(
b
.
clone
().
union
(
c
).
equals
(
c
),
"
Passed!
"
);
});
test
(
"
translate
"
,
function
()
{
var
compareBox
=
function
(
a
,
b
,
threshold
)
{
threshold
=
threshold
||
0.0001
;
return
(
a
.
min
.
distanceTo
(
b
.
min
)
<
threshold
&&
a
.
max
.
distanceTo
(
b
.
max
)
<
threshold
);
};
test
(
"
transform
"
,
function
()
{
var
a
=
new
THREE
.
Box3
(
zero3
,
zero3
);
var
b
=
new
THREE
.
Box3
(
zero3
,
one3
);
var
c
=
new
THREE
.
Box3
(
one3
.
clone
().
negate
(),
one3
);
var
d
=
new
THREE
.
Box3
(
one3
.
clone
().
negate
(),
zero3
);
ok
(
a
.
clone
().
translate
(
one3
).
equals
(
new
THREE
.
Box3
(
one3
,
one3
)
),
"
Passed!
"
);
ok
(
a
.
clone
().
translate
(
one3
).
translate
(
one3
.
clone
().
negate
()
).
equals
(
a
),
"
Passed!
"
);
ok
(
d
.
clone
().
translate
(
one3
).
equals
(
b
),
"
Passed!
"
);
ok
(
b
.
clone
().
translate
(
one3
.
clone
().
negate
()
).
equals
(
d
),
"
Passed!
"
);
var
m
=
new
THREE
.
Matrix4
();
var
t1
=
new
THREE
.
Vector3
(
1
,
-
2
,
1
);
m
.
makeTranslation
(
t1
);
ok
(
compareBox
(
a
.
clone
().
transform
(
m
),
a
.
clone
().
translate
(
t1
)
),
"
Passed!
"
);
ok
(
compareBox
(
b
.
clone
().
transform
(
m
),
b
.
clone
().
translate
(
t1
)
),
"
Passed!
"
);
ok
(
compareBox
(
c
.
clone
().
transform
(
m
),
c
.
clone
().
translate
(
t1
)
),
"
Passed!
"
);
ok
(
compareBox
(
d
.
clone
().
transform
(
m
),
d
.
clone
().
translate
(
t1
)
),
"
Passed!
"
);
});
test
(
"
scal
e
"
,
function
()
{
test
(
"
translat
e
"
,
function
()
{
var
a
=
new
THREE
.
Box3
(
zero3
,
zero3
);
var
b
=
new
THREE
.
Box3
(
zero3
,
one3
);
var
c
=
new
THREE
.
Box3
(
one3
.
clone
().
negate
(),
one3
);
var
d
=
new
THREE
.
Box3
(
one3
.
clone
().
negate
(),
zero3
);
ok
(
a
.
clone
().
scale
(
0
).
equals
(
a
),
"
Passed!
"
);
ok
(
c
.
clone
().
scale
(
0
).
equals
(
a
),
"
Passed!
"
);
ok
(
b
.
clone
().
scale
(
3
).
equals
(
new
THREE
.
Box3
(
new
THREE
.
Vector3
(
-
1
,
-
1
,
-
1
),
new
THREE
.
Vector3
(
2
,
2
,
2
)
)
),
"
Passed!
"
);
ok
(
d
.
clone
().
scale
(
3
).
equals
(
new
THREE
.
Box3
(
new
THREE
.
Vector3
(
2
,
2
,
2
).
negate
(),
new
THREE
.
Vector3
(
1
,
1
,
1
)
)
),
"
Passed!
"
);
ok
(
a
.
clone
().
translate
(
one3
).
equals
(
new
THREE
.
Box3
(
one3
,
one3
)
),
"
Passed!
"
);
ok
(
a
.
clone
().
translate
(
one3
).
translate
(
one3
.
clone
().
negate
()
).
equals
(
a
),
"
Passed!
"
);
ok
(
d
.
clone
().
translate
(
one3
).
equals
(
b
),
"
Passed!
"
);
ok
(
b
.
clone
().
translate
(
one3
.
clone
().
negate
()
).
equals
(
d
),
"
Passed!
"
);
});
test/
core
/Constants.js
→
test/
math
/Constants.js
浏览文件 @
c1fa178d
文件已移动
test/
core
/Plane.js
→
test/
math
/Plane.js
浏览文件 @
c1fa178d
...
...
@@ -4,9 +4,16 @@
module
(
"
Plane
"
);
var
comparePlane
=
function
(
a
,
b
,
threshold
)
{
threshold
=
threshold
||
0.0001
;
return
(
a
.
normal
.
distanceTo
(
b
.
normal
)
<
threshold
&&
Math
.
abs
(
a
.
constant
-
b
.
constant
)
<
threshold
);
};
test
(
"
constructor
"
,
function
()
{
var
a
=
new
THREE
.
Plane
();
ok
(
a
.
normal
.
x
==
0
,
"
Passed!
"
);
ok
(
a
.
normal
.
x
==
1
,
"
Passed!
"
);
ok
(
a
.
normal
.
y
==
0
,
"
Passed!
"
);
ok
(
a
.
normal
.
z
==
0
,
"
Passed!
"
);
ok
(
a
.
constant
==
0
,
"
Passed!
"
);
...
...
@@ -45,7 +52,7 @@ test( "copy", function() {
test
(
"
set
"
,
function
()
{
var
a
=
new
THREE
.
Plane
();
ok
(
a
.
normal
.
x
==
0
,
"
Passed!
"
);
ok
(
a
.
normal
.
x
==
1
,
"
Passed!
"
);
ok
(
a
.
normal
.
y
==
0
,
"
Passed!
"
);
ok
(
a
.
normal
.
z
==
0
,
"
Passed!
"
);
ok
(
a
.
constant
==
0
,
"
Passed!
"
);
...
...
@@ -59,7 +66,7 @@ test( "set", function() {
test
(
"
setComponents
"
,
function
()
{
var
a
=
new
THREE
.
Plane
();
ok
(
a
.
normal
.
x
==
0
,
"
Passed!
"
);
ok
(
a
.
normal
.
x
==
1
,
"
Passed!
"
);
ok
(
a
.
normal
.
y
==
0
,
"
Passed!
"
);
ok
(
a
.
normal
.
z
==
0
,
"
Passed!
"
);
ok
(
a
.
constant
==
0
,
"
Passed!
"
);
...
...
@@ -74,7 +81,7 @@ test( "setComponents", function() {
test
(
"
setFromNormalAndCoplanarPoint
"
,
function
()
{
var
a
=
new
THREE
.
Plane
().
setFromNormalAndCoplanarPoint
(
one3
,
zero3
);
ok
(
a
.
normal
.
equals
(
one3
),
"
Passed!
"
);
ok
(
a
.
normal
.
equals
(
one3
.
clone
().
normalize
()
),
"
Passed!
"
);
ok
(
a
.
constant
==
0
,
"
Passed!
"
);
});
...
...
@@ -86,3 +93,72 @@ test( "normalize", function() {
ok
(
a
.
normal
.
equals
(
new
THREE
.
Vector3
(
1
,
0
,
0
)
),
"
Passed!
"
);
ok
(
a
.
constant
==
1
,
"
Passed!
"
);
});
test
(
"
distanceToPoint
"
,
function
()
{
var
a
=
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
2
,
0
,
0
),
-
2
);
a
.
normalize
();
ok
(
a
.
distanceToPoint
(
a
.
projectPoint
(
zero3
.
clone
()
)
)
===
0
,
"
Passed!
"
);
ok
(
a
.
distanceToPoint
(
new
THREE
.
Vector3
(
4
,
0
,
0
)
)
===
3
,
"
Passed!
"
);
});
test
(
"
distanceToSphere
"
,
function
()
{
var
a
=
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
1
,
0
,
0
),
0
);
var
b
=
new
THREE
.
Sphere
(
new
THREE
.
Vector3
(
2
,
0
,
0
),
1
);
ok
(
a
.
distanceToSphere
(
b
)
===
1
,
"
Passed!
"
);
a
.
set
(
new
THREE
.
Vector3
(
1
,
0
,
0
),
2
);
ok
(
a
.
distanceToSphere
(
b
)
===
3
,
"
Passed!
"
);
a
.
set
(
new
THREE
.
Vector3
(
1
,
0
,
0
),
-
2
);
ok
(
a
.
distanceToSphere
(
b
)
===
-
1
,
"
Passed!
"
);
});
test
(
"
projectPoint
"
,
function
()
{
var
a
=
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
1
,
0
,
0
),
0
);
ok
(
a
.
projectPoint
(
new
THREE
.
Vector3
(
10
,
0
,
0
)
).
equals
(
zero3
),
"
Passed!
"
);
ok
(
a
.
projectPoint
(
new
THREE
.
Vector3
(
-
10
,
0
,
0
)
).
equals
(
zero3
),
"
Passed!
"
);
a
=
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
0
,
1
,
0
),
-
1
);
ok
(
a
.
projectPoint
(
new
THREE
.
Vector3
(
0
,
0
,
0
)
).
equals
(
new
THREE
.
Vector3
(
0
,
1
,
0
)
),
"
Passed!
"
);
ok
(
a
.
projectPoint
(
new
THREE
.
Vector3
(
0
,
1
,
0
)
).
equals
(
new
THREE
.
Vector3
(
0
,
1
,
0
)
),
"
Passed!
"
);
});
test
(
"
orthoPoint
"
,
function
()
{
var
a
=
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
1
,
0
,
0
),
0
);
ok
(
a
.
orthoPoint
(
new
THREE
.
Vector3
(
10
,
0
,
0
)
).
equals
(
new
THREE
.
Vector3
(
10
,
0
,
0
)
),
"
Passed!
"
);
ok
(
a
.
orthoPoint
(
new
THREE
.
Vector3
(
-
10
,
0
,
0
)
).
equals
(
new
THREE
.
Vector3
(
-
10
,
0
,
0
)
),
"
Passed!
"
);
});
/*
test( "isIntersectionLine", function() {
});
*/
test
(
"
coplanarPoint
"
,
function
()
{
var
a
=
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
1
,
0
,
0
),
0
);
ok
(
a
.
distanceToPoint
(
a
.
coplanarPoint
()
)
===
0
,
"
Passed!
"
);
a
=
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
0
,
1
,
0
),
-
1
);
ok
(
a
.
distanceToPoint
(
a
.
coplanarPoint
()
)
===
0
,
"
Passed!
"
);
});
test
(
"
transform/translate
"
,
function
()
{
var
a
=
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
1
,
0
,
0
),
0
);
var
m
=
new
THREE
.
Matrix4
();
m
.
makeRotationZ
(
Math
.
PI
*
0.5
);
ok
(
comparePlane
(
a
.
clone
().
transform
(
m
),
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
0
,
1
,
0
),
0
)
),
"
Passed!
"
);
a
=
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
0
,
1
,
0
),
-
1
);
ok
(
comparePlane
(
a
.
clone
().
transform
(
m
),
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
-
1
,
0
,
0
),
-
1
)
),
"
Passed!
"
);
m
.
makeTranslation
(
new
THREE
.
Vector3
(
1
,
1
,
1
)
);
ok
(
comparePlane
(
a
.
clone
().
transform
(
m
),
a
.
clone
().
translate
(
new
THREE
.
Vector3
(
1
,
1
,
1
)
)
),
"
Passed!
"
);
});
\ No newline at end of file
test/
core
/Ray.js
→
test/
math
/Ray.js
浏览文件 @
c1fa178d
...
...
@@ -149,26 +149,26 @@ test( "intersectPlane", function() {
});
test
(
"
transform
Self
"
,
function
()
{
test
(
"
transform
"
,
function
()
{
var
a
=
new
THREE
.
Ray
(
one3
,
new
THREE
.
Vector3
(
0
,
0
,
1
)
);
var
m
=
new
THREE
.
Matrix4
().
identity
();
ok
(
a
.
clone
().
transform
Self
(
m
).
equals
(
a
),
"
Passed!
"
);
ok
(
a
.
clone
().
transform
(
m
).
equals
(
a
),
"
Passed!
"
);
a
=
new
THREE
.
Ray
(
zero3
,
new
THREE
.
Vector3
(
0
,
0
,
1
)
);
m
.
rotateByAxis
(
new
THREE
.
Vector3
(
0
,
0
,
1
),
Math
.
PI
);
ok
(
a
.
clone
().
transform
Self
(
m
).
equals
(
a
),
"
Passed!
"
);
ok
(
a
.
clone
().
transform
(
m
).
equals
(
a
),
"
Passed!
"
);
m
.
identity
().
rotateX
(
Math
.
PI
);
var
b
=
a
.
clone
();
b
.
direction
.
negate
();
var
a2
=
a
.
clone
().
transform
Self
(
m
);
var
a2
=
a
.
clone
().
transform
(
m
);
ok
(
a2
.
origin
.
distanceTo
(
b
.
origin
)
<
0.0001
,
"
Passed!
"
);
ok
(
a2
.
direction
.
distanceTo
(
b
.
direction
)
<
0.0001
,
"
Passed!
"
);
a
.
origin
=
new
THREE
.
Vector3
(
0
,
0
,
1
);
b
.
origin
=
new
THREE
.
Vector3
(
0
,
0
,
-
1
);
var
a2
=
a
.
clone
().
transform
Self
(
m
);
var
a2
=
a
.
clone
().
transform
(
m
);
ok
(
a2
.
origin
.
distanceTo
(
b
.
origin
)
<
0.0001
,
"
Passed!
"
);
ok
(
a2
.
direction
.
distanceTo
(
b
.
direction
)
<
0.0001
,
"
Passed!
"
);
});
...
...
test/
core
/Sphere.js
→
test/
math
/Sphere.js
浏览文件 @
c1fa178d
...
...
@@ -37,3 +37,58 @@ test( "set", function() {
ok
(
a
.
center
.
equals
(
one3
),
"
Passed!
"
);
ok
(
a
.
radius
==
1
,
"
Passed!
"
);
});
test
(
"
empty
"
,
function
()
{
var
a
=
new
THREE
.
Sphere
();
ok
(
a
.
empty
(),
"
Passed!
"
);
a
.
set
(
one3
,
1
);
ok
(
!
a
.
empty
(),
"
Passed!
"
);
});
test
(
"
containsPoint
"
,
function
()
{
var
a
=
new
THREE
.
Sphere
(
one3
,
1
);
ok
(
!
a
.
containsPoint
(
zero3
),
"
Passed!
"
);
ok
(
a
.
containsPoint
(
one3
),
"
Passed!
"
);
});
test
(
"
distanceToPoint
"
,
function
()
{
var
a
=
new
THREE
.
Sphere
(
one3
,
1
);
ok
(
(
a
.
distanceToPoint
(
zero3
)
-
0.7320
)
<
0.001
,
"
Passed!
"
);
ok
(
a
.
distanceToPoint
(
one3
)
===
-
1
,
"
Passed!
"
);
});
test
(
"
clampPoint
"
,
function
()
{
var
a
=
new
THREE
.
Sphere
(
one3
,
1
);
ok
(
a
.
clampPoint
(
new
THREE
.
Vector3
(
1
,
1
,
3
)
).
equals
(
new
THREE
.
Vector3
(
1
,
1
,
2
)
),
"
Passed!
"
);
ok
(
a
.
clampPoint
(
new
THREE
.
Vector3
(
1
,
1
,
-
3
)
).
equals
(
new
THREE
.
Vector3
(
1
,
1
,
0
)
),
"
Passed!
"
);
});
test
(
"
bounds
"
,
function
()
{
var
a
=
new
THREE
.
Sphere
(
one3
,
1
);
ok
(
a
.
bounds
().
equals
(
new
THREE
.
Box3
(
zero3
,
two3
)
),
"
Passed!
"
);
a
.
set
(
zero3
,
0
)
ok
(
a
.
bounds
().
equals
(
new
THREE
.
Box3
(
zero3
,
zero3
)
),
"
Passed!
"
);
});
test
(
"
transform
"
,
function
()
{
var
a
=
new
THREE
.
Sphere
(
one3
,
1
);
var
m
=
new
THREE
.
Matrix4
();
var
t1
=
new
THREE
.
Vector3
(
1
,
-
2
,
1
);
m
.
makeTranslation
(
t1
);
ok
(
a
.
clone
().
transform
(
m
).
bounds
().
equals
(
a
.
bounds
().
transform
(
m
)
),
"
Passed!
"
);
});
test
(
"
translate
"
,
function
()
{
var
a
=
new
THREE
.
Sphere
(
one3
,
1
);
a
.
translate
(
one3
.
clone
().
negate
()
);
ok
(
a
.
center
.
equals
(
zero3
),
"
Passed!
"
);
});
test/
core
/Triangle.js
→
test/
math
/Triangle.js
浏览文件 @
c1fa178d
文件已移动
test/
core
/Vector2.js
→
test/
math
/Vector2.js
浏览文件 @
c1fa178d
文件已移动
test/
core
/Vector3.js
→
test/
math
/Vector3.js
浏览文件 @
c1fa178d
文件已移动
test/
core
/Vector4.js
→
test/
math
/Vector4.js
浏览文件 @
c1fa178d
文件已移动
test/sources.html
浏览文件 @
c1fa178d
...
...
@@ -26,16 +26,16 @@
<!-- add class-based unit tests below -->
<script
src=
"
core
/Constants.js"
></script>
<script
src=
"
core
/Box2.js"
></script>
<script
src=
"
core
/Box3.js"
></script>
<script
src=
"
core
/Plane.js"
></script>
<script
src=
"
core
/Ray.js"
></script>
<script
src=
"
core
/Sphere.js"
></script>
<script
src=
"
core
/Triangle.js"
></script>
<script
src=
"
core
/Vector2.js"
></script>
<script
src=
"
core
/Vector3.js"
></script>
<script
src=
"
core
/Vector4.js"
></script>
<script
src=
"
math
/Constants.js"
></script>
<script
src=
"
math
/Box2.js"
></script>
<script
src=
"
math
/Box3.js"
></script>
<script
src=
"
math
/Plane.js"
></script>
<script
src=
"
math
/Ray.js"
></script>
<script
src=
"
math
/Sphere.js"
></script>
<script
src=
"
math
/Triangle.js"
></script>
<script
src=
"
math
/Vector2.js"
></script>
<script
src=
"
math
/Vector3.js"
></script>
<script
src=
"
math
/Vector4.js"
></script>
</body>
</html>
\ No newline at end of file
test/three-math.html
浏览文件 @
c1fa178d
...
...
@@ -15,16 +15,16 @@
<!-- add class-based unit tests below -->
<script
src=
"
core
/Constants.js"
></script>
<script
src=
"
core
/Box2.js"
></script>
<script
src=
"
core
/Box3.js"
></script>
<script
src=
"
core
/Plane.js"
></script>
<script
src=
"
core
/Ray.js"
></script>
<script
src=
"
core
/Sphere.js"
></script>
<script
src=
"
core
/Triangle.js"
></script>
<script
src=
"
core
/Vector2.js"
></script>
<script
src=
"
core
/Vector3.js"
></script>
<script
src=
"
core
/Vector4.js"
></script>
<script
src=
"
math
/Constants.js"
></script>
<script
src=
"
math
/Box2.js"
></script>
<script
src=
"
math
/Box3.js"
></script>
<script
src=
"
math
/Plane.js"
></script>
<script
src=
"
math
/Ray.js"
></script>
<script
src=
"
math
/Sphere.js"
></script>
<script
src=
"
math
/Triangle.js"
></script>
<script
src=
"
math
/Vector2.js"
></script>
<script
src=
"
math
/Vector3.js"
></script>
<script
src=
"
math
/Vector4.js"
></script>
</body>
</html>
test/three.html
浏览文件 @
c1fa178d
...
...
@@ -15,16 +15,16 @@
<!-- add class-based unit tests below -->
<script
src=
"
core
/Constants.js"
></script>
<script
src=
"
core
/Box2.js"
></script>
<script
src=
"
core
/Box3.js"
></script>
<script
src=
"
core
/Plane.js"
></script>
<script
src=
"
core
/Ray.js"
></script>
<script
src=
"
core
/Sphere.js"
></script>
<script
src=
"
core
/Triangle.js"
></script>
<script
src=
"
core
/Vector2.js"
></script>
<script
src=
"
core
/Vector3.js"
></script>
<script
src=
"
core
/Vector4.js"
></script>
<script
src=
"
math
/Constants.js"
></script>
<script
src=
"
math
/Box2.js"
></script>
<script
src=
"
math
/Box3.js"
></script>
<script
src=
"
math
/Plane.js"
></script>
<script
src=
"
math
/Ray.js"
></script>
<script
src=
"
math
/Sphere.js"
></script>
<script
src=
"
math
/Triangle.js"
></script>
<script
src=
"
math
/Vector2.js"
></script>
<script
src=
"
math
/Vector3.js"
></script>
<script
src=
"
math
/Vector4.js"
></script>
</body>
</html>
test/three.min.html
浏览文件 @
c1fa178d
...
...
@@ -15,16 +15,16 @@
<!-- add class-based unit tests below -->
<script
src=
"
core
/Constants.js"
></script>
<script
src=
"
core
/Box2.js"
></script>
<script
src=
"
core
/Box3.js"
></script>
<script
src=
"
core
/Plane.js"
></script>
<script
src=
"
core
/Ray.js"
></script>
<script
src=
"
core
/Sphere.js"
></script>
<script
src=
"
core
/Triangle.js"
></script>
<script
src=
"
core
/Vector2.js"
></script>
<script
src=
"
core
/Vector3.js"
></script>
<script
src=
"
core
/Vector4.js"
></script>
<script
src=
"
math
/Constants.js"
></script>
<script
src=
"
math
/Box2.js"
></script>
<script
src=
"
math
/Box3.js"
></script>
<script
src=
"
math
/Plane.js"
></script>
<script
src=
"
math
/Ray.js"
></script>
<script
src=
"
math
/Sphere.js"
></script>
<script
src=
"
math
/Triangle.js"
></script>
<script
src=
"
math
/Vector2.js"
></script>
<script
src=
"
math
/Vector3.js"
></script>
<script
src=
"
math
/Vector4.js"
></script>
</body>
</html>
utils/build_all.bat
浏览文件 @
c1fa178d
...
...
@@ -4,4 +4,5 @@ python build.py --include canvas --minify --output ../build/three-canvas.min.js
python
build
.py
--include
css3d
--minify --output
../build/three
-css
3
d
.min.js
python
build
.py
--include
webgl
--minify --output
../build/three
-webgl
.min.js
python
build
.py
--include
extras
--externs
externs
/extras
.js
--minify --output
../build/three
-extras
.min.js
python
build
.py
--include
math
--output
../build/three
-math
.js
python
build
.py
--include
math
--minify --output
../build/three
-math
.min.js
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录