Dashed Line2 Material

Does dashed lines work the the line2 material. It seems to have parameters for dashed lines but it isn’t working for me. Any ideas?

import { LineMaterial } from "three/examples/jsm/lines/LineMaterial.js";
const lineMat = new LineMaterial({
    color: 0x0000ff,
    linewidth: 3,
    dashed: true,
    dashSize: 5,
    gapSize: 5,
    dashScale: 1,
});
lineMat.resolution.set(window.innerWidth, window.innerHeight);

Or have a look at the lines.js file in this codesandbox

Dashed lines only work if you call Line2.computeLineDistances() and if you enhance the line material by an additional define lineMat.defines.USE_DASH = "";. I know manually adding such code is hacky, but please read this comment for more information.

3 Likes

Ok, fair enough. Thanks for your help!