Capítulo 5 de 859

Chapter 5: Line

Core Idea

A continuous line. The line are rendered by connecting consecutive vertices with straight lines.

Key Concepts

  • geometry : BufferGeometry: The line geometry.
  • isLine : boolean (readonly): This flag can be used for type testing.
  • material : Material | Array.<Material>: The line material.
  • morphTargetDictionary : Object.<string, number> | undefined: A dictionary representing the morph targets in the geometry. The key is the morph targets name, the value its attribute index. This member …
  • morphTargetInfluences : Array.<number> | undefined: An array of weights typically in the range [0,1] that specify how much of the morph is applied. This member is undefined by default and…

Code Examples

const material = new THREE.LineBasicMaterial( { color: 0x0000ff } );
const points = [];
points.push( new THREE.Vector3( - 10, 0, 0 ) );
points.push( new THREE.Vector3( 0, 10, 0 ) );
points.push( new THREE.Vector3( 10, 0, 0 ) );
const geometry = new THREE.BufferGeometry().setFromPoints( points );
const line = new THREE.Line( geometry, material );
scene.add( line );
  • What it demonstrates: Typical usage of Line.

Reference Tables

Constructor

Signature
`new Line( geometry : BufferGeometry, material : Material

Properties

PropertyDescription
.geometry : BufferGeometryThe line geometry.
.isLine : boolean (readonly)This flag can be used for type testing.
`.material : MaterialArray.<Material>`
`.morphTargetDictionary : Object.<string, number>undefined`
`.morphTargetInfluences : Array.<number>undefined`

Methods

MethodDescription
.computeLineDistances() : LineComputes 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 be…
.raycast( raycaster : Raycaster, intersects : Array.<Object> )Computes intersection points between a casted ray and this line.
.updateMorphTargets()Sets the values of Line#morphTargetDictionary and Line#morphTargetInfluences to make sure existing morph targets can influence th…

Key Takeaways

  1. Line extends: EventDispatcher → Object3D
  2. Most relevant properties: geometry, isLine, material, morphTargetDictionary.
  3. Key methods: computeLineDistances, raycast, updateMorphTargets.

Connects To