Three.js Mesh Edge Skeleton (Feature, Silhouette & Boundary Edges)
Extract a mesh's edge skeleton in Three.js, covering crease-angle feature edges, open boundary edges and view-dependent silhouette edges recomputed every frame, plus a metal strut-sculpture mode.
Key topics: three.js edges, silhouette edges, feature lines, mesh adjacency, edgesgeometry, npr lines
Game Over
What this code does
- Welding & Adjacency: vertices are merged by position, and each edge records the one or two faces it borders.
- Feature Edges: an edge is a crease when the angle between its two face normals exceeds a threshold.
- Boundary Edges: edges with a single face outline holes and open rims, like the top of the vase.
- Silhouettes: each frame, edges where one face points toward the camera and the other away trace the outline.
- Strut Sculpture: feature and boundary edges become instanced metal cylinders with spheres at their nodes.
- Controls: model, crease angle, edge types, mesh visibility, strut mode and spin.
Related Demos
Continue Learning
JavaScript Implementation
// Feature edges: keep edges whose adjacent face normals differ by more than a crease angle
const edges = new THREE.EdgesGeometry(new THREE.IcosahedronGeometry(1, 1), 30) // thresholdAngle in degrees
scene.add(new THREE.LineSegments(edges, new THREE.LineBasicMaterial({ color: 0x38bdf8 })))
// Silhouette edges (view dependent): an edge is on the outline when one adjacent face
// points toward the camera and the other away:
// const front = (face) => face.normal.dot(eye.clone().sub(face.center)) > 0
// if (front(faceA) !== front(faceB)) silhouette.push(edge)