Skip to content

Commit 4e24967

Browse files
authored
SVGLoader: Honor scale in strokeWidth. (#33411)
1 parent 4286974 commit 4e24967

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

examples/jsm/loaders/SVGLoader.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,10 @@ class SVGLoader extends Loader {
238238

239239
paths.push( path );
240240

241-
path.userData = { node: node, style: style };
241+
const pathStyle = Object.assign( {}, style );
242+
pathStyle.strokeWidth = style.strokeWidth * getTransformScale( currentTransform );
243+
244+
path.userData = { node: node, style: pathStyle };
242245

243246
}
244247

@@ -1875,6 +1878,14 @@ class SVGLoader extends Loader {
18751878

18761879
}
18771880

1881+
function getTransformScale( m ) {
1882+
1883+
const te = m.elements;
1884+
const det = te[ 0 ] * te[ 4 ] - te[ 1 ] * te[ 3 ];
1885+
return Math.sqrt( Math.abs( det ) );
1886+
1887+
}
1888+
18781889
// Calculates the eigensystem of a real symmetric 2x2 matrix
18791890
// [ A B ]
18801891
// [ B C ]
Lines changed: 17 additions & 0 deletions
Loading

examples/webgl_loader_svg.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
'Defs4': 'models/svg/tests/testDefs/defs4.svg',
111111
'Defs5': 'models/svg/tests/testDefs/defs5.svg',
112112
'Style CSS inside defs': 'models/svg/style-css-inside-defs.svg',
113+
'Styled Paths': 'models/svg/styled-paths.svg',
113114
'Multiple CSS classes': 'models/svg/multiple-css-classes.svg',
114115
'Zero Radius': 'models/svg/zero-radius.svg',
115116
'Styles in svg tag': 'models/svg/tests/styles.svg',

0 commit comments

Comments
 (0)