JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q42987F
  • License MIT

A Three.js library for rendering wide lines with customizable attributes in React Three Fiber

Package Exports

  • three-wideline
  • three-wideline/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (three-wideline) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

three-wideline

three-wideline

A powerful Three.js library for rendering wide lines with customizable attributes, joins, caps, and advanced features. Built for React Three Fiber, it provides an easy-to-use component for creating high-quality 2D lines in 3D space.

Features

  • Customizable Attributes: Set color, width, and opacity per segment
  • Line Joins: Choose from Round, Bevel, Miter, or custom joins
  • Caps: Start and end caps with options like Butt, Round, Square, Top
  • Transparency: Optimized shaders for transparent lines
  • Custom Geometry: Beta support for user-defined custom elements
  • Raycasting: Optional raycasting for interaction
  • React Integration: Seamless integration with React Three Fiber
  • TypeScript: Full TypeScript support with strict typing

Install

npm install three-wideline

Quick Start

import { Canvas } from "@react-three/fiber"
import { Wideline } from "three-wideline"

function MyLine() {
   return (
      <Wideline
         points={[-1, -1, 0, 1, 1, -1]}
         attr={{ color: "red", width: 0.2 }}
         join="Round"
         capsStart="Round"
         capsEnd="Square"
      />
   )
}

function App() {
   return (
      <Canvas>
         <MyLine />
      </Canvas>
   )
}

Documentation

The core concept is based on instanced line rendering, well-documented in:

This library adapts these ideas into a reusable Three.js component with enhanced features.

Examples

Live demo: Wideline Example

CodeSandbox samples:

Repository

GitHub: three-wideline

Development

Prerequisites

  • Node.js >= 18
  • pnpm

Setup

pnpm install

Development Commands

# Start development server with samples
pnpm start

# Run tests
pnpm test

# Build for production
pnpm build

# Lint code
pnpm lint

# Format code
pnpm format

This project includes recommended VS Code extensions in .vscode/extensions.json. Install them for the best development experience:

Core Development:

Testing:

  • Vitest - Test explorer for Vitest

Three.js & React:

Git & Productivity:

File Support:

Theme & Icons:

Testing

This project uses Vitest for testing. Tests are located in src/**/*.test.tsx files.

# Run all tests
pnpm test

# Run tests in watch mode
pnpm test -- --watch

# Run specific test file
pnpm test src/Wideline/Wideline.test.tsx

Building

# Build samples for development
pnpm build

# Build library for distribution
pnpm dist

Architecture

  • TypeScript/React with strict typing
  • Three.js for 3D rendering
  • Vite for fast development and building
  • Vitest for testing
  • ESLint + Prettier for code quality
  • Husky for git hooks
  • API Extractor for documentation generation