📄 threejs/Addons/Lines/LineSegments2

File: LineSegments2.md | Updated: 11/15/2025


title: LineSegments2 category: Addons layout: docs

LineSegments2

A series of lines drawn between pairs of vertices.

This adds functionality beyond LineSegments, like arbitrary line width and changing width to be in world units. Line2 extends this object, forming a polyline instead of individual segments.

This module can only be used with WebGLRenderer. When using WebGPURenderer, import the class from lines/webgpu/LineSegments2.js.

Code Example

const geometry = new LineSegmentsGeometry();
geometry.setPositions( positions );
geometry.setColors( colors );
const material = new LineMaterial( { linewidth: 5, vertexColors: true } };
const lineSegments = new LineSegments2( geometry, material );
scene.add( lineSegments );

Import

LineSegments2 is an addon, and must be imported explicitly, see Installation#Addons.

import { LineSegments2 } from 'three/addons/lines/LineSegments2.js';

Constructor

new LineSegments2( geometry : LineSegmentsGeometry, material : LineMaterial )

Constructs a new wide line.

geometry | The line geometry.
---|---
material | The line material.

Properties

.isLineSegments2 : boolean (readonly)

This flag can be used for type testing.

Default is true.

Methods

.computeLineDistances() : LineSegments2

Computes an array of distance values which are necessary for rendering dashed lines. For each vertex in the geometry, the method calculates the cumulative length from the current point to the very beginning of the line.

Returns: A reference to this instance.

.raycast( raycaster : Raycaster, intersects : Array.<Object> )

Computes intersection points between a casted ray and this instance.

raycaster | The raycaster.
---|---
intersects | The target array that holds the intersection points.

Overrides: Mesh#raycast

Source

examples/jsm/lines/LineSegments2.js