提交 0daa6894 编写于 作者: S Sergey Linev

SVGRenderer: create special method to flush accumulated path

Such method can be used directly at the end of rendering loop
上级 3422cb05
......@@ -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 ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册