@@ -615,14 +615,14 @@ function parseStrokeProperties(style, builder, uniforms, context) {
615615
616616 if ( 'stroke-line-dash' in style ) {
617617 context . functions [ 'getSingleDashDistance' ] =
618- `float getSingleDashDistance(float distance, float radius, float dashOffset, float dashLength, float dashLengthTotal, float capType) {
618+ `float getSingleDashDistance(float distance, float radius, float dashOffset, float dashLength, float dashLengthTotal, float capType, float lineWidth ) {
619619 float localDistance = mod(distance, dashLengthTotal);
620620 float distanceSegment = abs(localDistance - dashOffset - dashLength * 0.5) - dashLength * 0.5;
621621 distanceSegment = min(distanceSegment, dashLengthTotal - localDistance);
622622 if (capType == ${ stringToGlsl ( 'square' ) } ) {
623- distanceSegment -= v_width * 0.5;
623+ distanceSegment -= lineWidth * 0.5;
624624 } else if (capType == ${ stringToGlsl ( 'round' ) } ) {
625- distanceSegment = min(distanceSegment, sqrt(distanceSegment * distanceSegment + radius * radius) - v_width * 0.5);
625+ distanceSegment = min(distanceSegment, sqrt(distanceSegment * distanceSegment + radius * radius) - lineWidth * 0.5);
626626 }
627627 return distanceSegment;
628628}` ;
@@ -655,22 +655,22 @@ function parseStrokeProperties(style, builder, uniforms, context) {
655655 . map ( ( v , i ) => `dashLength${ i } ` )
656656 . join ( ' + ' ) ;
657657 let currentDashOffset = '0.' ;
658- let distanceExpression = `getSingleDashDistance(distance, radius, ${ currentDashOffset } , dashLength0, totalDashLength, capType)` ;
658+ let distanceExpression = `getSingleDashDistance(distance, radius, ${ currentDashOffset } , dashLength0, totalDashLength, capType, lineWidth )` ;
659659 for ( let i = 2 ; i < dashPattern . length ; i += 2 ) {
660660 currentDashOffset = `${ currentDashOffset } + dashLength${
661661 i - 2
662662 } + dashLength${ i - 1 } `;
663- distanceExpression = `min(${ distanceExpression } , getSingleDashDistance(distance, radius, ${ currentDashOffset } , dashLength${ i } , totalDashLength, capType))` ;
663+ distanceExpression = `min(${ distanceExpression } , getSingleDashDistance(distance, radius, ${ currentDashOffset } , dashLength${ i } , totalDashLength, capType, lineWidth ))` ;
664664 }
665665
666666 context . functions [ dashFunctionName ] =
667- `float ${ dashFunctionName } (float distance, float radius, float capType) {
667+ `float ${ dashFunctionName } (float distance, float radius, float capType, float lineWidth ) {
668668 ${ dashLengthsDef . join ( '\n ' ) }
669669 float totalDashLength = ${ totalLengthDef } ;
670670 return ${ distanceExpression } ;
671671}` ;
672672 builder . setStrokeDistanceFieldExpression (
673- `${ dashFunctionName } (currentLengthPx + ${ offsetExpression } , currentRadiusPx, capType)` ,
673+ `${ dashFunctionName } (currentLengthPx + ${ offsetExpression } , currentRadiusPx, capType, v_width )` ,
674674 ) ;
675675 }
676676}
0 commit comments