Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
916ce9c6
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,发现更多精彩内容 >>
提交
916ce9c6
编写于
10月 19, 2015
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Renamed isIntersection* to intersects*. See #7376.
上级
47264fc6
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
226 addition
and
186 deletion
+226
-186
docs/api/math/Box2.html
docs/api/math/Box2.html
+9
-9
docs/api/math/Box3.html
docs/api/math/Box3.html
+14
-14
docs/api/math/Plane.html
docs/api/math/Plane.html
+4
-4
docs/api/math/Ray.html
docs/api/math/Ray.html
+9
-9
examples/js/renderers/CanvasRenderer.js
examples/js/renderers/CanvasRenderer.js
+2
-2
examples/js/renderers/Projector.js
examples/js/renderers/Projector.js
+1
-1
examples/js/renderers/SVGRenderer.js
examples/js/renderers/SVGRenderer.js
+2
-2
src/math/Box2.js
src/math/Box2.js
+10
-2
src/math/Box3.js
src/math/Box3.js
+19
-3
src/math/Plane.js
src/math/Plane.js
+18
-11
src/math/Ray.js
src/math/Ray.js
+57
-31
src/math/Sphere.js
src/math/Sphere.js
+2
-9
src/objects/Line.js
src/objects/Line.js
+1
-5
src/objects/Mesh.js
src/objects/Mesh.js
+2
-2
src/objects/Points.js
src/objects/Points.js
+1
-5
test/unit/math/Box2.js
test/unit/math/Box2.js
+10
-10
test/unit/math/Box3.js
test/unit/math/Box3.js
+10
-10
test/unit/math/Plane.js
test/unit/math/Plane.js
+11
-11
test/unit/math/Ray.js
test/unit/math/Ray.js
+44
-46
未找到文件。
docs/api/math/Box2.html
浏览文件 @
916ce9c6
...
...
@@ -22,7 +22,7 @@
max -- Upper (x, y) boundary of the box.
</div>
<div>
Creates a box bounded by min and max.
Creates a box bounded by min and max.
</div>
...
...
@@ -33,12 +33,12 @@
<h3>
[property:Vector2 min]
</h3>
<div>
Lower (x, y) boundary of this box.
</div>
</div>
<h3>
[property:Vector2 max]
</h3>
<div>
Upper (x, y) boundary of this box.
</div>
</div>
<h2>
Methods
</h2>
...
...
@@ -70,7 +70,7 @@
Clamps *point* within the bounds of this box.
</div>
<h3>
[method:Boolean i
sIntersection
Box]([page:Box2 box])
</h3>
<h3>
[method:Boolean i
ntersects
Box]([page:Box2 box])
</h3>
<div>
box -- Box to check for intersection against.
</div>
...
...
@@ -99,7 +99,7 @@
box -- Box that will be unioned with this box.
</div>
<div>
Unions this box with *box* setting the upper bound of this box to the greater of the
Unions this box with *box* setting the upper bound of this box to the greater of the
two boxes' upper bounds and the lower bound of this box to the lesser of the two boxes'
lower bounds.
</div>
...
...
@@ -108,7 +108,7 @@
<div>
point -- [page:Vector2]
<br/>
optionalTarget -- [page:Vector2]
<br/>
</div>
<div>
Returns a point as a proportion of this box's width and height.
...
...
@@ -139,7 +139,7 @@
</div>
<div>
Returns true if this box includes the entirety of *box*. If this and *box* overlap exactly,
</br>
this function also returns true.
this function also returns true.
</div>
<h3>
[method:Box2 translate]([page:Vector2 offset]) [page:Box2 this]
</h3>
...
...
@@ -177,7 +177,7 @@
</div>
<div>
Expands this box equilaterally by *vector*. The width of this box will be
expanded by the x component of *vector* in both directions. The height of
expanded by the x component of *vector* in both directions. The height of
this box will be expanded by the y component of *vector* in both directions.
</div>
...
...
@@ -222,7 +222,7 @@
<h3>
[method:Box2 setFromCenterAndSize]([page:Vector2 center], [page:Vector2 size]) [page:Box2 this]
</h3>
<div>
center -- Desired center position of the box.
<br
/>
size -- Desired x and y dimensions of the box.
size -- Desired x and y dimensions of the box.
</div>
<div>
Centers this box on *center* and sets this box's width and height to the values specified
...
...
docs/api/math/Box3.html
浏览文件 @
916ce9c6
...
...
@@ -22,7 +22,7 @@
max -- Upper (x, y, z) boundary of the box.
</div>
<div>
Creates a box bounded by min and max.
Creates a box bounded by min and max.
</div>
<h2>
Properties
</h2>
...
...
@@ -37,7 +37,7 @@
<h3>
[property:Vector3 max]
</h3>
<div>
Upper (x, y, z) boundary of this box.
</div>
</div>
<h2>
Methods
</h2>
...
...
@@ -51,7 +51,7 @@
<div>
Sets the lower and upper (x, y, z) boundaries of this box.
</div>
<h3>
[method:Box3 applyMatrix4]([page:Matrix4 matrix]) [page:Box3 this]
</h3>
<div>
matrix -- The [page:Matrix4] to apply
...
...
@@ -69,7 +69,7 @@
Clamps *point* within the bounds of this box.
</div>
<h3>
[method:Boolean i
sIntersection
Box]([page:Box3 box])
</h3>
<h3>
[method:Boolean i
ntersects
Box]([page:Box3 box])
</h3>
<div>
box -- Box to check for intersection against.
</div>
...
...
@@ -84,7 +84,7 @@
<div>
Sets the upper and lower bounds of this box to include all of the points in *points*.
</div>
<h3>
[method:Box3 setFromObject]([page:Object3D object]) [page:Box3 this]
</h3>
<div>
object -- [page:Object3D] to compute the bounding box for.
...
...
@@ -93,8 +93,8 @@
Computes the world-axis-aligned bounding box of an object (including its children),
accounting for both the object's, and childrens', world transforms
</div>
<h3>
[method:Vector3 size]([page:Vector3 optionalTarget])
</h3>
<div>
...
...
@@ -109,7 +109,7 @@
box -- Box that will be unioned with this box.
</div>
<div>
Unions this box with *box* setting the upper bound of this box to the greater of the
Unions this box with *box* setting the upper bound of this box to the greater of the
two boxes' upper bounds and the lower bound of this box to the lesser of the two boxes'
lower bounds.
</div>
...
...
@@ -139,7 +139,7 @@
</div>
<div>
Returns true if this box includes the entirety of *box*. If this and *box* overlap exactly,
</br>
this function also returns true.
this function also returns true.
</div>
<h3>
[method:Boolean containsPoint]([page:Vector3 point])
</h3>
...
...
@@ -149,7 +149,7 @@
<div>
Returns true if the specified point lies within the boundaries of this box.
</div>
<h3>
[method:Box3 translate]([page:Vector3 offset]) [page:Box3 this]
</h3>
<div>
offset -- Direction and distance of offset.
...
...
@@ -186,7 +186,7 @@
<div>
Expands the boundaries of this box to include *point*.
</div>
<h3>
[method:Box3 expandByScalar]([page:float scalar]) [page:Box3 this]
</h3>
<div>
scalar -- Distance to expand.
...
...
@@ -195,14 +195,14 @@
Expands each dimension of the box by *scalar*. If negative, the dimensions of the box
<br/>
will be contracted.
</div>
<h3>
[method:Box3 expandByVector]([page:Vector3 vector]) [page:Box3 this]
</h3>
<div>
vector -- Amount to expand this box in each dimension.
</div>
<div>
Expands this box equilaterally by *vector*. The width of this box will be
expanded by the x component of *vector* in both directions. The height of
expanded by the x component of *vector* in both directions. The height of
this box will be expanded by the y component of *vector* in both directions.
The depth of this box will be expanded by the z component of *vector* in
both directions.
...
...
@@ -249,7 +249,7 @@
<h3>
[method:Box3 setFromCenterAndSize]([page:Vector3 center], [page:Vector3 size]) [page:Box3 this]
</h3>
<div>
center -- Desired center position of the box.
<br
/>
size -- Desired x and y dimensions of the box.
size -- Desired x and y dimensions of the box.
</div>
<div>
Centers this box on *center* and sets this box's width and height to the values specified
...
...
docs/api/math/Plane.html
浏览文件 @
916ce9c6
...
...
@@ -28,7 +28,7 @@
<h3>
[property:Vector3 normal]
</h3>
<h3>
[property:Float constant]
</h3>
<h2>
Methods
</h2>
...
...
@@ -62,9 +62,9 @@
</div>
<div>
Apply a Matrix4 to the plane. The second parameter is optional.
<code>
var optionalNormalMatrix = new THREE.Matrix3().getNormalMatrix( matrix )
var optionalNormalMatrix = new THREE.Matrix3().getNormalMatrix( matrix )
</code>
</div>
...
...
@@ -77,7 +77,7 @@
Returns a vector in the same direction as the Plane's normal, but the magnitude is passed point's original distance to the plane.
</div>
<h3>
[method:Boolean i
sIntersection
Line]([page:Line3 line])
</h3>
<h3>
[method:Boolean i
ntersects
Line]([page:Line3 line])
</h3>
<div>
line -- [page:Line3]
</div>
...
...
docs/api/math/Ray.html
浏览文件 @
916ce9c6
...
...
@@ -30,12 +30,12 @@
<h3>
[property:Vector3 origin]
</h3>
<div>
The origin of the [page:Ray].
</div>
</div>
<h3>
[property:Vector3 direction]
</h3>
<div>
The direction of the [page:Ray]. This must be normalized (with [page:Vector3].normalize) for the methods to operate properly.
</div>
</div>
<h2>
Methods
</h2>
...
...
@@ -77,7 +77,7 @@
<div>
Copy the properties of the provided [page:Ray], then return this [page:Ray].
</div>
<h3>
.distanceSqToSegment([page:Vector3 v0], [page:Vector3 v1], [page:Vector3 optionalPointOnRay] = null, [page:Vector3 optionalPointOnSegment] = null) [page:Float]
</h3>
<div>
v0 -- [page:Vector3] The start of the line segment.
...
...
@@ -129,7 +129,7 @@
<div>
Intersect this [page:Ray] with a [page:Box3], returning the intersection point or *null* if there is no intersection.
</div>
<h3>
.intersectPlane([page:Plane plane], [page:Vector3 optionalTarget] = null) [page:Vector3]?
</h3>
<div>
plane -- [page:Plane] The [page:Plane] to intersect with.
<br
/>
...
...
@@ -139,7 +139,7 @@
Intersect this [page:Ray] with a [page:Plane], returning the intersection point or *null* if there is no intersection.
</div>
function ( a, b, c, backfaceCulling, optionalTarget )
<h3>
.intersectTriangle([page:Vector3 a], [page:Vector3 b], [page:Vector3 c], [page:Boolean backfaceCulling], [page:Vector3 optionalTarget] = null) [page:Vector3]?
</h3>
<div>
a, b, c -- [page:Vector3] The [page:Vector3] points on the triangle.
<br
/>
...
...
@@ -149,8 +149,8 @@
<div>
Intersect this [page:Ray] with a triangle, returning the intersection point or *null* if there is no intersection.
</div>
<h3>
[method:Boolean i
sIntersection
Box]([page:Box3 box])
</h3>
<h3>
[method:Boolean i
ntersects
Box]([page:Box3 box])
</h3>
<div>
box -- [page:Box3] The [page:Box3] to intersect with.
</div>
...
...
@@ -158,7 +158,7 @@
Return whether or not this [page:Ray] intersects with the [page:Box3].
</div>
<h3>
[method:Boolean i
sIntersection
Plane]([page:Plane plane])
</h3>
<h3>
[method:Boolean i
ntersects
Plane]([page:Plane plane])
</h3>
<div>
plane -- [page:Plane] The [page:Plane] to intersect with.
</div>
...
...
@@ -166,7 +166,7 @@
Return whether or not this [page:Ray] intersects with the [page:Plane].
</div>
<h3>
[method:Boolean i
sIntersection
Sphere]([page:Sphere sphere])
</h3>
<h3>
[method:Boolean i
ntersects
Sphere]([page:Sphere sphere])
</h3>
<div>
sphere -- [page:Sphere] The [page:Sphere] to intersect with.
</div>
...
...
examples/js/renderers/CanvasRenderer.js
浏览文件 @
916ce9c6
...
...
@@ -363,7 +363,7 @@ THREE.CanvasRenderer = function ( parameters ) {
_v2
.
positionScreen
]
);
if
(
_clipBox
.
i
sIntersection
Box
(
_elemBox
)
===
true
)
{
if
(
_clipBox
.
i
ntersects
Box
(
_elemBox
)
===
true
)
{
renderLine
(
_v1
,
_v2
,
element
,
material
);
...
...
@@ -395,7 +395,7 @@ THREE.CanvasRenderer = function ( parameters ) {
_v3
.
positionScreen
]
);
if
(
_clipBox
.
i
sIntersection
Box
(
_elemBox
)
===
true
)
{
if
(
_clipBox
.
i
ntersects
Box
(
_elemBox
)
===
true
)
{
renderFace3
(
_v1
,
_v2
,
_v3
,
0
,
1
,
2
,
element
,
material
);
...
...
examples/js/renderers/Projector.js
浏览文件 @
916ce9c6
...
...
@@ -223,7 +223,7 @@ THREE.Projector = function () {
_points3
[
1
]
=
v2
.
positionScreen
;
_points3
[
2
]
=
v3
.
positionScreen
;
return
_clipBox
.
i
sIntersection
Box
(
_boundingBox
.
setFromPoints
(
_points3
)
);
return
_clipBox
.
i
ntersects
Box
(
_boundingBox
.
setFromPoints
(
_points3
)
);
}
...
...
examples/js/renderers/SVGRenderer.js
浏览文件 @
916ce9c6
...
...
@@ -170,7 +170,7 @@ THREE.SVGRenderer = function () {
_elemBox
.
setFromPoints
(
[
_v1
.
positionScreen
,
_v2
.
positionScreen
]
);
if
(
_clipBox
.
i
sIntersection
Box
(
_elemBox
)
===
true
)
{
if
(
_clipBox
.
i
ntersects
Box
(
_elemBox
)
===
true
)
{
renderLine
(
_v1
,
_v2
,
element
,
material
);
...
...
@@ -194,7 +194,7 @@ THREE.SVGRenderer = function () {
_v3
.
positionScreen
]
);
if
(
_clipBox
.
i
sIntersection
Box
(
_elemBox
)
===
true
)
{
if
(
_clipBox
.
i
ntersects
Box
(
_elemBox
)
===
true
)
{
renderFace3
(
_v1
,
_v2
,
_v3
,
element
,
material
);
...
...
src/math/Box2.js
浏览文件 @
916ce9c6
...
...
@@ -51,7 +51,7 @@ THREE.Box2.prototype = {
};
}(),
clone
:
function
()
{
return
new
this
.
constructor
().
copy
(
this
);
...
...
@@ -165,7 +165,7 @@ THREE.Box2.prototype = {
},
i
sIntersection
Box
:
function
(
box
)
{
i
ntersects
Box
:
function
(
box
)
{
// using 6 splitting planes to rule out intersections.
...
...
@@ -180,6 +180,14 @@ THREE.Box2.prototype = {
},
isIntersectionBox
:
function
(
box
)
{
console
.
warn
(
'
THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().
'
);
return
this
.
intersectsBox
(
box
);
},
clampPoint
:
function
(
point
,
optionalTarget
)
{
var
result
=
optionalTarget
||
new
THREE
.
Vector2
();
...
...
src/math/Box3.js
浏览文件 @
916ce9c6
...
...
@@ -231,7 +231,7 @@ THREE.Box3.prototype = {
},
i
sIntersection
Box
:
function
(
box
)
{
i
ntersects
Box
:
function
(
box
)
{
// using 6 splitting planes to rule out intersections.
...
...
@@ -247,11 +247,19 @@ THREE.Box3.prototype = {
},
isIntersectionSphere
:
(
function
()
{
isIntersectionBox
:
function
(
box
)
{
console
.
warn
(
'
THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().
'
);
return
this
.
intersectsBox
(
box
);
},
intersectsSphere
:
(
function
()
{
var
closestPoint
;
return
function
i
sIntersection
Sphere
(
sphere
)
{
return
function
i
ntersects
Sphere
(
sphere
)
{
if
(
closestPoint
===
undefined
)
closestPoint
=
new
THREE
.
Vector3
();
...
...
@@ -265,6 +273,14 @@ THREE.Box3.prototype = {
}
)(),
isIntersectionSphere
:
function
(
sphere
)
{
console
.
warn
(
'
THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().
'
);
return
this
.
intersectsSphere
(
sphere
);
},
clampPoint
:
function
(
point
,
optionalTarget
)
{
var
result
=
optionalTarget
||
new
THREE
.
Vector3
();
...
...
src/math/Plane.js
浏览文件 @
916ce9c6
...
...
@@ -122,17 +122,6 @@ THREE.Plane.prototype = {
},
isIntersectionLine
:
function
(
line
)
{
// Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it.
var
startSign
=
this
.
distanceToPoint
(
line
.
start
);
var
endSign
=
this
.
distanceToPoint
(
line
.
end
);
return
(
startSign
<
0
&&
endSign
>
0
)
||
(
endSign
<
0
&&
startSign
>
0
);
},
intersectLine
:
function
()
{
var
v1
=
new
THREE
.
Vector3
();
...
...
@@ -173,6 +162,24 @@ THREE.Plane.prototype = {
}(),
intersectsLine
:
function
(
line
)
{
// Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it.
var
startSign
=
this
.
distanceToPoint
(
line
.
start
);
var
endSign
=
this
.
distanceToPoint
(
line
.
end
);
return
(
startSign
<
0
&&
endSign
>
0
)
||
(
endSign
<
0
&&
startSign
>
0
);
},
isIntersectionLine
:
function
(
line
)
{
console
.
warn
(
'
THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().
'
);
return
this
.
intersectsLine
(
line
);
},
coplanarPoint
:
function
(
optionalTarget
)
{
...
...
src/math/Ray.js
浏览文件 @
916ce9c6
...
...
@@ -232,13 +232,6 @@ THREE.Ray.prototype = {
}(),
isIntersectionSphere
:
function
(
sphere
)
{
return
this
.
distanceToPoint
(
sphere
.
center
)
<=
sphere
.
radius
;
},
intersectSphere
:
function
()
{
// from http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-7-intersecting-simple-shapes/ray-sphere-intersection/
...
...
@@ -280,35 +273,24 @@ THREE.Ray.prototype = {
}(),
isIntersectionPlane
:
function
(
plane
)
{
// check if the ray lies on the plane first
var
distToPoint
=
plane
.
distanceToPoint
(
this
.
origin
);
if
(
distToPoint
===
0
)
{
return
true
;
}
var
denominator
=
plane
.
normal
.
dot
(
this
.
direction
);
intersectsSphere
:
function
(
sphere
)
{
if
(
denominator
*
distToPoint
<
0
)
{
return
this
.
distanceToPoint
(
sphere
.
center
)
<=
sphere
.
radius
;
return
true
;
},
}
isIntersectionSphere
:
function
(
sphere
)
{
// ray origin is behind the plane (and is pointing behind it)
console
.
warn
(
'
THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().
'
);
return
false
;
return
this
.
intersectsSphere
(
sphere
)
;
},
distanceToPlane
:
function
(
plane
)
{
var
denominator
=
plane
.
normal
.
dot
(
this
.
direction
);
if
(
denominator
===
0
)
{
// line is coplanar, return origin
...
...
@@ -346,17 +328,41 @@ THREE.Ray.prototype = {
},
isIntersectionBox
:
function
()
{
var
v
=
new
THREE
.
Vector3
();
return
function
(
box
)
{
intersectsPlane
:
function
(
plane
)
{
return
this
.
intersectBox
(
box
,
v
)
!==
null
;
// check if the ray lies on the plane first
}
;
var
distToPoint
=
plane
.
distanceToPoint
(
this
.
origin
)
;
}(),
if
(
distToPoint
===
0
)
{
return
true
;
}
var
denominator
=
plane
.
normal
.
dot
(
this
.
direction
);
if
(
denominator
*
distToPoint
<
0
)
{
return
true
;
}
// ray origin is behind the plane (and is pointing behind it)
return
false
;
},
isIntersectionPlane
:
function
(
plane
)
{
console
.
warn
(
'
THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().
'
);
return
this
.
intersectsPlane
(
plane
);
},
intersectBox
:
function
(
box
,
optionalTarget
)
{
...
...
@@ -429,6 +435,26 @@ THREE.Ray.prototype = {
},
intersectsBox
:
(
function
()
{
var
v
=
new
THREE
.
Vector3
();
return
function
(
box
)
{
return
this
.
intersectBox
(
box
,
v
)
!==
null
;
};
}
)(),
isIntersectionBox
:
function
(
box
)
{
console
.
warn
(
'
THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().
'
);
return
this
.
intersectsBox
(
box
);
},
intersectTriangle
:
function
()
{
// Compute the offset origin, edges, and normal.
...
...
src/math/Sphere.js
浏览文件 @
916ce9c6
...
...
@@ -92,22 +92,15 @@ THREE.Sphere.prototype = {
intersectsSphere
:
function
(
sphere
)
{
console
.
warn
(
'
THREE.Sphere: .intersectsSphere() has been renamed to .isIntersectionSphere().
'
);
return
this
.
isIntersectionSphere
(
sphere
);
},
isIntersectionSphere
:
function
(
sphere
)
{
var
radiusSum
=
this
.
radius
+
sphere
.
radius
;
return
sphere
.
center
.
distanceToSquared
(
this
.
center
)
<=
(
radiusSum
*
radiusSum
);
},
i
sIntersection
Box
:
function
(
box
)
{
i
ntersects
Box
:
function
(
box
)
{
return
box
.
i
sIntersection
Sphere
(
this
);
return
box
.
i
ntersects
Sphere
(
this
);
},
...
...
src/objects/Line.js
浏览文件 @
916ce9c6
...
...
@@ -43,11 +43,7 @@ THREE.Line.prototype.raycast = ( function () {
sphere
.
copy
(
geometry
.
boundingSphere
);
sphere
.
applyMatrix4
(
this
.
matrixWorld
);
if
(
raycaster
.
ray
.
isIntersectionSphere
(
sphere
)
===
false
)
{
return
;
}
if
(
raycaster
.
ray
.
intersectsSphere
(
sphere
)
===
false
)
return
;
inverseMatrix
.
getInverse
(
this
.
matrixWorld
);
ray
.
copy
(
raycaster
.
ray
).
applyMatrix4
(
inverseMatrix
);
...
...
src/objects/Mesh.js
浏览文件 @
916ce9c6
...
...
@@ -169,7 +169,7 @@ THREE.Mesh.prototype.raycast = ( function () {
sphere
.
copy
(
geometry
.
boundingSphere
);
sphere
.
applyMatrix4
(
matrixWorld
);
if
(
raycaster
.
ray
.
i
sIntersection
Sphere
(
sphere
)
===
false
)
return
;
if
(
raycaster
.
ray
.
i
ntersects
Sphere
(
sphere
)
===
false
)
return
;
// Check boundingBox before continuing
...
...
@@ -178,7 +178,7 @@ THREE.Mesh.prototype.raycast = ( function () {
if
(
geometry
.
boundingBox
!==
null
)
{
if
(
ray
.
i
sIntersection
Box
(
geometry
.
boundingBox
)
===
false
)
return
;
if
(
ray
.
i
ntersects
Box
(
geometry
.
boundingBox
)
===
false
)
return
;
}
...
...
src/objects/Points.js
浏览文件 @
916ce9c6
...
...
@@ -32,11 +32,7 @@ THREE.Points.prototype.raycast = ( function () {
if
(
geometry
.
boundingBox
!==
null
)
{
if
(
ray
.
isIntersectionBox
(
geometry
.
boundingBox
)
===
false
)
{
return
;
}
if
(
ray
.
intersectsBox
(
geometry
.
boundingBox
)
===
false
)
return
;
}
...
...
test/unit/math/Box2.js
浏览文件 @
916ce9c6
...
...
@@ -189,23 +189,23 @@ test( "distanceToPoint", function() {
ok
(
b
.
distanceToPoint
(
new
THREE
.
Vector2
(
-
2
,
-
2
)
)
==
Math
.
sqrt
(
2
),
"
Passed!
"
);
});
test
(
"
i
sIntersection
Box
"
,
function
()
{
test
(
"
i
ntersects
Box
"
,
function
()
{
var
a
=
new
THREE
.
Box2
(
zero2
.
clone
(),
zero2
.
clone
()
);
var
b
=
new
THREE
.
Box2
(
zero2
.
clone
(),
one2
.
clone
()
);
var
c
=
new
THREE
.
Box2
(
one2
.
clone
().
negate
(),
one2
.
clone
()
);
ok
(
a
.
i
sIntersection
Box
(
a
),
"
Passed!
"
);
ok
(
a
.
i
sIntersection
Box
(
b
),
"
Passed!
"
);
ok
(
a
.
i
sIntersection
Box
(
c
),
"
Passed!
"
);
ok
(
a
.
i
ntersects
Box
(
a
),
"
Passed!
"
);
ok
(
a
.
i
ntersects
Box
(
b
),
"
Passed!
"
);
ok
(
a
.
i
ntersects
Box
(
c
),
"
Passed!
"
);
ok
(
b
.
i
sIntersection
Box
(
a
),
"
Passed!
"
);
ok
(
c
.
i
sIntersection
Box
(
a
),
"
Passed!
"
);
ok
(
b
.
i
sIntersection
Box
(
c
),
"
Passed!
"
);
ok
(
b
.
i
ntersects
Box
(
a
),
"
Passed!
"
);
ok
(
c
.
i
ntersects
Box
(
a
),
"
Passed!
"
);
ok
(
b
.
i
ntersects
Box
(
c
),
"
Passed!
"
);
b
.
translate
(
new
THREE
.
Vector2
(
2
,
2
)
);
ok
(
!
a
.
i
sIntersection
Box
(
b
),
"
Passed!
"
);
ok
(
!
b
.
i
sIntersection
Box
(
a
),
"
Passed!
"
);
ok
(
!
b
.
i
sIntersection
Box
(
c
),
"
Passed!
"
);
ok
(
!
a
.
i
ntersects
Box
(
b
),
"
Passed!
"
);
ok
(
!
b
.
i
ntersects
Box
(
a
),
"
Passed!
"
);
ok
(
!
b
.
i
ntersects
Box
(
c
),
"
Passed!
"
);
});
test
(
"
intersect
"
,
function
()
{
...
...
test/unit/math/Box3.js
浏览文件 @
916ce9c6
...
...
@@ -204,23 +204,23 @@ test( "distanceToPoint", function() {
ok
(
b
.
distanceToPoint
(
new
THREE
.
Vector3
(
-
2
,
-
2
,
-
2
)
)
==
Math
.
sqrt
(
3
),
"
Passed!
"
);
});
test
(
"
i
sIntersection
Box
"
,
function
()
{
test
(
"
i
ntersects
Box
"
,
function
()
{
var
a
=
new
THREE
.
Box3
(
zero3
.
clone
(),
zero3
.
clone
()
);
var
b
=
new
THREE
.
Box3
(
zero3
.
clone
(),
one3
.
clone
()
);
var
c
=
new
THREE
.
Box3
(
one3
.
clone
().
negate
(),
one3
.
clone
()
);
ok
(
a
.
i
sIntersection
Box
(
a
),
"
Passed!
"
);
ok
(
a
.
i
sIntersection
Box
(
b
),
"
Passed!
"
);
ok
(
a
.
i
sIntersection
Box
(
c
),
"
Passed!
"
);
ok
(
a
.
i
ntersects
Box
(
a
),
"
Passed!
"
);
ok
(
a
.
i
ntersects
Box
(
b
),
"
Passed!
"
);
ok
(
a
.
i
ntersects
Box
(
c
),
"
Passed!
"
);
ok
(
b
.
i
sIntersection
Box
(
a
),
"
Passed!
"
);
ok
(
c
.
i
sIntersection
Box
(
a
),
"
Passed!
"
);
ok
(
b
.
i
sIntersection
Box
(
c
),
"
Passed!
"
);
ok
(
b
.
i
ntersects
Box
(
a
),
"
Passed!
"
);
ok
(
c
.
i
ntersects
Box
(
a
),
"
Passed!
"
);
ok
(
b
.
i
ntersects
Box
(
c
),
"
Passed!
"
);
b
.
translate
(
new
THREE
.
Vector3
(
2
,
2
,
2
)
);
ok
(
!
a
.
i
sIntersection
Box
(
b
),
"
Passed!
"
);
ok
(
!
b
.
i
sIntersection
Box
(
a
),
"
Passed!
"
);
ok
(
!
b
.
i
sIntersection
Box
(
c
),
"
Passed!
"
);
ok
(
!
a
.
i
ntersects
Box
(
b
),
"
Passed!
"
);
ok
(
!
b
.
i
ntersects
Box
(
a
),
"
Passed!
"
);
ok
(
!
b
.
i
ntersects
Box
(
c
),
"
Passed!
"
);
});
test
(
"
getBoundingSphere
"
,
function
()
{
...
...
test/unit/math/Plane.js
浏览文件 @
916ce9c6
...
...
@@ -81,14 +81,14 @@ test( "setComponents", function() {
test
(
"
setFromNormalAndCoplanarPoint
"
,
function
()
{
var
normal
=
one3
.
clone
().
normalize
();
var
a
=
new
THREE
.
Plane
().
setFromNormalAndCoplanarPoint
(
normal
,
zero3
);
ok
(
a
.
normal
.
equals
(
normal
),
"
Passed!
"
);
ok
(
a
.
constant
==
0
,
"
Passed!
"
);
});
test
(
"
normalize
"
,
function
()
{
var
a
=
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
2
,
0
,
0
),
2
);
a
.
normalize
();
ok
(
a
.
normal
.
length
()
==
1
,
"
Passed!
"
);
ok
(
a
.
normal
.
equals
(
new
THREE
.
Vector3
(
1
,
0
,
0
)
),
"
Passed!
"
);
...
...
@@ -97,7 +97,7 @@ test( "normalize", function() {
test
(
"
negate/distanceToPoint
"
,
function
()
{
var
a
=
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
2
,
0
,
0
),
-
2
);
a
.
normalize
();
ok
(
a
.
distanceToPoint
(
new
THREE
.
Vector3
(
4
,
0
,
0
)
)
===
3
,
"
Passed!
"
);
ok
(
a
.
distanceToPoint
(
new
THREE
.
Vector3
(
1
,
0
,
0
)
)
===
0
,
"
Passed!
"
);
...
...
@@ -109,7 +109,7 @@ test( "negate/distanceToPoint", function() {
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!
"
);
...
...
@@ -119,7 +119,7 @@ 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
);
...
...
@@ -132,23 +132,23 @@ test( "isInterestionLine/intersectLine", function() {
var
a
=
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
1
,
0
,
0
),
0
);
var
l1
=
new
THREE
.
Line3
(
new
THREE
.
Vector3
(
-
10
,
0
,
0
),
new
THREE
.
Vector3
(
10
,
0
,
0
)
);
ok
(
a
.
i
sIntersection
Line
(
l1
),
"
Passed!
"
);
ok
(
a
.
i
ntersects
Line
(
l1
),
"
Passed!
"
);
ok
(
a
.
intersectLine
(
l1
).
equals
(
new
THREE
.
Vector3
(
0
,
0
,
0
)
),
"
Passed!
"
);
a
=
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
1
,
0
,
0
),
-
3
);
ok
(
a
.
i
sIntersection
Line
(
l1
),
"
Passed!
"
);
ok
(
a
.
i
ntersects
Line
(
l1
),
"
Passed!
"
);
ok
(
a
.
intersectLine
(
l1
).
equals
(
new
THREE
.
Vector3
(
3
,
0
,
0
)
),
"
Passed!
"
);
a
=
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
1
,
0
,
0
),
-
11
);
ok
(
!
a
.
i
sIntersection
Line
(
l1
),
"
Passed!
"
);
ok
(
!
a
.
i
ntersects
Line
(
l1
),
"
Passed!
"
);
ok
(
a
.
intersectLine
(
l1
)
===
undefined
,
"
Passed!
"
);
a
=
new
THREE
.
Plane
(
new
THREE
.
Vector3
(
1
,
0
,
0
),
11
);
ok
(
!
a
.
i
sIntersection
Line
(
l1
),
"
Passed!
"
);
ok
(
!
a
.
i
ntersects
Line
(
l1
),
"
Passed!
"
);
ok
(
a
.
intersectLine
(
l1
)
===
undefined
,
"
Passed!
"
);
});
...
...
@@ -162,7 +162,7 @@ test( "projectPoint", function() {
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
()
{
...
...
test/unit/math/Ray.js
浏览文件 @
916ce9c6
...
...
@@ -109,7 +109,7 @@ test( "distanceSqToPoint", function() {
ok
(
d
===
0
,
"
Passed!
"
);
});
test
(
"
i
sIntersection
Sphere
"
,
function
()
{
test
(
"
i
ntersects
Sphere
"
,
function
()
{
var
a
=
new
THREE
.
Ray
(
one3
.
clone
(),
new
THREE
.
Vector3
(
0
,
0
,
1
)
);
var
b
=
new
THREE
.
Sphere
(
zero3
,
0.5
);
var
c
=
new
THREE
.
Sphere
(
zero3
,
1.5
);
...
...
@@ -117,17 +117,17 @@ test( "isIntersectionSphere", function() {
var
e
=
new
THREE
.
Sphere
(
two3
,
0.1
);
var
f
=
new
THREE
.
Sphere
(
two3
,
1
);
ok
(
!
a
.
i
sIntersection
Sphere
(
b
),
"
Passed!
"
);
ok
(
!
a
.
i
sIntersection
Sphere
(
c
),
"
Passed!
"
);
ok
(
a
.
i
sIntersection
Sphere
(
d
),
"
Passed!
"
);
ok
(
!
a
.
i
sIntersection
Sphere
(
e
),
"
Passed!
"
);
ok
(
!
a
.
i
sIntersection
Sphere
(
f
),
"
Passed!
"
);
ok
(
!
a
.
i
ntersects
Sphere
(
b
),
"
Passed!
"
);
ok
(
!
a
.
i
ntersects
Sphere
(
c
),
"
Passed!
"
);
ok
(
a
.
i
ntersects
Sphere
(
d
),
"
Passed!
"
);
ok
(
!
a
.
i
ntersects
Sphere
(
e
),
"
Passed!
"
);
ok
(
!
a
.
i
ntersects
Sphere
(
f
),
"
Passed!
"
);
});
test
(
"
intersectSphere
"
,
function
()
{
var
TOL
=
0.0001
;
// ray a0 origin located at ( 0, 0, 0 ) and points outward in negative-z direction
var
a0
=
new
THREE
.
Ray
(
zero3
.
clone
(),
new
THREE
.
Vector3
(
0
,
0
,
-
1
)
);
// ray a1 origin located at ( 1, 1, 1 ) and points left in negative-x direction
...
...
@@ -136,75 +136,75 @@ test( "intersectSphere", function() {
// sphere (radius of 2) located behind ray a0, should result in null
var
b
=
new
THREE
.
Sphere
(
new
THREE
.
Vector3
(
0
,
0
,
3
),
2
);
ok
(
a0
.
intersectSphere
(
b
)
===
null
,
"
Passed!
"
);
// sphere (radius of 2) located in front of, but too far right of ray a0, should result in null
var
b
=
new
THREE
.
Sphere
(
new
THREE
.
Vector3
(
3
,
0
,
-
1
),
2
);
ok
(
a0
.
intersectSphere
(
b
)
===
null
,
"
Passed!
"
);
// sphere (radius of 2) located below ray a1, should result in null
var
b
=
new
THREE
.
Sphere
(
new
THREE
.
Vector3
(
1
,
-
2
,
1
),
2
);
ok
(
a1
.
intersectSphere
(
b
)
===
null
,
"
Passed!
"
);
// sphere (radius of 1) located to the left of ray a1, should result in intersection at 0, 1, 1
// sphere (radius of 1) located to the left of ray a1, should result in intersection at 0, 1, 1
var
b
=
new
THREE
.
Sphere
(
new
THREE
.
Vector3
(
-
1
,
1
,
1
),
1
);
ok
(
a1
.
intersectSphere
(
b
).
distanceTo
(
new
THREE
.
Vector3
(
0
,
1
,
1
)
)
<
TOL
,
"
Passed!
"
);
// sphere (radius of 1) located in front of ray a0, should result in intersection at 0, 0, -1
// sphere (radius of 1) located in front of ray a0, should result in intersection at 0, 0, -1
var
b
=
new
THREE
.
Sphere
(
new
THREE
.
Vector3
(
0
,
0
,
-
2
),
1
);
ok
(
a0
.
intersectSphere
(
b
).
distanceTo
(
new
THREE
.
Vector3
(
0
,
0
,
-
1
)
)
<
TOL
,
"
Passed!
"
);
// sphere (radius of 2) located in front & right of ray a0, should result in intersection at 0, 0, -1, or left-most edge of sphere
// sphere (radius of 2) located in front & right of ray a0, should result in intersection at 0, 0, -1, or left-most edge of sphere
var
b
=
new
THREE
.
Sphere
(
new
THREE
.
Vector3
(
2
,
0
,
-
1
),
2
);
ok
(
a0
.
intersectSphere
(
b
).
distanceTo
(
new
THREE
.
Vector3
(
0
,
0
,
-
1
)
)
<
TOL
,
"
Passed!
"
);
// same situation as above, but move the sphere a fraction more to the right, and ray a0 should now just miss
// same situation as above, but move the sphere a fraction more to the right, and ray a0 should now just miss
var
b
=
new
THREE
.
Sphere
(
new
THREE
.
Vector3
(
2.01
,
0
,
-
1
),
2
);
ok
(
a0
.
intersectSphere
(
b
)
===
null
,
"
Passed!
"
);
// following tests are for situations where the ray origin is inside the sphere
// sphere (radius of 1) center located at ray a0 origin / sphere surrounds the ray origin, so the first intersect point 0, 0, 1,
// sphere (radius of 1) center located at ray a0 origin / sphere surrounds the ray origin, so the first intersect point 0, 0, 1,
// is behind ray a0. Therefore, second exit point on back of sphere will be returned: 0, 0, -1
// thus keeping the intersection point always in front of the ray.
var
b
=
new
THREE
.
Sphere
(
zero3
.
clone
(),
1
);
ok
(
a0
.
intersectSphere
(
b
).
distanceTo
(
new
THREE
.
Vector3
(
0
,
0
,
-
1
)
)
<
TOL
,
"
Passed!
"
);
// sphere (radius of 4) center located behind ray a0 origin / sphere surrounds the ray origin, so the first intersect point 0, 0, 5,
// sphere (radius of 4) center located behind ray a0 origin / sphere surrounds the ray origin, so the first intersect point 0, 0, 5,
// is behind ray a0. Therefore, second exit point on back of sphere will be returned: 0, 0, -3
// thus keeping the intersection point always in front of the ray.
var
b
=
new
THREE
.
Sphere
(
new
THREE
.
Vector3
(
0
,
0
,
1
),
4
);
ok
(
a0
.
intersectSphere
(
b
).
distanceTo
(
new
THREE
.
Vector3
(
0
,
0
,
-
3
)
)
<
TOL
,
"
Passed!
"
);
// sphere (radius of 4) center located in front of ray a0 origin / sphere surrounds the ray origin, so the first intersect point 0, 0, 3,
// sphere (radius of 4) center located in front of ray a0 origin / sphere surrounds the ray origin, so the first intersect point 0, 0, 3,
// is behind ray a0. Therefore, second exit point on back of sphere will be returned: 0, 0, -5
// thus keeping the intersection point always in front of the ray.
var
b
=
new
THREE
.
Sphere
(
new
THREE
.
Vector3
(
0
,
0
,
-
1
),
4
);
ok
(
a0
.
intersectSphere
(
b
).
distanceTo
(
new
THREE
.
Vector3
(
0
,
0
,
-
5
)
)
<
TOL
,
"
Passed!
"
);
});
test
(
"
i
sIntersection
Plane
"
,
function
()
{
test
(
"
i
ntersects
Plane
"
,
function
()
{
var
a
=
new
THREE
.
Ray
(
one3
.
clone
(),
new
THREE
.
Vector3
(
0
,
0
,
1
)
);
// parallel plane in front of the ray
var
b
=
new
THREE
.
Plane
().
setFromNormalAndCoplanarPoint
(
new
THREE
.
Vector3
(
0
,
0
,
1
),
one3
.
clone
().
sub
(
new
THREE
.
Vector3
(
0
,
0
,
-
1
)
)
);
ok
(
a
.
i
sIntersection
Plane
(
b
),
"
Passed!
"
);
ok
(
a
.
i
ntersects
Plane
(
b
),
"
Passed!
"
);
// parallel plane coincident with origin
var
c
=
new
THREE
.
Plane
().
setFromNormalAndCoplanarPoint
(
new
THREE
.
Vector3
(
0
,
0
,
1
),
one3
.
clone
().
sub
(
new
THREE
.
Vector3
(
0
,
0
,
0
)
)
);
ok
(
a
.
i
sIntersection
Plane
(
c
),
"
Passed!
"
);
ok
(
a
.
i
ntersects
Plane
(
c
),
"
Passed!
"
);
// parallel plane behind the ray
var
d
=
new
THREE
.
Plane
().
setFromNormalAndCoplanarPoint
(
new
THREE
.
Vector3
(
0
,
0
,
1
),
one3
.
clone
().
sub
(
new
THREE
.
Vector3
(
0
,
0
,
1
)
)
);
ok
(
!
a
.
i
sIntersection
Plane
(
d
),
"
Passed!
"
);
ok
(
!
a
.
i
ntersects
Plane
(
d
),
"
Passed!
"
);
// perpendical ray that overlaps exactly
var
e
=
new
THREE
.
Plane
().
setFromNormalAndCoplanarPoint
(
new
THREE
.
Vector3
(
1
,
0
,
0
),
one3
);
ok
(
a
.
i
sIntersection
Plane
(
e
),
"
Passed!
"
);
ok
(
a
.
i
ntersects
Plane
(
e
),
"
Passed!
"
);
// perpendical ray that doesn't overlap
var
f
=
new
THREE
.
Plane
().
setFromNormalAndCoplanarPoint
(
new
THREE
.
Vector3
(
1
,
0
,
0
),
zero3
);
ok
(
!
a
.
i
sIntersection
Plane
(
f
),
"
Passed!
"
);
ok
(
!
a
.
i
ntersects
Plane
(
f
),
"
Passed!
"
);
});
test
(
"
intersectPlane
"
,
function
()
{
...
...
@@ -295,39 +295,37 @@ test( "distanceSqToSegment", function() {
test
(
"
intersectBox
"
,
function
()
{
var
TOL
=
0.0001
;
var
box
=
new
THREE
.
Box3
(
new
THREE
.
Vector3
(
-
1
,
-
1
,
-
1
),
new
THREE
.
Vector3
(
1
,
1
,
1
)
);
var
a
=
new
THREE
.
Ray
(
new
THREE
.
Vector3
(
-
2
,
0
,
0
),
new
THREE
.
Vector3
(
1
,
0
,
0
)
);
//ray should intersect box at -1,0,0
ok
(
a
.
i
sIntersection
Box
(
box
)
===
true
,
"
Passed!
"
);
ok
(
a
.
i
ntersects
Box
(
box
)
===
true
,
"
Passed!
"
);
ok
(
a
.
intersectBox
(
box
).
distanceTo
(
new
THREE
.
Vector3
(
-
1
,
0
,
0
)
)
<
TOL
,
"
Passed!
"
);
var
b
=
new
THREE
.
Ray
(
new
THREE
.
Vector3
(
-
2
,
0
,
0
),
new
THREE
.
Vector3
(
-
1
,
0
,
0
)
);
//ray is point away from box, it should not intersect
ok
(
b
.
i
sIntersection
Box
(
box
)
===
false
,
"
Passed!
"
);
ok
(
b
.
i
ntersects
Box
(
box
)
===
false
,
"
Passed!
"
);
ok
(
b
.
intersectBox
(
box
)
===
null
,
"
Passed!
"
);
var
c
=
new
THREE
.
Ray
(
new
THREE
.
Vector3
(
0
,
0
,
0
),
new
THREE
.
Vector3
(
1
,
0
,
0
)
);
// ray is inside box, should return exit point
ok
(
c
.
i
sIntersection
Box
(
box
)
===
true
,
"
Passed!
"
);
ok
(
c
.
i
ntersects
Box
(
box
)
===
true
,
"
Passed!
"
);
ok
(
c
.
intersectBox
(
box
).
distanceTo
(
new
THREE
.
Vector3
(
1
,
0
,
0
)
)
<
TOL
,
"
Passed!
"
);
var
d
=
new
THREE
.
Ray
(
new
THREE
.
Vector3
(
0
,
2
,
1
),
new
THREE
.
Vector3
(
0
,
-
1
,
-
1
).
normalize
()
);
//tilted ray should intersect box at 0,1,0
ok
(
d
.
i
sIntersection
Box
(
box
)
===
true
,
"
Passed!
"
);
ok
(
d
.
intersectBox
(
box
).
distanceTo
(
new
THREE
.
Vector3
(
0
,
1
,
0
)
)
<
TOL
,
"
Passed!
"
);
ok
(
d
.
i
ntersects
Box
(
box
)
===
true
,
"
Passed!
"
);
ok
(
d
.
intersectBox
(
box
).
distanceTo
(
new
THREE
.
Vector3
(
0
,
1
,
0
)
)
<
TOL
,
"
Passed!
"
);
var
e
=
new
THREE
.
Ray
(
new
THREE
.
Vector3
(
1
,
-
2
,
1
),
new
THREE
.
Vector3
(
0
,
1
,
0
).
normalize
()
);
//handle case where ray is coplanar with one of the boxes side - box in front of ray
ok
(
e
.
i
sIntersection
Box
(
box
)
===
true
,
"
Passed!
"
);
ok
(
e
.
intersectBox
(
box
).
distanceTo
(
new
THREE
.
Vector3
(
1
,
-
1
,
1
)
)
<
TOL
,
"
Passed!
"
);
ok
(
e
.
i
ntersects
Box
(
box
)
===
true
,
"
Passed!
"
);
ok
(
e
.
intersectBox
(
box
).
distanceTo
(
new
THREE
.
Vector3
(
1
,
-
1
,
1
)
)
<
TOL
,
"
Passed!
"
);
var
f
=
new
THREE
.
Ray
(
new
THREE
.
Vector3
(
1
,
-
2
,
0
),
new
THREE
.
Vector3
(
0
,
-
1
,
0
).
normalize
()
);
//handle case where ray is coplanar with one of the boxes side - box behind ray
ok
(
f
.
isIntersectionBox
(
box
)
===
false
,
"
Passed!
"
);
ok
(
f
.
intersectBox
(
box
)
==
null
,
"
Passed!
"
);
});
ok
(
f
.
intersectsBox
(
box
)
===
false
,
"
Passed!
"
);
ok
(
f
.
intersectBox
(
box
)
==
null
,
"
Passed!
"
);
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录