Using Separated axis theorem; For spatial indexing I used mapbox/grid-index, that's the fastest solution for real-time collision detection of uniform rectangles.
xxxxxxxxxx
<html>
<head>
<title>OBB Intersections</title>
<script type="text/javascript" src="sat.js"></script>
<script type="text/javascript" src="gridindex.js"></script>
<script type="text/javascript" src="quadtree.js"></script>
<style type="text/css">
html, body {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
font-family: Georgia, sans-serif;
overflow: hidden;
}
#range {
position: absolute;
bottom: 20px;
left: 20px;
width: 90%;
}
#indicator {
position: absolute;
top: 20px;
right: 20px;
font-size: 3em;
font-weight: bold;
color: #222222;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<input type="range" id="range" min="10" max="10000" value="300" />
<div id="indicator">300</div>
<script type="text/javascript" src="intersections.js"></script>
</body>
</html>