提交 55475648 编写于 作者: J Jonathan Brandel

added polygon and polyline nodes

上级 fdf6a954
......@@ -58,6 +58,14 @@ THREE.SVGLoader.prototype = {
paths.push( parseRectNode( node ) );
break;
case 'polygon':
paths.push( parsePolygonNode( node ) );
break;
case 'polyline':
paths.push( parsePolylineNode( node ) );
break;
default:
console.log( node );
......@@ -319,6 +327,64 @@ THREE.SVGLoader.prototype = {
}
function parsePolygonNode( node ) {
function iterator( match, a, b ) {
var x = parseFloat( a );
var y = parseFloat( b );
if ( index === 0 ) {
path.moveTo( x, y );
} else {
path.lineTo( x, y );
}
index++;
}
var regex = /(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g;
var path = new THREE.ShapePath();
var index = 0;
node.getAttribute( 'points' ).replace(regex, iterator);
path.currentPath.autoClose = true;
return path;
}
function parsePolylineNode( node ) {
function iterator( match, a, b ) {
var x = parseFloat( a );
var y = parseFloat( b );
if ( index === 0 ) {
path.moveTo( x, y );
} else {
path.lineTo( x, y );
}
index++;
}
var regex = /(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g;
var path = new THREE.ShapePath();
var index = 0;
node.getAttribute( 'points' ).replace(regex, iterator);
path.currentPath.autoClose = false;
return path;
}
// http://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes
function getReflection( a, b ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册