如何在Three JS中将渐变应用于曲线?

时间:2019-02-27 22:39:17

标签: three.js

我正在寻找一种将颜色渐变应用于曲线的方法。我发现的示例将颜色应用于每个线段,但是我的曲线在curveGeometry对象上没有任何顶点或线段,它仅在curveGeometry.position属性中具有点。

下面是我用于创建行的函数,其固定颜色为0x00AAFF。如何为这个东西应用颜色渐变?

createLine() {
    // Create a curve from the points
    var curve = new THREE.CatmullRomCurve3(this.points);

    // Get the points
    var curvePoints = curve.getPoints(this.pointCount);

    // Create the buffer geometry from the points
    var curveGeometry = new THREE.BufferGeometry().setFromPoints(curvePoints);

    // Create a material for the line
    var curveMaterial = new THREE.LineBasicMaterial({
        color : 0x00AAFF,
    });

    // Create the line with the geometry and the material
    var line = new THREE.Line(curveGeometry, curveMaterial);

    return line;
}

此问题针对使用顶点的线解决了此问题,但我的行没有顶点:

Multi-stop Gradient in THREE.js for Lines

0 个答案:

没有答案