Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 4df216e0fc
Fetching contributors…

Cannot retrieve contributors at this time

63 lines (50 sloc) 2.33 kb
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>
CubicVR.js: AABB Collision Test
</title>
<script src="../../CubicVR.js" type="text/javascript">
</script>
<script type='text/javascript'>
var test = 1,
failed = false;
function checkEqual(a, b){
if(a !== b && !failed){
alert('Test #' + test + ' failed.');
failed = true;
}
test++;
}
function runTests(gl, canvas) {
var res;
// box1 inside box2
res = CubicVR.aabb.intersects([[-1, -1, -1],[1, 1, 1]],
[[-2, -2, -2],[2, 2, 2]]);
checkEqual(res, CubicVR.enums.aabb.A_INSIDE_B);
// box2 inside box1
res = CubicVR.aabb.intersects([[-2, -2, -2],[2, 2, 2]],
[[-1, -1, -1],[1, 1, 1]]);
checkEqual(res, CubicVR.enums.aabb.B_INSIDE_A);
// disjoint (0)
res = CubicVR.aabb.intersects([[ 1, 1, 1],[ 2, 2, 2]],
[[-2, -2, -2],[-1, -1, -1]]);
checkEqual(res, CubicVR.enums.aabb.DISJOINT);
// disjoint
res = CubicVR.aabb.intersects([[ 1, 1, 1],[ 2, 2, 2]],
[[-2, -2, -2],[-1, -1, -1]]);
checkEqual(res, CubicVR.enums.aabb.DISJOINT);
// disjoint
res = CubicVR.aabb.intersects([[ 1, 1, 1],[2, 2, 2]],
[[ 1, 3, 1],[2, 4, 2]]);
checkEqual(res, CubicVR.enums.aabb.DISJOINT);
// intersection
res = CubicVR.aabb.intersects([[-1, -1, -1],[1, 1, 1]],
[[ 1, 1, 1],[2, 2, 2]]);
checkEqual(res, CubicVR.enums.aabb.INTERSECT);
alert('All tests passed');
}
</script>
</head>
<body onLoad="CubicVR.start('auto',runTests);"></body>
</html>
Jump to Line
Something went wrong with that request. Please try again.