SATES6.js is an ES6 version of the SAT.js
SAT.js is useful when you want to test collision of two convex polyhedra, but don't want the overhead of a physics engine line Cannon.js or Ammo.js. It can take in geometries in the Three.js format.
SAT.js is a Javascript implementation of the Separating Axis Theorem for convex polygons and polyhedra.
Requires three.js.
Based on this article.
Add three.js and SAT.js to your page:
npm install sates6
Or add via CDN
<script src="https://cdnjs.cloudflare.com/ajax/libs/sates6.js/1.0.0/SAT.js></script>
Convert your Three.js geometries to a SAT.js shape object.
import * as THREE from 'three'
import { ShapeFromGeometry } from 'sates6'
const box1 = new THREE.BoxGeometry(1, 1, 1)
const box2 = new THREE.BoxGeometry(2, 2, 2)
const collider1 = ShapeFromGeometry(box1)
const collider2 = ShapeFromGeometry(box2)
import { CheckCollision } from 'SAT.js'
CheckCollision(collider1, collider2)
Examine the SAT algorithm step-by-step here.