sates6

1.0.0 • Public • Published

SATES6.js

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

SAT.js is a Javascript implementation of the Separating Axis Theorem for convex polygons and polyhedra.

Requires three.js.

Based on this article.


Usage

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>

Polyhedra

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)

Collision Checking

import { CheckCollision } from 'SAT.js'
CheckCollision(collider1, collider2)

Demo

Examine the SAT algorithm step-by-step here.


Video

Video

Readme

Keywords

Package Sidebar

Install

npm i sates6

Weekly Downloads

7

Version

1.0.0

License

MIT

Unpacked Size

301 kB

Total Files

6

Last publish

Collaborators

  • pickles976