FIXED! ThreeJS Seam/Artifact Lines Bug

Reproducing the issue described here: https://discourse.threejs.org/t/canvas-texture-seams-artifact-lines-at-repeat-border/15512 https://github.com/mrdoob/three.js/issues/19445

HTML

<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/three.js"></script>

CSS

body {
    background-color: black;
	margin: 0;
}

JavaScript

//Just some code to make the grass canvas texture. No need to parse through it.
let DoublePI = Math.PI * 2.0;
let GrassColor = new THREE.Color('#0c4013');
function HasFlag({ borderFlags, testFlag }) {
    return !!(borderFlags & testFlag);
}
function LerpBorderWaveLine({ context, startX, startY, endX, endY, lineCount,
    waveFrequency, horizontalWaveAmplitude, verticalWaveAmplitude, waveRandomness
}) {
    context.beginPath();
    context.moveTo(startX, startY);
    let lerpInterval = 1.0 / lineCount;
    let oneMinus;
    for (let lerpRatio = 0.0; lerpRatio <= 1.0; lerpRatio += lerpInterval) {
        oneMinus = 1.0 - lerpRatio;
        context.lineTo(
            oneMinus * startX + lerpRatio * endX +
                Math.sin(waveFrequency * lerpRatio + Math.random() * waveRandomness) * verticalWaveAmplitude,
            oneMinus * startY + lerpRatio * endY +
                Math.sin(waveFrequency * lerpRatio + Math.random() * waveRandomness) * horizontalWaveAmplitude
        );
    }
    context.stroke();
}
function CreateCanvasTexture({ width, height, color, borderColor, colorVariances, colorSubtractions,
    lineCount, lengthVariance, lengthAddition,
    borderLineWidth, waveFrequency, waveAmplitude, waveRandomness, borderFlags }) {
    let context = document.createElement('canvas').getContext('2d');
    context.canvas.width = width;
    context.canvas.height = height;
    context.fillStyle = '#' + color.getHexString();
    context.fillRect(0, 0, width, height);
    let imageData = context.getImageData(0, 0, width, height);
    let data = imageData.data;
    for (let lineIndex = 0; lineIndex < lineCount; ++lineIndex) {
        let x = Math.random() * width;
        let y = Math.random() * height;
        let direction = Math.random() * DoublePI;
        let length = Math.random() * lengthVariance + lengthAddition;
        let redDifference = Math.round(Math.random() * colorVariances.red - colorSubtractions.red);
        let greenDifference =...