Capítulo 568 de 859

Chapter 568: Line2

Core Idea

A polyline drawn between vertices.

This adds functionality beyond Line, like arbitrary line width and changing width to be in world units.It extends LineSegments2, simplifying constructing segments from a chain of points.

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

Key Concepts

  • isLine2 : boolean (readonly): This flag can be used for type testing.

Code Examples

const geometry = new LineGeometry();
geometry.setPositions( positions );
geometry.setColors( colors );
const material = new LineMaterial( { linewidth: 5, vertexColors: true } };
const line = new Line2( geometry, material );
scene.add( line );
  • What it demonstrates: Typical usage of Line2.

Reference Tables

Constructor

Signature
new Line2( geometry : LineGeometry, material : LineMaterial )

Properties

PropertyDescription
.isLine2 : boolean (readonly)This flag can be used for type testing.

Key Takeaways

  1. Line2 extends: EventDispatcher → Object3D → Mesh → LineSegments2
  2. Most relevant properties: isLine2.

Connects To

  • EventDispatcher: parent class
  • Object3D: parent class
  • Mesh: parent class
  • LineSegments2: parent class
  • Source: examples/jsm/lines/Line2.js