Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/erasta/three-halfedge-dcel

Doubly-Connected-Edge-List (DCEL) implementation for three.js
https://github.com/erasta/three-halfedge-dcel

3d dcel halfedge javascript threejs

Last synced: about 24 hours ago
JSON representation

Doubly-Connected-Edge-List (DCEL) implementation for three.js

Awesome Lists containing this project

README

        

# three-halfedge-dcel
Doubly-Connected-Edge-List (DCEL) or Half-Edge data structure implementation for three.js

[![npm](https://img.shields.io/npm/v/three-halfedge-dcel?style=plastic)](https://www.npmjs.com/package/three-halfedge-dcel)

The Doubly-Connected-Edge-List (DCEL) or Half-Edge data structure is a compact and efficient representation of all faces, edges and vertices in a mesh, allowing fast spatial travel and queries.
DCEL Contains a list of faces in a geometry, each holding a cyclic linked-list of half-edges. Each half-edge is composed of two vertices and its twin half-edge on the adjacent face.
For more information [wikipedia](https://en.wikipedia.org/wiki/Doubly_connected_edge_list). Illustration:

Dcel-halfedge-connectivity

## Demo
This demo color the face pointed by the user, and color all its adjacent faces and their adjacent faces, upto the k-th steps distance, with color according to its adjacency steps distance from the pointed face.
https://erasta.github.io/three-halfedge-dcel
![Preview of the demo](files/halfedge-small.gif)

## Install
```sh
npm install --save three-halfedge-dcel
```

## Usage
```js
import { Dcel } from 'three-halfedge-dcel';
const mesh = new THREE.Mesh(...); // get your mesh from somewhere
const dcel = new Dcel(mesh.geometry, {
mergeVerticesThreshold: identical_vertices_max_dist // default: 1e-4
});
dcel.forAdjacentFaces(faceIndex, (adjacentFaceIndex) => {
... // do something with adjacent faces
})
```