Skip to content

NgtsLine

NgtsLine is a port of Drei’s Line which renders a THREE.Line2 or THREE.LineSegments2 (depending on the value of segments).

Usage

import { NgtsLine } from 'angular-three-soba/abstractions';
<ngts-line [points]="[[0, 0, 0], [1, 1, 1], [2, 0, 0]]" [options]="{ color: 'hotpink', lineWidth: 2 }" />

Vertex Colors

You can use vertex colors to create multi-colored lines:

<ngts-line
[points]="[[0, 0, 0], [1, 1, 0], [2, 0, 0]]"
[options]="{
vertexColors: [[1, 0, 0], [0, 1, 0], [0, 0, 1]],
lineWidth: 3
}"
/>

Line Segments

Set segments: true to render as THREE.LineSegments2 for disconnected line pairs:

<ngts-line
[points]="[[0, 0, 0], [1, 1, 0], [2, 0, 0], [3, 1, 0]]"
[options]="{ segments: true, color: 'cyan' }"
/>

NgtsQuadraticBezierLine

Renders a THREE.Line2 using THREE.QuadraticBezierCurve3 for interpolation.

Usage

import { NgtsQuadraticBezierLine } from 'angular-three-soba/abstractions';
<ngts-quadratic-bezier-line
[start]="[0, 0, 0]"
[end]="[2, 2, 0]"
[options]="{ color: 'yellow', lineWidth: 2 }"
/>

Inputs

InputTypeDescriptionDefault
startPointStarting point of the bezier curve.[0, 0, 0]
endPointEnding point of the bezier curve.[0, 0, 0]
midPointControl point. If not provided, automatically calculated.undefined

Options

PropertyTypeDescriptionDefault
segmentsnumberNumber of segments to approximate the bezier curve.20
lineWidthnumberLine width.1

NgtsCubicBezierLine

Renders a THREE.Line2 using THREE.CubicBezierCurve3 for interpolation.

Usage

import { NgtsCubicBezierLine } from 'angular-three-soba/abstractions';
<ngts-cubic-bezier-line
[start]="[0, 0, 0]"
[end]="[2, 2, 0]"
[midA]="[0.5, 1, 0]"
[midB]="[1.5, 1, 0]"
[options]="{ color: 'magenta', lineWidth: 2 }"
/>

Inputs

InputTypeDescriptionRequired
startPointStart point.Yes
endPointEnd point.Yes
midAPointFirst control point.Yes
midBPointSecond control point.Yes

Options

PropertyTypeDescriptionDefault
segmentsnumberNumber of segments to divide the Bezier curve into.20
lineWidthnumberLine width.1

NgtsCatmullRomLine

Renders a THREE.Line2 using THREE.CatmullRomCurve3 for interpolation.

Usage

import { NgtsCatmullRomLine } from 'angular-three-soba/abstractions';
<ngts-catmull-rom-line
[points]="[[0, 0, 0], [1, 2, 0], [2, 0, 0], [3, 2, 0]]"
[options]="{ closed: false, curveType: 'centripetal', tension: 0.5, color: 'lime', lineWidth: 2 }"
/>

Inputs

InputTypeDescriptionRequired
pointsArrayArray of points.Yes

Options

PropertyTypeDescriptionDefault
closedbooleanWhether the curve should be closed (connect end to start).false
curveType'centripetal' | 'chordal' | 'catmullrom'Type of curve.'centripetal'
tensionnumberTension parameter for the curve (0 to 1).0.5
segmentsnumberNumber of segments to divide the curve into for rendering.20
lineWidthnumberLine width.1

Inputs

name type description required
points Array<Vector3 | Vector2 | [number, number, number] | [number, number] | number> Array of points. Accepts Vector3, Vector2, coordinate tuples, or flat numbers. yes

Options

options input accepts any properties from THREE.Line2 in addition to the following:

Properties

name type description
color THREE.ColorRepresentation Line color. Default: 0xffffff
lineWidth number Line width in pixels. Default: 1
segments boolean Whether to render as THREE.LineSegments2 instead of THREE.Line2. Default: false
dashed boolean Whether the line is dashed.
vertexColors Array<[number, number, number] | [number, number, number, number]> Array of colors for vertex coloring. Supports RGB or RGBA tuples.