Skip to content

Commit d9fa174

Browse files
authored
Merge pull request #13843 from mrdoob/svgloader
SVGLoader: parseRectNode robustness and clean up.
2 parents 36c33e7 + e5383ed commit d9fa174

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

examples/js/loaders/SVGLoader.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,7 @@ THREE.SVGLoader.prototype = {
209209
point.y = numbers[ 1 ];
210210
break;
211211

212-
case 'A':
213-
// TODO:
214-
break;
212+
// case 'A': break;
215213

216214
case 'm':
217215
var numbers = parseFloats( data );
@@ -309,9 +307,7 @@ THREE.SVGLoader.prototype = {
309307
point.y = point.y + numbers[ 1 ];
310308
break;
311309

312-
case 'a':
313-
// TODO:
314-
break;
310+
// case 'a': break;
315311

316312
case 'Z':
317313
case 'z':
@@ -331,8 +327,8 @@ THREE.SVGLoader.prototype = {
331327

332328
function parseRectNode( node, style ) {
333329

334-
var x = parseFloat( node.getAttribute( 'x' ) );
335-
var y = parseFloat( node.getAttribute( 'y' ) );
330+
var x = parseFloat( node.getAttribute( 'x' ) || 0 );
331+
var y = parseFloat( node.getAttribute( 'y' ) || 0 );
336332
var w = parseFloat( node.getAttribute( 'width' ) );
337333
var h = parseFloat( node.getAttribute( 'height' ) );
338334

@@ -360,14 +356,14 @@ THREE.SVGLoader.prototype = {
360356
path.lineTo( x, y );
361357
}
362358

363-
index++;
359+
index ++;
364360

365361
}
366362

367363
var regex = /(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g;
368364

369365
var path = new THREE.ShapePath();
370-
path.color.setStyle( parseFill( node, style ) );
366+
path.color.setStyle( style.fill );
371367

372368
var index = 0;
373369

@@ -392,7 +388,7 @@ THREE.SVGLoader.prototype = {
392388
path.lineTo( x, y );
393389
}
394390

395-
index++;
391+
index ++;
396392

397393
}
398394

0 commit comments

Comments
 (0)