LineBasicMaterial
Quick answer
LineBasicMaterial renders Line, LineLoop, and LineSegments with an unlit color, optional vertex colors, and opacity. It is the default line material and is cheap, but linewidth above 1 is ignored on nearly every WebGL platform unless you switch to an addon wide-line material.
new THREE.LineBasicMaterial ( parameters )
Key points
- Set vertexColors to true and add a color attribute to give each vertex its own tint.
- Transparent lines need transparent and opacity set together to blend correctly.
- fog controls whether the line fades into scene fog with distance.
Example
const geometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-5, 0, 0),
new THREE.Vector3(0, 3, 0),
new THREE.Vector3(5, 0, 0)
]);
const material = new THREE.LineBasicMaterial({
color: 0x4aa3df,
transparent: true,
opacity: 0.9
});
const line = new THREE.Line(geometry, material);
scene.add(line);import { Line2 } from 'three/addons/lines/Line2.js';
import { LineGeometry } from 'three/addons/lines/LineGeometry.js';
import { LineMaterial } from 'three/addons/lines/LineMaterial.js';
const lineGeometry = new LineGeometry();
lineGeometry.setPositions([-5, 0, 0, 0, 3, 0, 5, 0, 0]);
const lineMaterial = new LineMaterial({
color: 0x4aa3df,
linewidth: 3, // 单位是像素
worldUnits: false
});
lineMaterial.resolution.set(window.innerWidth, window.innerHeight);
const thick = new Line2(lineGeometry, lineMaterial);
thick.computeLineDistances();
scene.add(thick);
Notes
- Expecting thick lines fails; use LineMaterial with resolution or fat-line geometry instead.
- Judging a line's color is affected by colorSpace and tone mapping, so compare it in scene.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). LineBasicMaterial. https://www.jingweizhi.com/en/three/api/line-basic-material.html (accessed 2026-11-03).