Socket
Socket
Sign inDemoInstall

@types/earcut

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/earcut

TypeScript definitions for earcut


Version published
Weekly downloads
129K
increased by2.76%
Maintainers
1
Weekly downloads
 
Created

What is @types/earcut?

@types/earcut provides TypeScript type definitions for the earcut library, which is a fast, portable, and robust polygon triangulation library. It is used to convert 2D polygons into triangles, which is a common requirement in computer graphics and game development.

What are @types/earcut's main functionalities?

Triangulate a simple polygon

This feature allows you to triangulate a simple polygon by providing an array of vertices. The output is an array of triangle indices.

const earcut = require('earcut');
const vertices = [10, 0, 0, 50, 60, 60, 70, 10];
const triangles = earcut(vertices);
console.log(triangles); // [1, 0, 3, 3, 2, 1]

Triangulate a polygon with holes

This feature allows you to triangulate a polygon with holes by providing an array of vertices and an array of hole indices. The output is an array of triangle indices.

const earcut = require('earcut');
const vertices = [0, 0, 50, 0, 50, 50, 0, 50, 10, 10, 40, 10, 40, 40, 10, 40];
const holeIndices = [4];
const triangles = earcut(vertices, holeIndices);
console.log(triangles); // [1, 0, 3, 3, 2, 1, 5, 4, 7, 7, 6, 5]

Triangulate a polygon with 3D coordinates

This feature allows you to triangulate a polygon with 3D coordinates by providing an array of vertices and specifying the dimension. The output is an array of triangle indices.

const earcut = require('earcut');
const vertices = [10, 0, 0, 0, 50, 0, 60, 60, 0, 70, 10, 0];
const dim = 3;
const triangles = earcut(vertices, null, dim);
console.log(triangles); // [1, 0, 3, 3, 2, 1]

Other packages similar to @types/earcut

FAQs

Package last updated on 07 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc