提交 639e7553 编写于 作者: Z zz85

Merge remote-tracking branch 'mind0s/dev' into curves

...@@ -438,7 +438,7 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) { ...@@ -438,7 +438,7 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
// Breaks path into shapes // Breaks path into shapes
THREE.Path.prototype.toShapes = function() { THREE.Path.prototype.toShapes = function( isCCW ) {
var i, il, item, action, args; var i, il, item, action, args;
...@@ -466,89 +466,95 @@ THREE.Path.prototype.toShapes = function() { ...@@ -466,89 +466,95 @@ THREE.Path.prototype.toShapes = function() {
} }
if ( lastPath.actions.length != 0 ) { if ( lastPath.actions.length != 0 ) {
subPaths.push( lastPath ); subPaths.push( lastPath );
} }
// console.log(subPaths); // console.log(subPaths);
if ( subPaths.length == 0 ) return []; if ( subPaths.length == 0 ) return [];
var tmpPath, tmpShape, shapes = []; var solid, tmpPath, tmpShape, shapes = [];
var holesFirst = !THREE.Shape.Utils.isClockWise( subPaths[ 0 ].getPoints() ); if ( subPaths.length == 1) {
// console.log("Holes first", holesFirst); tmpPath = subPaths[0];
tmpShape = new THREE.Shape();
tmpShape.actions = tmpPath.actions;
tmpShape.curves = tmpPath.curves;
shapes.push( tmpShape );
return shapes;
};
if ( subPaths.length == 1) { var holesFirst = !THREE.Shape.Utils.isClockWise( subPaths[ 0 ].getPoints() );
tmpPath = subPaths[0]; holesFirst = isCCW ? !holesFirst : holesFirst;
tmpShape = new THREE.Shape();
tmpShape.actions = tmpPath.actions;
tmpShape.curves = tmpPath.curves;
shapes.push( tmpShape );
return shapes;
};
if ( holesFirst ) { // console.log("Holes first", holesFirst);
tmpShape = new THREE.Shape(); if ( holesFirst ) {
for ( i = 0, il = subPaths.length; i < il; i ++ ) { tmpShape = new THREE.Shape();
tmpPath = subPaths[ i ]; for ( i = 0, il = subPaths.length; i < il; i ++ ) {
if ( THREE.Shape.Utils.isClockWise( tmpPath.getPoints() ) ) { tmpPath = subPaths[ i ];
solid = THREE.Shape.Utils.isClockWise( tmpPath.getPoints() );
solid = isCCW ? !solid : solid;
tmpShape.actions = tmpPath.actions; if ( solid ) {
tmpShape.curves = tmpPath.curves;
shapes.push( tmpShape ); tmpShape.actions = tmpPath.actions;
tmpShape = new THREE.Shape(); tmpShape.curves = tmpPath.curves;
//console.log('cw', i); shapes.push( tmpShape );
tmpShape = new THREE.Shape();
} else { //console.log('cw', i);
tmpShape.holes.push( tmpPath ); } else {
//console.log('ccw', i); tmpShape.holes.push( tmpPath );
} //console.log('ccw', i);
} }
} else { }
// Shapes first } else {
for ( i = 0, il = subPaths.length; i < il; i ++ ) { // Shapes first
tmpShape = undefined;
tmpPath = subPaths[ i ]; for ( i = 0, il = subPaths.length; i < il; i ++ ) {
if ( THREE.Shape.Utils.isClockWise( tmpPath.getPoints() ) ) { tmpPath = subPaths[ i ];
solid = THREE.Shape.Utils.isClockWise( tmpPath.getPoints() );
solid = isCCW ? !solid : solid;
if ( solid ) {
if ( tmpShape ) shapes.push( tmpShape ); if ( tmpShape ) shapes.push( tmpShape );
tmpShape = new THREE.Shape(); tmpShape = new THREE.Shape();
tmpShape.actions = tmpPath.actions; tmpShape.actions = tmpPath.actions;
tmpShape.curves = tmpPath.curves; tmpShape.curves = tmpPath.curves;
} else { } else {
tmpShape.holes.push( tmpPath ); tmpShape.holes.push( tmpPath );
} }
} }
shapes.push( tmpShape ); shapes.push( tmpShape );
} }
//console.log("shape", shapes); //console.log("shape", shapes);
return shapes; return shapes;
}; };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册