LineMaterial Dashed

Hi, I’ m trying to show a dashed line.
const geometr = new THREE.LineGeometry();

            const pointsPR = [];
            pointsPR.push(100, 0, 0);
            matLine = new THREE.LineMaterial({

                color: 0xffff00,
                linewidth: 0.004, // in pixels
                //resolution:  // to be set by renderer, eventually
                dashed: true,

            lineEX = new THREE.Line2(geometr, matLine);

But shows the line continious. Thanks

Try to add lineEX.computeLineDistances();

I added this but the problem persist.

Ah, are you using fat lines?

No, I am not

Then could you provide an editable working live code example, that demonstrates the issue?

Sorry, I didn´t understand what do you want it. Here is the code example:


So, yes, you’re using that technique of fat lines.
Set your material like this:

matLine = new LineMaterial({
  linewidth: 2, // in pixels
  defines: {"USE_DASH":""}

and set resolution for lines in animation loop:

function animate() {

    requestAnimationFrame( animate );
    matLine.resolution.set(innerWidth, innerHeight);

    renderer.render( scene, camera );

1 Like

Understood. Thank you very much!!

You’re welcome :beers: