if(!pacem3D||!pacem3D.maths||!pacem3D.engine)throw"Missing pacem3D core reference";pacem3D=pacem3D||{};pacem3D.primitives={};pacem3D.primitives._utils={parseFloats:function(a){var c=/([\d.-]+)/i,b=c.exec(a),d=[];while(b!=null){var e=b[0],g=parseFloat(e);d.push(g);var f="";a=a.replace(e,f);b=c.exec(a)}return d}};pacem3D.primitives.polyhedron=function(a){this.radius=a||1;if(typeof this.radius!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"radius","Number");};pacem3D.primitives.polyhedron.prototype=new pacem3D.engine.modelVisual3D;pacem3D.primitives.polyhedron.prototype.constructor=pacem3D.engine.polyhedron;pacem3D.primitives.polyhedron.prototype.toString=function(){return"pacem3D.primitives.polyhedron"};pacem3D.primitives.tetrahedron=function(b){this.radius=b||1;if(typeof this.radius!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"radius","Number");this.materials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,255,0,0))];this.backMaterials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,255,0,0))];for(var b=this.radius,j="0 0.5774 -0.8165, 0 0.5774 0.8165, 0.8165 -0.5774 0, -0.8165 -0.5774 0",d=j.split(","),g=[],a=0;a<d.length;a++){var l=d[a],c=pacem3D.primitives._utils.parseFloats(l);g.push(new pacem3D.maths.point3D(c[0]*b,c[1]*b,c[2]*b))}for(var m=[1,2,0,2,3,0,3,1,0,3,2,1],i="0.5 0.9995, 0.5 0.0004995, 0.0004995 0.5, 0.9995 0.5,  0.5 0.0004995, 0.9995 0.5, 0.5 0.9995, 0.0004995 0.5,  0.9995 0.5, 0.5 0.9995, 0.0004995 0.5, 0.5 0.0004995",k=i.split(","),e=[4,5,6,7,8,9,10,11,0,3,2,1],h=[],a=0;a<e.length;a++){var o=e[a],f=pacem3D.primitives._utils.parseFloats(k[o]);h.push({x:f[0],y:f[1]})}var n=new pacem3D.engine.mesh(g,m,h);this.geometry=n};pacem3D.primitives.tetrahedron.prototype=new pacem3D.primitives.polyhedron;pacem3D.primitives.tetrahedron.prototype.constructor=pacem3D.primitives.tetrahedron;pacem3D.primitives.tetrahedron.prototype.toString=function(){return"pacem3D.primitives.tetrahedron"};pacem3D.primitives.octahedron=function(b){this.radius=b||1;if(typeof this.radius!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"radius","Number");this.materials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,0,153,255))];this.backMaterials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,0,153,255))];for(var b=this.radius,j="0 0.7071 -0.7071, 0 0.7071 0.7071, 1 0 0, 0 -0.7071 -0.7071, -1 0 0, 0 -0.7071 0.7071",m=[1,2,0,2,3,0,3,4,0,4,1,0,4,5,1,5,2,1,2,5,3,4,3,5],i="0.5 0.9995, 0.5 0.9995, 0.0004995 0.5, 0.5 0.9995, 0.9995 0.5, 0.5 0.0004995, 0.5 0.0004995, 0.9995 0.5, 0.5 0.9995, 0.0004995 0.5, 0.5 0.0004995, 0.5 0.9995, 0.5 0.0004995, 0.9995 0.5, 0.5 0.9995, 0.0004995 0.5, 0.5 0.0004995, 0.0004995 0.5, 0.5 0.0004995, 0.5 0.9995, 0.5 0.0004995, 0.9995 0.5, 0.5 0.0004995, 0.5 0.9995",e=[6,7,8,9,10,11,12,13,14,15,16,0,17,18,19,20,21,1,2,22,23,4,3,5],d=j.split(","),g=[],a=0;a<d.length;a++){var l=d[a],c=pacem3D.primitives._utils.parseFloats(l);g.push(new pacem3D.maths.point3D(c[0]*b,c[1]*b,c[2]*b))}for(var k=i.split(","),h=[],a=0;a<e.length;a++){var o=e[a],f=pacem3D.primitives._utils.parseFloats(k[o]);h.push({x:f[0],y:f[1]})}var n=new pacem3D.engine.mesh(g,m,h);this.geometry=n};pacem3D.primitives.octahedron.prototype=new pacem3D.primitives.polyhedron;pacem3D.primitives.octahedron.prototype.constructor=pacem3D.primitives.octahedron;pacem3D.primitives.octahedron.prototype.toString=function(){return"pacem3D.primitives.octahedron"};pacem3D.primitives.box=function(g,f,e,d,c,b,a){this.width=g||1;this.height=f||1;this.depth=e||1;this.widthSegments=d||1;this.heightSegments=c||1;this.depthSegments=b||1;if(typeof this.width!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"w","Number");if(typeof this.height!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"h","Number");if(typeof this.depth!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"d","Number");if(typeof this.widthSegments!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"sw","Number");if(typeof this.heightSegments!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"sh","Number");if(typeof this.depthSegments!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"sd","Number");this.materials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,255,201,0))];this.backMaterials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,255,201,0))];this.geometry=pacem3D.primitives.box._geometry(this.width,this.height,this.depth,this.widthSegments,this.heightSegments,this.depthSegments,a)};pacem3D.primitives.box._geometry=function(j,i,h,g,f,e,D){for(var B=[],o=[],n=[],C=D||false,b=0;b<=f;b++)for(var l=i/2-i*(1*b)/(1*f),c=0;c<=e;c++)for(var m=-h/2+h*(1*c)/(1*e),a=0;a<=g;a++){var k=-j/2+j*(1*a)/(1*g);(a==0||a==g||c==0||c==e||b==0||b==f)&&B.push(new pacem3D.maths.point3D(k,l,m))}for(var d=function(d,e,f){for(var b=1e-5,a=0;a<B.length;a++){var c=B[a];if(Math.abs(c.x-d)<b&&Math.abs(c.y-e)<b&&Math.abs(c.z-f)<b)return a}return-1},s=function(e,g,f,h,c,d,a,b){if(!C){n.push(e);n.push(g);n.push(f);n.push(e);n.push(f);n.push(h);o.push({x:c,y:b});o.push({x:a,y:b});o.push({x:a,y:d});o.push({x:c,y:b});o.push({x:a,y:d});o.push({x:c,y:d})}else{n.push([e,g,f,h]);o.push([{x:c,y:b},{x:a,y:b},{x:a,y:d},{x:c,y:d}])}},c=0;c<e;c++)for(var l=i/2,m=-h/2+h*(1*c)/(1*e),r=-h/2+h*(1*(c+1))/(1*e),a=0;a<g;a++){var k=-j/2+1*a*j/(1*g),p=-j/2+1*(a+1)*j/(1*g),v=d(k,l,r),w=d(p,l,r),x=d(p,l,m),y=d(k,l,m),t=1*(a+1)/(1*g),z=1*a/(1*g),u=1-1*(c+1)/(1*e),A=1-1*c/(1*e);s(v,w,x,y,z,A,t,u)}for(var b=0;b<f;b++)for(var l=i/2-1*b*i/(1*f),q=i/2-(b+1)*i/(1*f),m=-h/2,a=0;a<g;a++){var k=j/2-1*a*j/(1*g),p=j/2-(a+1)*j/(1*g),v=d(k,q,m),w=d(p,q,m),x=d(p,l,m),y=d(k,l,m),t=(a+1)/(1*g),z=1*a/(1*g),u=1-(b+1)/(1*f),A=1-1*b/(1*f);s(v,w,x,y,z,A,t,u)}for(var b=0;b<f;b++)for(var l=i/2-1*b*i/(1*f),q=i/2-(b+1)*i/(1*f),k=-j/2,c=0;c<e;c++){var m=-h/2+c*h/(1*e),r=-h/2+(c+1)*h/(1*e),v=d(k,q,m),w=d(k,q,r),x=d(k,l,r),y=d(k,l,m),t=(c+1)/(1*e),z=1*c/(1*e),u=1-(b+1)/(1*f),A=1-b/(1*f);s(v,w,x,y,z,A,t,u)}for(var b=0;b<f;b++)for(var l=i/2-b*i/(1*f),q=i/2-(b+1)*i/(1*f),m=h/2,a=0;a<g;a++){var k=-j/2+a*j/(1*g),p=-j/2+(a+1)*j/(1*g),v=d(k,q,m),w=d(p,q,m),x=d(p,l,m),y=d(k,l,m),t=(a+1)/(1*g),z=1*a/(1*g),u=1-(b+1)/(1*f),A=1-1*b/(1*f);s(v,w,x,y,z,A,t,u)}for(var b=0;b<f;b++)for(var l=i/2-b*i/(1*f),q=i/2-(b+1)*i/(1*f),k=j/2,c=0;c<e;c++){var m=h/2-c*h/(1*e),r=h/2-(c+1)*h/(1*e),v=d(k,q,m),w=d(k,q,r),x=d(k,l,r),y=d(k,l,m),t=(c+1)/(1*e),z=1*c/(1*e),u=1-(b+1)/(1*f),A=1-1*b/(1*f);s(v,w,x,y,z,A,t,u)}for(var c=0;c<e;c++)for(var l=-i/2,m=h/2-h*c/(1*e),r=h/2-h*(c+1)/(1*e),a=0;a<g;a++){var k=-j/2+a*j/(1*g),p=-j/2+(a+1)*j/(1*g),v=d(k,l,r),w=d(p,l,r),x=d(p,l,m),y=d(k,l,m),t=(a+1)/(1*g),z=1*a/(1*g),u=1-(c+1)/(1*e),A=1-1*c/(1*e);s(v,w,x,y,z,A,t,u)}return!C?new pacem3D.engine.mesh(B,n,o):new pacem3D.engine.poly(B,n,o)};pacem3D.primitives.box.prototype=new pacem3D.engine.modelVisual3D;pacem3D.primitives.box.prototype.constructor=pacem3D.primitives.box;pacem3D.primitives.box.prototype.toString=function(){return"pacem3D.primitives.box"};pacem3D.primitives.hexahedron=function(c,d){this.radius=c||1;if(typeof this.radius!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"radius","Number");this.materials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,255,201,0))];this.backMaterials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,255,201,0))];var b=1/Math.sqrt(3),a=2*this.radius*b;this.geometry=pacem3D.primitives.box._geometry(a,a,a,1,1,1,d)};pacem3D.primitives.hexahedron.prototype=new pacem3D.primitives.polyhedron;pacem3D.primitives.hexahedron.prototype.constructor=pacem3D.primitives.hexahedron;pacem3D.primitives.hexahedron.prototype.toString=function(){return"pacem3D.primitives.hexahedron"};pacem3D.primitives.icosahedron=function(b){this.radius=b||1;if(typeof this.radius!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"radius","Number");this.materials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,0,127,0))];this.backMaterials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,0,127,0))];for(var b=this.radius,j="0 0.850651 -0.525731, 0 0.850651 0.525731, 0.850651 0.525731 0, 0.525731 0 -0.850651, -0.525731 0 -0.850651, -0.850651 0.525731 0, -0.525731 0 0.850651, 0.525731 0 0.850651, 0.850651 -0.525731 0, 0 -0.850651 0.525731, 0 -0.850651 -0.525731, -0.850651 -0.525731 0",m=[1,2,0,2,3,0,3,4,0,4,5,0,5,1,0,5,6,1,6,7,1,7,2,1,2,8,3,2,7,8,6,9,7,9,8,7,8,10,3,8,9,10,6,11,9,11,10,9,10,4,3,10,11,4,6,5,11,5,4,11],i="0.5 0.808708, 0.5 0.999501, 0.5 0.808708, 0.191292 0.5,  0.000499547 0.5, 0.5 0.808708, 0.9995 0.5, 0.808708 0.5,0.000499487 0.5, 0.5 0.191292, 0.5 0.000499487, 0.5 0.191292,0.5 0.191292, 0.999501 0.5, 0.5 0.808708, 0.5 0.808708,0.9995 0.5, 0.808708 0.999501, 0.191292 0.5, 0.808708 0.5,0.5 0.999501, 0.808708 0.5, 0.999501 0.808708, 0.5 0.999501,0.000499487 0.5, 0.5 0.191292, 0.5 0.808708, 0.9995 0.5,0.808708 0.999501, 0.191292 0.5, 0.808708 0.5, 0.5 0.999501,0.808708 0.5, 0.999501 0.808708, 0.5 0.808708, 0.5 0.191292,0.9995 0.5, 0.000499547 0.5, 0.5 0.191292, 0.191292 0.5,0.5 0.000499487, 0.808708 0.5, 0.5 0.000499487, 0.999501 0.191292,0.5 0.191292, 0.808708 0.000499487, 0.9995 0.5, 0.5 0.191292,0.5 0.808708, 0.9995 0.5, 0.5 0.191292, 0.808708 0.000499487,0.999501 0.5, 0.5 0.808708, 0.5 0.000499487, 0.808708 0.5,0.999501 0.191292, 0.808708 0.5, 0.5 0.808708, 0.5 0.191292",e=[12,13,14,15,16,17,18,19,20,21,22,23,24,25,0,26,27,28,29,30,31,32,33,1,34,35,36,2,37,38,39,40,41,42,43,7,44,45,46,8,47,48,49,50,51,52,53,9,54,55,3,10,56,57,6,58,59,5,4,11],d=j.split(","),g=[],a=0;a<d.length;a++){var l=d[a],c=pacem3D.primitives._utils.parseFloats(l);g.push(new pacem3D.maths.point3D(c[0]*b,c[1]*b,c[2]*b))}for(var k=i.split(","),h=[],a=0;a<e.length;a++){var o=e[a],f=pacem3D.primitives._utils.parseFloats(k[o]);h.push({x:f[0],y:f[1]})}var n=new pacem3D.engine.mesh(g,m,h);this.geometry=n};pacem3D.primitives.icosahedron.prototype=new pacem3D.primitives.polyhedron;pacem3D.primitives.icosahedron.prototype.constructor=pacem3D.primitives.icosahedron;pacem3D.primitives.icosahedron.prototype.toString=function(){return"pacem3D.primitives.icosahedron"};pacem3D.primitives.dodecahedron=function(b,c){this.radius=b||1;if(typeof this.radius!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"radius","Number");this.materials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,51,51,51))];this.backMaterials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,51,51,51))];var b=this.radius,a=c||false;if(a)this.geometry=pacem3D.primitives.dodecahedron._poly(this.radius);else this.geometry=pacem3D.primitives.dodecahedron._mesh(this.radius)};pacem3D.primitives.dodecahedron._mesh=function(a){var v=new pacem3D.maths.point3D(.356822*a,.934172*a,0*a),w=new pacem3D.maths.point3D(-.356822*a,.934172*a,0*a),x=new pacem3D.maths.point3D(.57735*a,.57735*a,-.57735*a),y=new pacem3D.maths.point3D(0*a,.356822*a,-.934172*a),z=new pacem3D.maths.point3D(-.57735*a,.57735*a,-.57735*a),A=new pacem3D.maths.point3D(-.57735*a,.57735*a,.57735*a),B=new pacem3D.maths.point3D(0*a,.356822*a,.934172*a),C=new pacem3D.maths.point3D(.57735*a,.57735*a,.57735*a),D=new pacem3D.maths.point3D(.934172*a,0*a,-.356822*a),j=new pacem3D.maths.point3D(.934172*a,0*a,.356822*a),k=new pacem3D.maths.point3D(0*a,-.356822*a,.934172*a),l=new pacem3D.maths.point3D(.57735*a,-.57735*a,.57735*a),m=new pacem3D.maths.point3D(.57735*a,-.57735*a,-.57735*a),n=new pacem3D.maths.point3D(.356822*a,-.934172*a,0*a),o=new pacem3D.maths.point3D(-.57735*a,-.57735*a,.57735*a),p=new pacem3D.maths.point3D(-.356822*a,-.934172*a,0*a),q=new pacem3D.maths.point3D(0*a,-.356822*a,-.934172*a),r=new pacem3D.maths.point3D(-.57735*a,-.57735*a,-.57735*a),s=new pacem3D.maths.point3D(-.934172*a,0*a,.356822*a),t=new pacem3D.maths.point3D(-.934172*a,0*a,-.356822*a),b=[];b.push(v);b.push(w);b.push(x);b.push(y);b.push(z);b.push(A);b.push(B);b.push(C);b.push(D);b.push(j);b.push(k);b.push(l);b.push(m);b.push(n);b.push(o);b.push(p);b.push(q);b.push(r);b.push(s);b.push(t);for(var i=[0,2,3,0,3,4,0,4,1,1,5,6,1,6,7,1,7,0,7,9,8,7,8,2,7,2,0,7,6,10,7,10,11,7,11,9,11,13,12,11,12,8,11,8,9,11,10,14,11,14,15,11,15,13,15,17,16,15,16,12,15,12,13,15,14,18,15,18,19,15,19,17,19,4,3,19,3,16,19,16,17,19,18,5,19,5,1,19,1,4,18,14,10,18,10,6,18,6,5,3,2,8,3,8,12,3,12,16],g="0.5 0.999501, 0.5 0.999501, 0.191292 0.808708, 0.5 0.690792, 0.191292 0.808708, 0.191292 0.808708, 0.5 0.690792,                              0.808708 0.808708, 0.000499517 0.5, 0.309208 0.5, 0.5 0.309208,                  0.191292 0.191292, 0.191292 0.191292, 0.309208 0.5,                              0.191292 0.191292, 0.5 0.000499517, 0.5 0.309208, 0.808708 0.191292,             0.000499517 0.5, 0.309208 0.5, 0.690792 0.5, 0.808708 0.808708,                  0.5 0.999501, 0.690792 0.5, 0.5 0.999501, 0.191292 0.808708,                     0.690792 0.5, 0.191292 0.808708, 0.309208 0.5, 0.309208 0.5,                     0.191292 0.191292, 0.5 0.000499517, 0.309208 0.5, 0.5 0.000499517,               0.808708 0.191292, 0.309208 0.5, 0.808708 0.191292,                              0.690792 0.5, 0.191292 0.808708, 0.309208 0.5, 0.690792 0.5,                     0.191292 0.808708, 0.690792 0.5, 0.808708 0.808708,                              0.191292 0.808708, 0.808708 0.808708, 0.808708 0.808708,                         0.5 0.690792, 0.5 0.309208, 0.808708 0.808708, 0.5 0.309208,                     0.808708 0.191292, 0.808708 0.191292, 0.9995 0.5, 0.191292 0.191292,             0.5 0.000499517, 0.808708 0.191292, 0.191292 0.191292,                           0.808708 0.191292, 0.690792 0.5, 0.191292 0.191292,                              0.690792 0.5, 0.191292 0.191292, 0.5 0.000499517, 0.808708 0.191292,             0.191292 0.191292, 0.808708 0.191292, 0.690792 0.5,                              0.690792 0.5, 0.309208 0.5, 0.690792 0.5, 0.808708 0.808708,                     0.5 0.999501, 0.690792 0.5, 0.5 0.999501, 0.191292 0.808708,                     0.690792 0.5, 0.191292 0.808708, 0.5 0.000499517, 0.808708 0.191292,             0.690792 0.5, 0.5 0.000499517, 0.690792 0.5, 0.309208 0.5,                       0.309208 0.5, 0.191292 0.191292, 0.9995 0.5, 0.808708 0.808708,                  0.5 0.690792, 0.9995 0.5, 0.5 0.690792, 0.5 0.309208,                            0.9995 0.5, 0.5 0.309208, 0.309208 0.5, 0.690792 0.5,                            0.808708 0.808708, 0.309208 0.5, 0.808708 0.808708,                              0.5 0.999501, 0.000499517 0.5, 0.5 0.309208, 0.000499517 0.5,                    0.5 0.690792, 0.5 0.690792, 0.000499517 0.5, 0.5 0.690792,                       0.191292 0.191292",d=[20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,0,46,47,48,49,50,51,7,52,53,54,55,56,57,58,59,60,61,9,62,63,64,65,66,67,11,68,69,70,71,72,73,74,75,76,77,13,78,79,80,81,82,83,15,84,85,86,87,88,89,90,91,92,93,17,94,95,96,97,98,99,19,1,4,100,14,101,102,10,103,18,6,5,104,2,105,106,8,107,3,12,16],h=g.split(","),f=[],c=0;c<d.length;c++){var u=d[c],e=pacem3D.primitives._utils.parseFloats(h[u]);f.push({x:e[0],y:e[1]})}return new pacem3D.engine.mesh(b,i,f)};pacem3D.primitives.dodecahedron._poly=function(c){for(var h=[],q="0.3568 0.9342 -0.0000, 0.5774 0.5774 -0.5774  ,0.0000 0.3568 -0.9342  ,-0.5774 0.5774 -0.5774 ,-0.3568 0.9342 -0.0000 ,-0.5774 0.5774 0.5774  ,-0.0000 0.3568 0.9342  ,0.5774 0.5774 0.5774   ,0.9342 0.0000 0.3568   ,0.9342 0.0000 -0.3568  ,0.0000 -0.3568 0.9342  ,0.5774 -0.5774 0.5774  ,0.3568 -0.9342 0.0000  ,0.5774 -0.5774 -0.5774 ,-0.5774 -0.5774 0.5774 ,-0.3568 -0.9342 0.0000 ,-0.5774 -0.5774 -0.5774,0.0000 -0.3568 -0.9342 ,-0.9342 -0.0000 0.3568 ,-0.9342 -0.0000 -0.3568",f=q.split(","),a=0;a<f.length;a++){var b=pacem3D.primitives._utils.parseFloats(f[a]),v=new pacem3D.maths.point3D(b[0]*c,b[1]*c,b[2]*c);h.push(v)}for(var t="0.6908 0.5000 0.9995, 0.8087 0.8087 0.8087, 0.5000 0.9995 0.6908, 0.1913 0.8087 0.8087, 0.3092 0.5000 0.9995, 0.1913 0.1913 0.8087, 0.5000 0.0005 0.6908, 0.8087 0.1913 0.8087, 0.8087 0.8087 0.1913, 0.5000 0.6908 0.0005, 0.5000 0.3092 0.0005, 0.8087 0.1913 0.1913, 0.9995 0.5000 0.3092, 0.1913 0.1913 0.1913, 0.5000 0.0005 0.3092, 0.6908 0.5000 0.0005, 0.3092 0.5000 0.0005, 0.5000 0.9995 0.3092, 0.1913 0.8087 0.1913, 0.9995 0.5000 0.6908, 0.5000 0.6908 0.9995, 0.5000 0.3092 0.9995, 0.0005 0.5000 0.3092, 0.0005 0.5000 0.6908",j=t.split(","),n=[],a=0;a<j.length;a++){var b=pacem3D.primitives._utils.parseFloats(j[a]);n.push({x:b[0],y:b[1]});for(var p="1/1 2/2 3/3 4/4 5/5 f 5/5 6/6 7/7 8/8 1/1          f 8/4 9/5 10/1 2/2 1/3         f 8/9 7/10 11/11 12/12 9/13    f 12/6 13/7 14/8 10/1 9/5      f 12/14 11/15 15/12 16/16 13/17f 16/16 17/9 18/18 14/19 13/17 f 16/15 15/12 19/16 20/17 17/14f 20/20 4/2 3/21 18/22 17/8    f 20/17 19/16 6/9 5/18 4/19    f 19/23 15/14 11/11 7/10 6/19  f 3/21 2/4 10/24 14/6 18/22 ",e=[],i=[],l=p.split("f"),a=0;a<l.length;a++){for(var u=l[a],m=u.replace(/^\s+|\s+$/g,"").split(" "),k=[],g=[],d=0;d<m.length;d++){var o=m[d].split("/"),s=parseInt(o[0]),r=parseInt(o[1]);g.push(s-1);k.push(n[r-1])}i.push(k);e.push(g)}return new pacem3D.engine.poly(h,e,i)}};pacem3D.primitives.dodecahedron.prototype=new pacem3D.primitives.polyhedron;pacem3D.primitives.dodecahedron.prototype.constructor=pacem3D.primitives.dodecahedron;pacem3D.primitives.dodecahedron.prototype.toString=function(){return"pacem3D.primitives.dodecahedron"};pacem3D.primitives.plane=function(r,q,p,o,m){this.width=r||1;this.length=q||1;this.widthSegments=p||4;this.lengthSegments=o||4;if(typeof this.width!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"w(idth)","Number");if(typeof this.length!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"l(ength)","Number");if(typeof this.widthSegments!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"sw","Number");if(typeof this.lengthSegments!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"sl","Number");this.materials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(1,154,215,229))];this.backMaterials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(1,154,215,229))];for(var k=m||false,j=[],e=[],d=[],b=0;b<=this.lengthSegments;b++)for(var a=0;a<=this.widthSegments;a++){var s=-this.width/2+a*this.width/(1*this.widthSegments),t=0,u=-this.length/2+b*this.length/(1*this.lengthSegments);j.push(new pacem3D.maths.point3D(s,t,u));if(b<this.lengthSegments&&a<this.widthSegments){var c=this.widthSegments+1,v=this.lengthSegments+1,f=(a+1)/(1*this.widthSegments),h=1*a/(1*this.widthSegments),g=1-(b+1)/(1*this.lengthSegments),i=1-1*b/(1*this.lengthSegments);if(k){var n=[(b+1)*c+a,(b+1)*c+a+1,b*c+a+1,b*c+a];d.push(n);var l=[{x:h,y:g},{x:f,y:g},{x:f,y:i},{x:h,y:i}];e.push(l)}else{d.push((b+1)*c+a);d.push((b+1)*c+a+1);d.push(b*c+a+1);d.push((b+1)*c+a);d.push(b*c+a+1);d.push(b*c+a);e.push({x:h,y:g});e.push({x:f,y:g});e.push({x:f,y:i});e.push({x:h,y:g});e.push({x:f,y:i});e.push({x:h,y:i})}}}if(k)this.geometry=new pacem3D.engine.poly(j,d,e);else this.geometry=new pacem3D.engine.mesh(j,d,e)};pacem3D.primitives.plane.prototype=new pacem3D.engine.modelVisual3D;pacem3D.primitives.plane.prototype.constructor=pacem3D.primitives.plane;pacem3D.primitives.plane.prototype.toString=function(){return"pacem3D.primitives.plane"};pacem3D.primitives.sphere=function(v,i,w){this.radius=v||1;this.segments=i||36;if(typeof this.radius!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"radius","Number");if(typeof this.segments!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"segments","Number");this.materials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,154,215,229))];this.backMaterials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,154,215,229))];var m=w||false,j=[],d=[],c=[],l=this.radius,q=pacem3D.maths._utils.degToRad(360/this.segments),i=this.segments%2==0?this.segments/2:(this.segments-1)/2;j.push(new pacem3D.maths.point3D(0,l,0));for(var a=1;a<i;a++)for(var o=q*a,s=Math.cos(o),n=Math.sin(o),e=1-1*a/i,b=0;b<this.segments;b++){var p=q*b-Math.PI/2,t=Math.cos(p),u=Math.sin(p),y=l*n*t,z=l*s,A=l*n*u;j.push(new pacem3D.maths.point3D(y,z,A));var f=b==0?this.segments-1:b-1,h=b==0?0:1-1*b/this.segments,g=1-1*f/this.segments;if(m)if(a==1){c.push([1+b,1+f,0]);d.push([{x:h,y:e},{x:g,y:e},{x:.5,y:1}])}else{c.push([(a-1)*this.segments+1+b,(a-1)*this.segments+f+1,(a-2)*this.segments+f+1,(a-2)*this.segments+b+1]);var k=1-(a-1)/i;d.push([{x:h,y:e},{x:g,y:e},{x:g,y:k},{x:h,y:k}])}else if(a==1){c.push(1+b);c.push(1+f);c.push(0);d.push({x:h,y:e});d.push({x:g,y:e});d.push({x:.5,y:1})}else{c.push((a-1)*this.segments+b+1);c.push((a-1)*this.segments+f+1);c.push((a-2)*this.segments+f+1);c.push((a-1)*this.segments+b+1);c.push((a-2)*this.segments+f+1);c.push((a-2)*this.segments+b+1);var k=1-(a-1)/i;d.push({x:h,y:e});d.push({x:g,y:e});d.push({x:g,y:k});d.push({x:h,y:e});d.push({x:g,y:k});d.push({x:h,y:k})}}j.push(new pacem3D.maths.point3D(0,-l,0));for(var r=j.length-1,b=0;b<this.segments;b++){var a=i-2,f=b==0?this.segments-1:b-1,h=b==0?0:1-1*b/this.segments,g=1-1*f/this.segments,e=1-(a+1)/i;if(m){var x=[r,a*this.segments+1+f,a*this.segments+1+b];c.push(x);d.push([{x:.5,y:0},{x:g,y:e},{x:h,y:e}])}else{c.push(r);c.push(a*this.segments+1+f);c.push(a*this.segments+1+b);d.push({x:.5,y:0});d.push({x:g,y:e});d.push({x:h,y:e})}}if(m)this.geometry=new pacem3D.engine.poly(j,c,d);else this.geometry=new pacem3D.engine.mesh(j,c,d)};pacem3D.primitives.sphere.prototype=new pacem3D.engine.modelVisual3D;pacem3D.primitives.sphere.prototype.constructor=pacem3D.primitives.sphere;pacem3D.primitives.sphere.prototype.toString=function(){return"pacem3D.primitives.sphere"};pacem3D.primitives.cylinder=function(cb,bb,eb,W,Y,db){this.radius=cb||1;this.height=bb||1;this.sides=eb||18;this.heightSegments=W||5;this.capSegments=Y||1;var s=db||false;if(typeof this.radius!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"radius","Number");if(typeof this.height!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"height","Number");if(typeof this.sides!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"sides","Number");if(typeof this.heightSegments!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"heightSegments","Number");if(typeof this.capSegments!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"capSegments","Number");this.materials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,154,215,229))];this.backMaterials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,154,215,229))];var E=this.radius,g=[],b=[],c=[],i=pacem3D.maths._utils.degToRad(360/this.sides),gb=this.heightSegments;g.push(new pacem3D.maths.point3D(0,this.height,0));g.push(new pacem3D.maths.point3D(0,0,0));for(var Z=E/this.capSegments,d=1;d<=this.capSegments;d++)for(var L=Z*d,a=0;a<this.sides;a++){var I=2+2*this.sides*(d-1),e=a==0?I+2*(this.sides-1):I+2*(a-1),f=I+2*a,o=Math.cos(i*a),p=-Math.sin(i*a),w=Math.cos(i*(a-1)),x=-Math.sin(i*(a-1)),M=L*o,N=L*p,ab=new pacem3D.maths.point3D(M,this.height,N),X=new pacem3D.maths.point3D(M,0,N);g.push(ab);g.push(X);var v=.5*L/E,B=o*v,D=p*v,A=w*v,C=x*v;if(d==1){var H=[0,e,f],G=[1,f+1,e+1],y=[{x:.5,y:.5},{x:.5+A,y:.5-C},{x:.5+B,y:.5-D}],t=[{x:.5,y:.5},{x:.5+B,y:.5+D},{x:.5+A,y:.5+C}];if(s){c.push(H);c.push(G);b.push(y);b.push(t)}else{c.push(H);c.push(G);for(var a=0;a<y.length;a++)b.push(y[a]);for(var a=0;a<t.length;a++)b.push(t[a])}}else{var F=2+2*this.sides*(d-2),k=a==0?F+2*(this.sides-1):F+2*(a-1),h=F+2*a,u=.5*((d-1)/this.capSegments),S=o*u,U=p*u,T=w*u,V=x*u,m={x:.5+A,y:.5-C},n={x:.5+B,y:.5-D},j={x:.5+S,y:.5-U},z={x:.5+T,y:.5-V},J={x:.5+A,y:.5+C},O={x:.5+B,y:.5+D},K={x:.5+S,y:.5+U},P={x:.5+T,y:.5+V};if(s){var H=[e,f,h,k],G=[f+1,e+1,k+1,h+1];c.push(H);c.push(G);var y=[m,n,j,z],t=[O,J,P,K];b.push(y);b.push(t)}else{c.push(e);c.push(f);c.push(k);c.push(k);c.push(f);c.push(h);c.push(h+1);c.push(f+1);c.push(e+1);c.push(h+1);c.push(e+1);c.push(k+1);b.push(m);b.push(n);b.push(z);b.push(z);b.push(n);b.push(j);b.push(K);b.push(O);b.push(J);b.push(K);b.push(J);b.push(P)}}}for(var q=2+2*this.sides*this.capSegments,r=2+2*this.sides*(this.capSegments-1),d=1;d<=this.heightSegments;d++)for(var a=0;a<this.sides;a++){if(d!=this.heightSegments){var M=E*Math.cos(i*a),N=-E*Math.sin(i*a),fb=this.height*d/this.heightSegments;g.push(new pacem3D.maths.point3D(M,fb,N))}var l=a==0?this.sides-1:a-1,e=d==1?r+2*l+1:q+this.sides*(d-2)+l,f=d==1?r+2*a+1:q+this.sides*(d-2)+a,h=d==this.heightSegments?r+2*a:q+this.sides*(d-1)+a,k=d==this.heightSegments?r+2*l:q+this.sides*(d-1)+l,Q=1/this.sides,R=1/this.heightSegments,w=l*Q,x=(d-1)*R,o=a==0?1:a*Q,p=d*R,m={x:w,y:x},n={x:o,y:x},j={x:o,y:p},z={x:w,y:p};if(s){c.push([e,f,h,k]);b.push([m,n,j,j])}else{c.push(e);c.push(f);c.push(h);b.push(m);b.push(n);b.push(j);b.push(m);b.push(j);b.push(z)}}if(s)this.geometry=new pacem3D.engine.poly(g,c,b);else this.geometry=new pacem3D.engine.mesh(g,c,b)};pacem3D.primitives.cylinder.prototype=new pacem3D.engine.modelVisual3D;pacem3D.primitives.cylinder.prototype.constructor=pacem3D.primitives.cylinder;pacem3D.primitives.cylinder.prototype.toString=function(){return"pacem3D.primitives.cylinder"};pacem3D.primitives.torus=function(u,x,f,a,v){this.radius=u||1;this.innerRadius=x||.25;this.segments=f||24;this.sides=a||12;var r=v||false;if(typeof this.radius!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"radius","Number");if(typeof this.innerRadius!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"innerRadius","Number");if(typeof this.sides!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"sides","Number");if(typeof this.segments!="number")throw pacem3D._stringFormat(pacem3D._resources.ERR_INVALIDARGUMENTTYPE,"segments","Number");this.materials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,154,215,229))];this.backMaterials=[new pacem3D.engine.solidColorMaterial(new pacem3D.engine.color(.78,154,215,229))];for(var f=this.segments,a=this.sides,u=this.radius,y=this.innerRadius,r=v||false,z=pacem3D.maths._utils.degToRad(360/f),A=pacem3D.maths._utils.degToRad(360/a),w=u,n=y,m=[],d=[],e=[],c=0;c<f;c++)for(var s=z*c-Math.PI/2,q=Math.sin(s),o=Math.cos(s),b=0;b<a;b++){var t=A*b+Math.PI,p=Math.cos(t),B=w*o+n*p*o,C=n*Math.sin(t),D=w*q+n*p*q;m.push(new pacem3D.maths.point3D(B,C,D));var h=c>0?c-1:f-1,g=b>0?b-1:a-1,k=c==0?0:1-1*c/f,l=b>0?1*b/a:1,i=c>0?1-(c-1)/f:1/f,j=b>0?(b-1)/a:1-1/a;if(r){d.push([c*a+g,h*a+g,h*a+b,c*a+b]);e.push([{x:k,y:j},{x:i,y:j},{x:i,y:l},{x:k,y:l}])}else{d.push(c*a+g);d.push(h*a+g);d.push(h*a+b);d.push(c*a+g);d.push(h*a+b);d.push(c*a+b);e.push({x:k,y:j});e.push({x:i,y:j});e.push({x:i,y:l});e.push({x:k,y:j});e.push({x:i,y:l});e.push({x:k,y:l})}}if(r)this.geometry=new pacem3D.engine.poly(m,d,e);else this.geometry=new pacem3D.engine.mesh(m,d,e)};pacem3D.primitives.torus.prototype=new pacem3D.engine.modelVisual3D;pacem3D.primitives.torus.prototype.constructor=pacem3D.primitives.torus;pacem3D.primitives.torus.prototype.toString=function(){return"pacem3D.primitives.torus"}
