From 05adccd1e306c97610872b91adeff445f0396912 Mon Sep 17 00:00:00 2001 From: leomartine Date: Fri, 19 Mar 2021 14:02:28 +0000 Subject: [PATCH] js first commit --- src/paperPlaneAnimation.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/paperPlaneAnimation.js diff --git a/src/paperPlaneAnimation.js b/src/paperPlaneAnimation.js new file mode 100644 index 0000000..31ccaaa --- /dev/null +++ b/src/paperPlaneAnimation.js @@ -0,0 +1 @@ +function View3d(t,e){function n(){for(var t=[],e=[],n=[],r=[],o=[],a=[],s=[],l=0,p=0;p=1?(n=50*Math.tan(Math.PI/360*40),o=(i=-n)*e,a=n*e):(a=50*Math.tan(Math.PI/360*40),n=a/e,i=(o=-a)/e);var s=a-o,h=n-i;t[0]=100/s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=100/h,t[6]=0,t[7]=0,t[8]=(o+a)/s,t[9]=(n+i)/h,t[10]=-1250/1150,t[11]=-1,t[12]=0,t[13]=0,t[14]=-12e4/1150,t[15]=0,t[15]+=700;var c=u.getUniformLocation(u.program,"uProjectionMatrix");u.uniformMatrix4fv(c,!1,t)}(),View3d.lastX=-1,View3d.lastY=-1,View3d.touchtime=0,l.addEventListener("mousedown",o),l.addEventListener("mouseup",a),l.addEventListener("mousemove",s),l.addEventListener("touchstart",o,{capture:!0,passive:!1}),l.addEventListener("touchend",a,{capture:!0,passive:!1}),l.addEventListener("touchmove",s,{capture:!0,passive:!1})}(),this.initBuffers=n,this.draw=function(){r(),u.useProgram(u.program);var t=View3d.modelViewMatrix,e=Math.sin(View3d.currentAngle[0]/200),n=Math.cos(View3d.currentAngle[0]/200);t[0]=1,t[4]=0,t[8]=0,t[12]=0,t[1]=0,t[5]=n,t[9]=-e,t[13]=0,t[2]=0,t[6]=e,t[10]=n,t[14]=0,t[3]=0,t[7]=0,t[11]=0,t[15]=1;var i=t.slice(0);e=Math.sin(View3d.currentAngle[1]/100),n=Math.cos(View3d.currentAngle[1]/100),i[0]=n*t[0]-e*t[8],i[4]=t[4],i[8]=n*t[8]+e*t[0],i[12]=t[12],i[1]=n*t[1]-e*t[9],i[5]=t[5],i[9]=n*t[9]+e*t[1],i[13]=t[13],i[2]=n*t[2]-e*t[10],i[6]=t[6],i[10]=n*t[10]+e*t[2],i[14]=t[14],i[3]=n*t[3]-e*t[11],i[7]=t[7],i[11]=n*t[11]+e*t[3],i[15]=t[15];var o=View3d.scale;t[0]=o*i[0],t[4]=o*i[4],t[8]=o*i[8],t[12]=i[12],t[1]=o*i[1],t[5]=o*i[5],t[9]=o*i[9],t[13]=i[13],t[2]=o*i[2],t[6]=o*i[6],t[10]=o*i[10],t[14]=i[14],t[3]=i[3],t[7]=i[7],t[11]=i[11],t[15]=i[15];var a=u.getUniformLocation(u.program,"uModelViewMatrix");u.uniformMatrix4fv(a,!1,t),u.clear(u.COLOR_BUFFER_BIT|u.DEPTH_BUFFER_BIT),u.activeTexture(u.TEXTURE0),u.cullFace(u.BACK),u.drawElements(u.TRIANGLES,c,u.UNSIGNED_BYTE,0),u.activeTexture(u.TEXTURE1),u.cullFace(u.FRONT),u.drawElements(u.TRIANGLES,c,u.UNSIGNED_BYTE,0)}}function CommandArea(t,e){e.addEventListener("keypress",CommandArea.keypress),CommandArea.textArea=e,CommandArea.cde=t}function Orisim3d(t,e,n,i){this.model=t,this.view2d=e,this.view3d=n,this.command=i}function animePlane(){var t=new Model;t.init([-200,-200,200,-200,200,200,-200,200]);var e=new Command(t),n=window.document.getElementById("canvas2d"),i=n?new View2d(t,n):null,r=window.document.getElementById("canvas3d"),o=r?new View3d(t,r):null,a=window.document.getElementById("commandarea");a&&new CommandArea(e,a),orisim3d=new Orisim3d(t,i,o,e);var s=document.getElementById("planeFoldScript.txt");orisim3d.command.command(s.textContent),requestAnimationFrame(loop)}function loop(){orisim3d.model.change&&(null!==orisim3d.view2d&&orisim3d.view2d.draw(),null!==orisim3d.view3d&&orisim3d.view3d.initBuffers(),orisim3d.model.change=!!orisim3d.command.anim()),orisim3d.view3d.draw(),requestAnimationFrame(loop)}(Point=function(t,e,n,i,r){3===arguments.length?(this.x=t,this.y=e,this.z=n,this.xf=t,this.yf=e):2===arguments.length?(this.xf=t,this.yf=e,this.x=t,this.y=e,this.z=0):(this.xf=0|t,this.yf=0|e,this.x=0|n,this.y=0|i,this.z=0|r),this.select=!1,this.set5d=function(t,e,n,i,r){return this.xf=0|t,this.yf=0|e,this.x=0|n,this.y=0|i,this.z=0|r,this},this.set3d=function(t,e,n){return this.x=0|t,this.y=0|e,this.z=0|n,this},this.set2d=function(t,e){return this.xf=0|t,this.yf=0|e,this},this.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},this.scale=function(t){return this.x*=t,this.y*=t,this.z*=t,this},this.norm=function(){console.log("norm:"+this.constructor.name);var t=this.length();return this.scale(1/t)},this.toString=function(){return"["+Math.round(this.x)+","+Math.round(this.y)+","+Math.round(this.z)+" "+Math.round(this.xf)+","+Math.round(this.yf)+"]"},this.toXYZString=function(){return"["+Math.round(this.x)+","+Math.round(this.y)+","+Math.round(this.z)+"]"},this.toXYString=function(){return"["+Math.round(this.xf)+","+Math.round(this.yf)+"]"}}).prototype.constructor=Point,Point.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z},Point.add=function(t,e){return new Point(t.x+e.x,t.y+e.y,t.z+e.z)},Point.sub=function(t,e){return new Point(t.x-e.x,t.y-e.y,t.z-e.z)},Point.compare3d=function(t,e,n,i){if(2===arguments.length){var r=(t.x-e.x)*(t.x-e.x),o=(t.y-e.y)*(t.y-e.y),a=(t.z-e.z)*(t.z-e.z),s=r+o+a;s=s>1?s:0}else s=(s=(r=(t.x-e)*(t.x-e))+(o=(t.y-n)*(t.y-n))+(a=(t.z-i)*(t.z-i)))>1?s:0;return s},Point.compare2d=function(t,e){var n=(t.xf-e.xf)*(t.xf-e.xf),i=(t.yf-e.yf)*(t.yf-e.yf);return Math.sqrt(n+i)};(Plane=function(t,e){this.r=t,this.n=e,this.isOnPlane=function(t){var e=Point.sub(t,this.r),n=Point.dot(e,this.n);return Math.abs(n)<.1},this.intersectPoint=function(t,e){var n=new Point(e.x-t.x,e.y-t.y,e.z-t.z),i=Point.dot(n,this.n);if(0===i)return null;var r=(Point.dot(this.r,this.n)-Point.dot(t,this.n))/i;return r>=0&&r<=1?Point.add(t,n.scale(r)):null},this.intersectSeg=function(t){var e=new Point(t.p2.x-t.p1.x,t.p2.y-t.p1.y,t.p2.z-t.p1.z),n=Point.dot(e,this.n);if(0===n)return null;var i=(Point.dot(this.r,this.n)-Point.dot(t.p1,this.n))/n;return i>=0&&i<=1?Point.add(t.p1,e.scale(i)):null},this.classifyPointToPlane=function(t){var e=Point.dot(this.r,this.n)-Point.dot(this.n,t);return e>Plane.THICKNESS?1:e<-Plane.THICKNESS?-1:0},this.toString=function(){return"Pl[r:"+this.r+" n:"+this.n+"]"}}).prototype.constructor=Plane,Plane.THICKNESS=1,Plane.across=function(t,e){var n=new Point((t.x+e.x)/2,(t.y+e.y)/2,(t.z+e.z)/2),i=new Point(e.x-t.x,e.y-t.y,e.z-t.z);return new Plane(n,i)},Plane.by=function(t,e){var n=new Point(t.x,t.y,t.z),i=new Point(e.y-t.y,-(e.x-t.x),0);return new Plane(n,i)},Plane.ortho=function(t,e){var n=new Point(e.x,e.y,e.z),i=new Point(t.p2.x-t.p1.x,t.p2.y-t.p1.y,t.p2.z-t.p1.z);return new Plane(n,i)};(Segment=function(t,e,n){this.p1=t,this.p2=e,this.type=Segment.PLAIN|n,this.angle=0,this.select=!1,this.reverse=function(){const t=this.p1;this.p1=this.p2,this.p2=t},this.length3d=function(){return Math.sqrt((this.p1.x-this.p2.x)*(this.p1.x-this.p2.x)+(this.p1.y-this.p2.y)*(this.p1.y-this.p2.y)+(this.p1.z-this.p2.z)*(this.p1.z-this.p2.z))},this.length2d=function(){return Math.sqrt((this.p1.xf-this.p2.xf)*(this.p1.xf-this.p2.xf)+(this.p1.yf-this.p2.yf)*(this.p1.yf-this.p2.yf))},this.toString=function(){return"S(P1:"+this.p1.toXYZString()+" "+this.p1.toXYString()+", P2:"+this.p2.toXYZString()+" "+this.p2.toXYString()+")"}}).prototype.constructor=Segment,Segment.PLAIN=0,Segment.EDGE=1,Segment.MOUNTAIN=2,Segment.VALLEY=3,Segment.TEMPORARY=-1,Segment.EPSILON=.01,Segment.compare=function(t,e){var n=Point.compare3d(t.p1,e.p1)+Point.compare3d(e.p2,e.p2);return n>1?n:0},Segment.distanceToSegment=function(t,e){var n=t.p1.x,i=t.p1.y,r=t.p2.x,o=t.p2.y,a=e.x,s=e.y,h=(n-r)*(n-r)+(i-o)*(i-o),l=((i-s)*(i-o)+(n-a)*(n-r))/h,c=((i-s)*(r-n)-(n-a)*(o-i))/h;return l<=0?Math.sqrt((a-n)*(a-n)+(s-i)*(s-i)):l>=1?Math.sqrt((a-r)*(a-r)+(s-o)*(s-o)):Math.abs(c)*Math.sqrt(h)},Segment.closestSeg=function(t,e){var n,i,r,o=new Point(t.p2.x-t.p1.x,t.p2.y-t.p1.y,t.p2.z-t.p1.z),a=new Point(e.p2.x-e.p1.x,e.p2.y-e.p1.y,e.p2.z-e.p1.z),s=new Point(t.p1.x-e.p1.x,t.p1.y-e.p1.y,t.p1.z-e.p1.z),h=Point.dot(o,o),l=Point.dot(a,a),c=Point.dot(a,s);if(h<=Segment.EPSILON&&l<=Segment.EPSILON)n=i=0,r=new Segment(t.p1,e.p1,Segment.TEMPORARY);else{if(h<=Segment.EPSILON)n=0,i=(i=c/l)<0?0:i>1?1:i;else{var u=Point.dot(o,s);if(l<=Segment.EPSILON)i=0,n=(n=-u/h)<0?0:n>1?1:n;else{var p=Point.dot(o,a),d=h*l-p*p;(i=(p*(n=0!==d?(n=(p*c-u*l)/d)<0?0:n>1?1:n:0)+c)/l)<0?(i=0,n=(n=-u/h)<0?0:n>1?1:n):i>1&&(i=1,n=(n=(p-u)/h)<0?0:n>1?1:n)}}var f=Point.add(t.p1,o.scale(n)),g=Point.add(e.p1,a.scale(i));r=new Segment(f,g)}return r},Segment.closestLine=function(t,e){var n,i,r,o=new Point(t.p2.x-t.p1.x,t.p2.y-t.p1.y,t.p2.z-t.p1.z),a=new Point(e.p2.x-e.p1.x,e.p2.y-e.p1.y,e.p2.z-e.p1.z),s=new Point(t.p1.x-e.p1.x,t.p1.y-e.p1.y,t.p1.z-e.p1.z),h=Point.dot(o,o),l=Point.dot(a,a),c=Point.dot(a,s);if(h<=Segment.EPSILON&&l<=Segment.EPSILON)n=i=0,r=new Segment(t.p1,e.p1,Segment.TEMPORARY,-1);else{if(h<=Segment.EPSILON)n=0,i=c/l;else{var u=Point.dot(o,s);if(l<=Segment.EPSILON)i=0,n=-u/h;else{var p=Point.dot(o,a),d=h*l-p*p;i=(p*(n=0!==d?(p*c-u*l)/d:0)+c)/l}}var f=Point.add(t.p1,o.scale(n)),g=Point.add(e.p1,a.scale(i));r=new Segment(f,g)}return r};(Face=function(){this.points=[],this.normal=[0,0,1],this.select=0,this.highlight=!1,this.offset=0,this.computeFaceNormal=function(){if(this.points.length<3)return console.log("Warn Face < 3pts:"+this),null;for(var t=0;t.1)break}return function(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}(this.normal),this.normal},this.toString=function(){var t="F(";return this.points.forEach(function(e,n,i){t=t+"P"+n+e.toString()+(n===i.length-1?"":" ")}),t+=")"}}).prototype.constructor=Face;var Face,Plane;(Model=function(t){function e(t){this.points=[],this.segments=[],this.faces=[];for(var e=new Face,n=null,i=0;i1&&console.log("Error More than one segment on 2 points:"+n.length+" "+n[0].p1+n[0].p2+" "+n[1].p1+n[1].p2),0===n.length?null:n[0]},this.align2dFrom3d=function(t,e){var n=Math.sqrt((e.p1.x-t.x)*(e.p1.x-t.x)+(e.p1.y-t.y)*(e.p1.y-t.y)+(e.p1.z-t.z)*(e.p1.z-t.z))/e.length3d();t.xf=e.p1.xf+n*(e.p2.xf-e.p1.xf),t.yf=e.p1.yf+n*(e.p2.yf-e.p1.yf)},this.faceLeft=function(t,e){void 0===e&&(e=t.p2,t=t.p1);var n,i,r=null;return this.faces.forEach(function(o){(n=o.points.indexOf(t))>=0&&(i=o.points.indexOf(e))>=0&&(i===n+1||n===o.points.length-1&&0===i)&&(r=o)}),r},this.faceRight=function(t,e){void 0===e&&(e=t.p2,t=t.p1);var n=0,i=0,r=null;return this.faces.forEach(function(o){(n=o.points.indexOf(t))>=0&&(i=o.points.indexOf(e))>=0&&(n===i+1||i===o.points.length-1&&0===n)&&(r=o)}),r},this.splitFacesByPlane=function(t,e){for(var n=(e=void 0!==e?e:this.faces).length-1;n>-1;n--){var i=e[n];this.splitFaceByPlane(i,t)}},this.splitFaceByPlane=function(t,e){for(var n=[],i=[],r=!1,o=!1,a=null,s=t.points[t.points.length-1],h=e.classifyPointToPlane(s),l=0;l-1&&t.points.indexOf(i)>-1?r=t:t!==e&&t.points.indexOf(n)>-1&&t.points.indexOf(i)>-1&&(r=t)}),r},this.splitSegmentByPoint=function(t,e){if(0===Point.compare3d(t.p1,e)||0===Point.compare3d(t.p2,e))return t;var n=this.addSegment(e,t.p2,t.type);return t.p2=e,t.length2d(),t.length3d(),n},this.splitSegmentOnPoint=function(t,e){var n=null,i=null;this.align2dFrom3d(e,t);var r=this.searchFace(t,null);if(null!==r&&-1===r.points.indexOf(e))for(n=r.points,i=0;iPoint.sub(t.p2,r).length()?t.p1:t.p2,a=Point.sub(e.p1,r).length()>Point.sub(e.p2,r).length()?e.p1:e.p2;this.splitLineToLineByPoints(o,r,a,n)}else{var s=Plane.across(i.p1,i.p2);this.splitFacesByPlane(s,n)}},this.splitLineToLineByPoints=function(t,e,n,i){var r=Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)+(e.z-t.z)*(e.z-t.z))/Math.sqrt((e.x-n.x)*(e.x-n.x)+(e.y-n.y)*(e.y-n.y)+(e.z-n.z)*(e.z-n.z)),o=e.x+r*(n.x-e.x),a=e.y+r*(n.y-e.y),s=e.z+r*(n.z-e.z),h=new Point(o,a,s),l=Plane.by(t,h);this.splitFacesByPlane(l,i)},this.computeAngle=function(t){var e=t.p1,n=t.p2,i=this.faceLeft(e,n),r=this.faceRight(e,n);if(t.type===Segment.EDGE)return console.log("Warn Angle on Edge:"+t),0;if(null===r||null===i)return console.log("Warn No right and left face for:"+t+" left:"+i+" right:"+r),0;var o=i.computeFaceNormal(),a=r.computeFaceNormal(),s=o[1]*a[2]-o[2]*a[1],h=o[2]*a[0]-o[0]*a[2],l=o[0]*a[1]-o[1]*a[0],c=t.p2.x-t.p1.x,u=t.p2.y-t.p1.y,p=t.p2.z-t.p1.z,d=(s*c+h*u+l*p)/Math.sqrt(c*c+u*u+p*p),f=o[0]*a[0]+o[1]*a[1]+o[2]*a[2];return f>1&&(f=1),f<-1&&(f=-1),t.angle=Math.acos(f)/Math.PI*180,Number.isNaN(t.angle)&&(t.angle=0),d<0&&(t.angle=-t.angle),t.angle=-t.angle,t.angle},this.rotate=function(t,e,n){var i=e*Math.PI/180,r=t.p1.x,o=t.p1.y,a=t.p1.z,s=t.p2.x-r,h=t.p2.y-o,l=t.p2.z-a,c=1/Math.sqrt(s*s+h*h+l*l);s*=c,h*=c,l*=c;var u=Math.sin(i),p=Math.cos(i),d=1-p,f=d*s*s+p,g=d*s*h-l*u,m=d*s*l+h*u,x=d*h*s+l*u,v=d*h*h+p,y=d*h*l-s*u,w=d*l*s-h*u,P=d*l*h+s*u,S=d*l*l+p;n.forEach(function(t){var e=t.x-r,n=t.y-o,i=t.z-a;t.x=r+f*e+g*n+m*i,t.y=o+x*e+v*n+y*i,t.z=a+w*e+P*n+S*i})},this.turn=function(t,e){e*=Math.PI/180;var n=0,i=0,r=0;1===t?n=1:2===t?i=1:3===t&&(r=1);var o=1/Math.sqrt(n*n+i*i+r*r);n*=o,i*=o,r*=o;var a=Math.sin(e),s=Math.cos(e),h=1-s,l=h*n*n+s,c=h*n*i-r*a,u=h*n*r+i*a,p=h*i*n+r*a,d=h*i*i+s,f=h*i*r-n*a,g=h*r*n-i*a,m=h*r*i+n*a,x=h*r*r+s;this.points.forEach(function(t){var e=t.x-0,n=t.y-0,i=t.z-0;t.x=0+l*e+c*n+u*i,t.y=0+p*e+d*n+f*i,t.z=0+g*e+m*n+x*i})},this.adjust=function(t,e){for(var n=e||this.searchSegmentsOnePoint(t),i=100,r=0;i>.001&&r<20;r++){i=0;for(var o=new Point(0,0,0),a=0;ai&&(i=Math.abs(c));var u=l/h;s.p2===t?(o.x+=s.p1.x+(s.p2.x-s.p1.x)*u,o.y+=s.p1.y+(s.p2.y-s.p1.y)*u,o.z+=s.p1.z+(s.p2.z-s.p1.z)*u):s.p1===t&&(o.x+=s.p2.x+(s.p1.x-s.p2.x)*u,o.y+=s.p2.y+(s.p1.y-s.p2.y)*u,o.z+=s.p2.z+(s.p1.z-s.p2.z)*u)}0!==n.length&&(t.x=o.x/n.length,t.y=o.y/n.length,t.z=o.z/n.length)}return i},this.adjustList=function(t){for(var e=100,n=0;e>.001&&n<100;n++){e=0;for(var i=0;ie&&(e=Math.abs(a))}}return e},this.evaluate=function(){for(var t=0;t=.1}},this.move=function(t,e,n,i){(i=null===i?this.points:void 0===i?this.points:i).forEach(function(i){i.x+=t,i.y+=e,i.z+=n})},this.moveOn=function(t,e,n,i){i.forEach(function(i){i.x=t.x*e+i.x*n,i.y=t.y*e+i.y*n,i.z=t.z*e+i.z*n})},this.flat=function(t){(void 0===t?this.points:t).forEach(function(t){t.z=0})},this.offset=function(t,e){e.forEach(function(e){e.offset+=t})},this.selectSegs=function(t){t.forEach(function(t){t.select=!t.select})},this.selectPts=function(t){t.forEach(function(t){t.select=!t.select})},this.get2DBounds=function(){var t=-100,e=100,n=-100,i=100;this.points.forEach(function(r){var o=r.xf,a=r.yf;o>t&&(t=o),on&&(n=a),at&&(t=o),on&&(n=a),a1?2-e:e},GravityBounceInterpolator:function(t){var e=0;return(e=t<.29?((-14.094*t+9.81)*t-.142)*t+0:t<.62?((-16.696*t+21.298)*t-6.39)*t+.909:t<.885?((31.973*t-74.528)*t+56.497)*t-12.844:t<1?((-37.807*t+114.745)*t-114.938)*t+39:((-7278.029*t+22213.034)*t-22589.244)*t+7655.239)>1?2-e:e},BounceInterpolator:function(t){function e(t){return t*t*8}return(t*=1.1226)<.3535?e(t):t<.7408?e(t-.54719)+.7:t<.9644?e(t-.8526)+.9:e(t-1.0435)+.95},OvershootInterpolator:function(t){return(t-=1)*t*(3*t+2)+1},AnticipateInterpolator:function(t){return t*t*(1*t-0)},AnticipateOvershootInterpolator:function(t){return t<.5?.5*function(t,e){return t*t*((e+1)*t-e)}(2*t,1.5):.5*(function(t,e){return t*t*((e+1)*t+e)}(2*t-2,1.5)+2)}},Command=function(t){function e(t){var e=t.replace(/[\);]/g," rparent");return e=e.replace(/,/g," "),e=e.replace(/\/\/.*$/gm,""),f=e.split(/\s+/),m=0,T.toko=f,f}function n(t){var e=null;{const n=new XMLHttpRequest;n.onreadystatechange=function(){n.readyState===XMLHttpRequest.DONE&&200===n.status?n.getResponseHeader("Content-Type").match(/^text/)&&(e=n.responseText):n.readyState!==XMLHttpRequest.OPENED&&console.log("Error ? state:"+n.readyState+" status:"+n.status)},n.open("GET",t,!1),n.send(null)}return null===e&&console.log("Error reading:"+t),e}function i(){var t=[],e=null,n=null,i=null,o=null,a=null;if("d"===f[m]||"define"===f[m]){for(m++;Number.isInteger(Number(f[m]));)t.push(f[m++]);d.init(t)}else if("b"===f[m]||"by"===f[m])m++,e=d.points[f[m++]],n=d.points[f[m++]],d.splitBy(e,n);else if("c"===f[m]||"cross"===f[m])m++,e=d.points[f[m++]],n=d.points[f[m++]],d.splitCross(e,n);else if("p"===f[m]||"perpendicular"===f[m])m++,o=d.segments[f[m++]],a=d.points[f[m++]],d.splitOrtho(o,a);else if("lol"===f[m]||"lineonline"===f[m]){m++;var s=d.segments[f[m++]],h=d.segments[f[m++]];d.splitLineToLine(s,h)}else if("s"===f[m]||"split"===f[m]){m++,o=d.segments[f[m++]];var l=f[m++],c=f[m++];d.splitSegmentByRatio(o,l/c)}else if("r"===f[m]||"rotate"===f[m])m++,o=d.segments[f[m++]],i=f[m++]*(v-y),t=r(),d.rotate(o,i,t);else if("f"===f[m]||"fold"===f[m]){m++,o=d.segments[f[m++]];var u=0;0===y&&(u=d.computeAngle(o)),i=(f[m++]-u)*(v-y),t=r(),0===y&&-1!==d.faceRight(o.p1,o.p2).points.indexOf(t[0])&&o.reverse(),d.rotate(o,i,t)}else if("a"===f[m]||"adjust"===f[m]){m++;var p=0===(t=r()).length?d.points:t;d.adjustList(p)}else if("o"===f[m]||"offset"===f[m]){m++;var g=f[m++]*S;t=function(){var t=[];for(;Number.isInteger(Number(f[m]));)t.push(d.faces[f[m++]]);return t}(),d.offset(g,t)}else if("m"===f[m]||"move"===f[m])m++,d.move(f[m++]*(v-y),f[m++]*(v-y),f[m++]*(v-y),d.points);else if("mo"===f[m]){m++;var x=d.points.get(f[m++]),P=(1-v)/(1-y),E=v-y*P;d.moveOn(x,E,P,d.points)}else if("tx"===f[m])m++,d.turn(1,Number(f[m++])*(v-y));else if("ty"===f[m])m++,d.turn(2,Number(f[m++])*(v-y));else if("tz"===f[m])m++,d.turn(3,Number(f[m++])*(v-y));else if("z"===f[m]){m++;var z=f[m++],A=f[m++],I=f[m++],M=(1+v*(z-1))/(1+y*(z-1)),V=z*(v/M-y);d.move(A*V,I*V,0,null),d.scaleModel(M)}else if("zf"===f[m]){if(m++,0===y){n=d.get3DBounds();w[0]=400/Math.max(n.xmax-n.xmin,n.ymax-n.ymin),w[1]=-(n.xmin+n.xmax)/2,w[2]=-(n.ymin+n.ymax)/2}z=(1+v*(w[0]-1))/(1+y*(w[0]-1)),V=w[0]*(v/z-y),d.move(w[1]*V,w[2]*V,0,null),d.scaleModel(z)}else if("il"===f[m])m++,T.interpolator=Interpolator.LinearInterpolator;else if("ib"===f[m])m++,T.interpolator=Interpolator.BounceInterpolator;else if("io"===f[m])m++,T.interpolator=Interpolator.OvershootInterpolator;else if("ia"===f[m])m++,T.interpolator=Interpolator.AnticipateInterpolator;else if("iao"===f[m])m++,T.interpolator=Interpolator.AnticipateOvershootInterpolator;else if("iad"===f[m])m++,T.interpolator=Interpolator.AccelerateDecelerateInterpolator;else if("iso"===f[m])m++,T.interpolator=Interpolator.SpringOvershootInterpolator;else if("isb"===f[m])m++,T.interpolator=Interpolator.SpringBounceInterpolator;else if("igb"===f[m])m++,T.interpolator=Interpolator.GravityBounceInterpolator;else if("pt"===f[m])m++,d.selectPts(d.points);else if("seg"===f[m])m++,d.selectSegs(d.segments);else if("end"===f[m])m=f.length;else{if("t"===f[m]||"rparent"===f[m]||"u"===f[m]||"co"===f[m])return console.log("Warn unnecessary token :"+f[m]+"\n"),m++,-1;m++}return m}function r(){for(var t=[];Number.isInteger(Number(f[m]));)t.push(d.points[f[m++]]);return t}function o(){for(;mm;return!1===t&&(p=!1),t}if(x===State.pause)return h=(new Date).getTime(),!1;if(x!==State.anim)return!1;var e=((new Date).getTime()-u-l)/c;e>1&&(e=1),v=T.interpolator(e);for(var n=m;"rparent"!==f[m];)if(i(),m===f.length){console.log("Warning missing parent !");break}if(a(),y=v,e>=1){for(v=1,y=0;n