npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

three-tube-wireframe

v1.2.0

Published

Builds a tube-based wireframe geometry in ThreeJS

Downloads

10

Readme

three-tube-wireframe

Build a wireframe geometry made of cylinders from the input THREE.Geometry. This is expensive and leads to a lot of vertices, so its best suited for simple geometries.

Motivations:

  • Thicker wireframes than what gl.LINES supports
  • Volumetric wireframe meshes made up of cylindrical tubes
  • Different face organization such as quads or cross-hatching lines

There are some limitations to this approach, including joins (no attempt is made to join the line segments) and occasional issues with different face organizations (this library makes assumptions about the layout of the incoming THREE.Geometry, which may not always be accurate).

Example:

// Create a base geometry
const geometry = new THREE.TorusGeometry(1, 0.25, 8, 16);

// Now build a wireframe geometry out of it
const wireGeometry = createTubeWireframe(geometry, {
  thickness: 0.03, // thickness in world units of tubes
  radiusSegments: 6, // number of segments around the tubes
  mode: 'quad' // face layout, use quads instead of triangles
});

// And finally add it to the scene
const mesh = new THREE.Mesh(
  wireGeometry,
  new THREE.MeshPhysicalMaterial({
    color: 'white',
    roughness: 0.75,
    flatShading: true
  })
);
scene.add(mesh);

Install

Use npm to install.

npm install three-tube-wireframe --save

It assumes three module is already installed and able to be required by your build tool.

Usage

wireGeo = createTubeWireframe(baseGeo, opt = {})

Builds a new THREE.Geometry from baseGeo using the given options:

  • thickness (default 1) thickness/radius of each individual tube

  • radiusSegments (default 4) number of radial segments around each individual tube

  • lengthSegments (default 1) number of segments along each individual tube

  • openEnded (default false) whether tubes should be open or closed ended

  • matrix (default identity) a THREE.Matrix4 to apply to all segments as the geometry is being built

  • filter (default pass-through) a function that accepts (index, mode) parameters and returns true (accept face) or false (discard face). If the mode is anything except 'triangle', the index will be incremented in steps of 2.

  • buffer (defualt false) if true, returns a THREE.BufferGeometry with an additional basePosition attribute, which provides the positions of the original input baseGeo before wireframe expansion

  • mode (string, default 'triangle') a face layout mode, can be one of the following. Some geometries (such as THREE.IcosahedronGeometry) may produce unusual results with non-triangle modes.

    • 'triangle' build triangles
    • 'quad' attempt to organize into quads
    • 'diagonal0' or 'diagonal1' diagonal lines in different directions
    • 'cross-hatch' a mix of diagonal lines
    • 'horizontal' or 'vertical' straight lines
    • 'diagonal0-horizontal' or 'diagonal1-horizontal' a mix of diagonal and horizontal lines
    • 'diagonal0-vertical' or 'diagonal1-vertical' a mix of diagonal and vertical lines

modes = createTubeWireframe.modes

A list of all the mode names ('triangle', 'quad', etc) that can be passed into the options.

License

MIT, see LICENSE.md for details.