|
@@ -401,153 +401,6 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
|
|
|
|
|
|
};
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-// This was used for testing purposes. Should be removed soon.
|
|
|
-
|
|
|
-THREE.Path.prototype.transform = function( path, segments ) {
|
|
|
-
|
|
|
- var bounds = this.getBoundingBox();
|
|
|
- var oldPts = this.getPoints( segments ); // getPoints getSpacedPoints
|
|
|
-
|
|
|
- //console.log( path.cacheArcLengths() );
|
|
|
- //path.getLengths(400);
|
|
|
- //segments = 40;
|
|
|
-
|
|
|
- return this.getWrapPoints( oldPts, path );
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-// Read http://www.tinaja.com/glib/nonlingr.pdf
|
|
|
-// nonlinear transforms
|
|
|
-
|
|
|
-THREE.Path.prototype.nltransform = function( a, b, c, d, e, f ) {
|
|
|
-
|
|
|
- // a - horizontal size
|
|
|
- // b - lean
|
|
|
- // c - x offset
|
|
|
- // d - vertical size
|
|
|
- // e - climb
|
|
|
- // f - y offset
|
|
|
-
|
|
|
- var oldPts = this.getPoints();
|
|
|
-
|
|
|
- var i, il, p, oldX, oldY;
|
|
|
-
|
|
|
- for ( i = 0, il = oldPts.length; i < il; i ++ ) {
|
|
|
-
|
|
|
- p = oldPts[i];
|
|
|
-
|
|
|
- oldX = p.x;
|
|
|
- oldY = p.y;
|
|
|
-
|
|
|
- p.x = a * oldX + b * oldY + c;
|
|
|
- p.y = d * oldY + e * oldX + f;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return oldPts;
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-// FUTURE Export JSON Format
|
|
|
-
|
|
|
-/* Draws this path onto a 2d canvas easily */
|
|
|
-
|
|
|
-THREE.Path.prototype.debug = function( canvas ) {
|
|
|
-
|
|
|
- var bounds = this.getBoundingBox();
|
|
|
-
|
|
|
- if ( !canvas ) {
|
|
|
-
|
|
|
- canvas = document.createElement( "canvas" );
|
|
|
-
|
|
|
- canvas.setAttribute( 'width', bounds.maxX + 100 );
|
|
|
- canvas.setAttribute( 'height', bounds.maxY + 100 );
|
|
|
-
|
|
|
- document.body.appendChild( canvas );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- var ctx = canvas.getContext( "2d" );
|
|
|
- ctx.fillStyle = "white";
|
|
|
- ctx.fillRect( 0, 0, canvas.width, canvas.height );
|
|
|
-
|
|
|
- ctx.strokeStyle = "black";
|
|
|
- ctx.beginPath();
|
|
|
-
|
|
|
- var i, il, item, action, args;
|
|
|
-
|
|
|
- // Debug Path
|
|
|
-
|
|
|
- for ( i = 0, il = this.actions.length; i < il; i ++ ) {
|
|
|
-
|
|
|
- item = this.actions[ i ];
|
|
|
-
|
|
|
- args = item.args;
|
|
|
- action = item.action;
|
|
|
-
|
|
|
- // Short hand for now
|
|
|
-
|
|
|
- if ( action != THREE.PathActions.CSPLINE_THRU ) {
|
|
|
-
|
|
|
- ctx[ action ].apply( ctx, args );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /*
|
|
|
- switch ( action ) {
|
|
|
-
|
|
|
- case THREE.PathActions.MOVE_TO:
|
|
|
-
|
|
|
- ctx[ action ]( args[ 0 ], args[ 1 ] );
|
|
|
- break;
|
|
|
-
|
|
|
- case THREE.PathActions.LINE_TO:
|
|
|
-
|
|
|
- ctx[ action ]( args[ 0 ], args[ 1 ] );
|
|
|
- break;
|
|
|
-
|
|
|
- case THREE.PathActions.QUADRATIC_CURVE_TO:
|
|
|
-
|
|
|
- ctx[ action ]( args[ 0 ], args[ 1 ], args[ 2 ], args[ 3 ] );
|
|
|
- break;
|
|
|
-
|
|
|
- case THREE.PathActions.CUBIC_CURVE_TO:
|
|
|
-
|
|
|
- ctx[ action ]( args[ 0 ], args[ 1 ], args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ] );
|
|
|
- break;
|
|
|
-
|
|
|
- }
|
|
|
- */
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- ctx.stroke();
|
|
|
- ctx.closePath();
|
|
|
-
|
|
|
- // Debug Points
|
|
|
-
|
|
|
- ctx.strokeStyle = "red";
|
|
|
-
|
|
|
- /* TO CLEAN UP */
|
|
|
-
|
|
|
- var p, points = this.getPoints();
|
|
|
-
|
|
|
- for ( i = 0, il = points.length; i < il; i ++ ) {
|
|
|
-
|
|
|
- p = points[ i ];
|
|
|
-
|
|
|
- ctx.beginPath();
|
|
|
- ctx.arc( p.x, p.y, 1.5, 0, Math.PI * 2, false );
|
|
|
- ctx.stroke();
|
|
|
- ctx.closePath();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
// Breaks path into shapes
|
|
|
|
|
|
THREE.Path.prototype.toShapes = function() {
|