Getting Started
This guide will walk you through the basics of installing and using Makio MeshLine in your Three.js project.
A MeshLine is not a native GPU line — it's a triangle-strip ribbon that mirrors your polyline on both sides, so every line has real projected thickness, supports gradients, dashes, textures, and plugs into any TSL shader hook.
Installation
First, install the package:
pnpm add makio-meshline # or npm/yarnUpgrading from V1
Version 2 is the current package line. Existing users should review Migrating from v1 to V2 before upgrading.
Basic Setup
Here's a minimal example of how to create a simple circular MeshLine and add it to your scene:
import * as THREE from 'three/webgpu'
import { MeshLine, circlePositions } from 'makio-meshline'
const scene = new THREE.Scene()
const camera = new THREE.PerspectiveCamera( 55, innerWidth / innerHeight, 0.1, 1000 )
camera.position.z = 20
const renderer = new THREE.WebGPURenderer( { antialias: true } )
renderer.setSize( innerWidth, innerHeight )
document.body.append( renderer.domElement )
await renderer.init()
const line = new MeshLine()
.lines( circlePositions( 64, 10 ), true ) // 64-segment closed circle, radius 10
.lineWidth( 1 ) // scene-space width with sizeAttenuation enabled
.color( 0xff8800 ) // base color
.gradientColor( 0xffffff ) // gradient to white along arc length
.autoResize() // keep screen resolution synced on window resize
scene.add( line )
renderer.setAnimationLoop( () => renderer.render( scene, camera ) )That's it! You should now see a vibrant orange circle in your scene.
Using a Framework?
If you're building with React or Vue, jump to a ready-to-run example with a declarative <MeshLine> wrapper component:
- React Three Fiber — open the R3F StackBlitz template
- Vue — open the Vue StackBlitz template
Next Steps
- Start with the Style Gallery (Basic Example) to compare common options and open the vanilla starter
- Build a camera-independent road with the Road Surface Editor
- Inspect the Joins & Caps gallery for wireframed joins, caps, reversals, and native-WebGPU clipping
- Check Draw & Trail for dynamic updates and spring-driven trails
- Use the Sandbox to tune parameters and copy the generated line
- Move to Instancing and GPU Position & Ring Tunnel once the basics are clear
- Explore the V2 Benchmarks to see interactive performance diagrams rendered with
MeshLine - Check other examples in the Live Demos to see the more advanced scenes in action
- Check out the API Reference to explore all the available customization options.