diff --git a/examples/js/renderers/SVGRenderer.js b/examples/js/renderers/SVGRenderer.js index 8b8e7e9c4502a9fb7e72e74a1cf5e47bddec86d0..9ba08d45b646b9c0c9bd3c87c5c7e850b8dda4b0 100644 --- a/examples/js/renderers/SVGRenderer.js +++ b/examples/js/renderers/SVGRenderer.js @@ -46,7 +46,7 @@ THREE.SVGRenderer = function () { _svgPathPool = [], _svgNode, _pathCount = 0, _currPath, _currStyle, - _quality = 1, _precision = -1; + _quality = 1, _precision = null; this.domElement = _svg; @@ -134,7 +134,7 @@ THREE.SVGRenderer = function () { function convert ( c ) { - return _precision < 0 ? c : c.toFixed(_precision); + return _precision !== null ? c.toFixed(_precision) : c; } @@ -241,7 +241,7 @@ THREE.SVGRenderer = function () { } - addPath ( "!dummy!", ""); // just to flush last svg:path + flushPath(); // just to flush last svg:path scene.traverseVisible( function ( object ) { @@ -447,14 +447,7 @@ THREE.SVGRenderer = function () { } else { - if ( _currPath ) { - - _svgNode = getPathNode( _pathCount ++ ); - _svgNode.setAttribute( 'd', _currPath ); - _svgNode.setAttribute( 'style', _currStyle ); - _svg.appendChild( _svgNode ); - - } + flushPath(); _currStyle = style; _currPath = path; @@ -463,6 +456,20 @@ THREE.SVGRenderer = function () { } + function flushPath() { + + if ( _currPath ) { + + _svgNode = getPathNode( _pathCount ++ ); + _svgNode.setAttribute( 'd', _currPath ); + _svgNode.setAttribute( 'style', _currStyle ); + _svg.appendChild( _svgNode ); + + } + + _currPath = _currStyle = ""; + } + function getPathNode( id ) { if ( _svgPathPool[ id ] == null ) {