Skip to content

RedstoneWizard08/QuickHull

Repository files navigation

QuickHull

A conversion utility for converting points to a cannon-es body.

Originally created by @Dannie226.

Installation

To install use these commands:

  • Yarn:
yarn add quickhull-ts
  • NPM:
npm install quickhull-ts

Type definitions are included, so there is no need for a @types/quickhull-ts package.

Usage

To begin using QuickHull, you first need to import and instantiate it. This can be done with these simple lines of code:

// ES Modules
import QuickHull from "quickhull-ts";

// CommonJS
const QuickHull = require("quickhull-ts");

// Create the hull
const hull = QuickHull.createHull(points);

Your points list can be an array of arrays of three numbers or an array of any class or object that has an x, y, and z property. It can even be both!

Example:

// Import the library
import QuickHull from "quickhull-ts";

// A list of points to use
const points = [
    { x: 1, y: 0, z: 1 },
    [1, 1, 1],
    { x: 1, y: 2, z: 1 },
    [1, 3, 1],
    [1, 4, 1],
    [1, 5, 1],
];

// Create the initial hull
const hull = QuickHull.createHull(points);

// Log the faces to the console
console.log(hull); // [ [ 0, 1, 5 ], [ 2, 0, 5 ], [ 2, 5, 1 ], [ 2, 1, 0 ] ]

More documentation coming soon.

About

A conversion utility for converting points to a cannon-es body.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published