text: var e=require("cannon"),t=function(){var e,t,r,n,o,i,s,a,u,c,m,f,l,d,p,x,y,E,h,v=[],g=[],w=0;var T=function(){var e=new THREE.Vector3,t=new THREE.Vector3,r=new THREE.Vector3;return function(n,o,i){return e.subVectors(i,n),t.subVectors(o,n),r.crossVectors(e,t),r.normalize()}}();function V(e,t){if(void 0!==e.normal)return e.normal;var r=t[e[0]],n=t[e[2]];return m.subVectors(t[e[1]],r),f.subVectors(n,r),p.crossVectors(f,m),p.normalize(),e.normal=p.clone()}function b(e,t,r){var n=r[e[0]],o=[],i=V(e,r);t.sort(function(e,t){return o[e.x/3]=void 0!==o[e.x/3]?o[e.x/3]:i.dot(l.subVectors(e,n)),o[t.x/3]=void 0!==o[t.x/3]?o[t.x/3]:i.dot(d.subVectors(t,n)),o[e.x/3]-o[t.x/3]});var s=t.length;for(1===s&&(o[t[0].x/3]=i.dot(l.subVectors(t[0],n)));s-- >0&&o[t[s].x/3]>0;);s+1<t.length&&o[t[s+1].x/3]>0&&(e.visiblePoints=t.splice(s+1))}function R(e,t){for(var r,n=v.length,o=[e],i=t.indexOf(e.visiblePoints.pop());n-- >0;)(r=v[n])!==e&&V(r,t).dot(x.subVectors(t[i],t[r[0]]))>0&&o.push(r);var s,a,u,c,m=n=o.length,f=1===n,l=[],d=0,p=[];if(1===o.length)l=[(r=o[0])[0],r[1],r[1],r[2],r[2],r[0]],g.indexOf(r)>-1&&g.splice(g.indexOf(r),1),r.visiblePoints&&(p=p.concat(r.visiblePoints)),v.splice(v.indexOf(r),1);else for(;n-- >0;){var y;for(g.indexOf(r=o[n])>-1&&g.splice(g.indexOf(r),1),r.visiblePoints&&(p=p.concat(r.visiblePoints)),v.splice(v.indexOf(r),1),cEdgeIndex=0;cEdgeIndex<3;){for(y=!1,m=o.length,u=r[cEdgeIndex],c=r[(cEdgeIndex+1)%3];m-- >0&&!y;)if(d=0,(s=o[m])!==r)for(;d<3&&!y;)a=d+1,y=s[d]===u&&s[a%3]===c||s[d]===c&&s[a%3]===u,d++;y&&!f||(l.push(u),l.push(c)),cEdgeIndex++}}n=0;for(var E,h=l.length/2;n<h;)b(E=[l[2*n+1],i,l[2*n]],p,t),v.push(E),void 0!==E.visiblePoints&&g.push(E),n++}var H=function(){var e=new THREE.Vector3,t=new THREE.Vector3,r=new THREE.Vector3;return function(n,o,i){e.subVectors(o,n),t.subVectors(i,n),r.subVectors(i,o);var s=t.dot(e);if(s<0)return t.dot(t);var a=e.dot(e);return s>=a?r.dot(r):t.dot(t)-s*s/a}}();return function(V){for(m=new THREE.Vector3,f=new THREE.Vector3,new THREE.Vector3,l=new THREE.Vector3,d=new THREE.Vector3,p=new THREE.Vector3,x=new THREE.Vector3,y=new THREE.Vector3,E=new THREE.Vector3,h=new THREE.Vector3,points=V.vertices,v=[],g=[],M=e=points.length,t=points.slice(0,6),w=0;M-- >0;)points[M].x<t[0].x&&(t[0]=points[M]),points[M].x>t[1].x&&(t[1]=points[M]),points[M].y<t[2].y&&(t[2]=points[M]),points[M].y<t[3].y&&(t[3]=points[M]),points[M].z<t[4].z&&(t[4]=points[M]),points[M].z<t[5].z&&(t[5]=points[M]);for(n=M=6;M-- >0;)for(n=M-1;n-- >0;)w<(r=t[M].distanceToSquared(t[n]))&&(w=r,o=t[M],i=t[n]);for(M=6,w=0;M-- >0;)r=H(o,i,t[M]),w<r&&(w=r,s=t[M]);for(u=T(o,i,s),c=u.dot(o),w=0,M=e;M-- >0;)r=Math.abs(points[M].dot(u)-c),w<r&&(w=r,a=points[M]);var B=points.indexOf(o),z=points.indexOf(i),S=points.indexOf(s),O=points.indexOf(a),G=[[S,z,B],[z,O,B],[S,O,z],[B,O,S]];y.subVectors(i,o).normalize(),E.subVectors(s,o).normalize(),h.subVectors(a,o).normalize(),h.dot((new THREE.Vector3).crossVectors(E,y))<0&&(G[0].reverse(),G[1].reverse(),G[2].reverse(),G[3].reverse());var C=points.slice();C.splice(C.indexOf(o),1),C.splice(C.indexOf(i),1),C.splice(C.indexOf(s),1),C.splice(C.indexOf(a),1);for(var M=G.length;M-- >0;)b(G[M],C,points),void 0!==G[M].visiblePoints&&g.push(G[M]),v.push(G[M]);!function(e){for(;g.length>0;)R(g.shift(),e)}(points);for(var P=v.length;P-- >0;)V.faces[P]=new THREE.Face3(v[P][2],v[P][1],v[P][0],v[P].normal);return V.normalsNeedUpdate=!0,V}}(),r=Math.PI/2,n={BOX:"Box",CYLINDER:"Cylinder",SPHERE:"Sphere",HULL:"ConvexPolyhedron",MESH:"Trimesh"},o=function(o,c){var m;if((c=c||{}).type===n.BOX)return s(o);if(c.type===n.CYLINDER)return function(t,n){var o,i,s,a=new THREE.Box3,u=["x","y","z"],c=n.cylinderAxis||"y",m=u.splice(u.indexOf(c),1)&&u;if(a.setFromObject(t),!isFinite(a.min.lengthSq()))return null;return i=a.max[c]-a.min[c],s=.5*Math.max(a.max[m[0]]-a.min[m[0]],a.max[m[1]]-a.min[m[1]]),(o=new e.Cylinder(s,s,i,12))._type=e.Shape.types.CYLINDER,o.radiusTop=s,o.radiusBottom=s,o.height=i,o.numSegments=12,o.orientation=new e.Quaternion,o.orientation.setFromEuler("y"===c?r:0,"z"===c?r:0,0,"XYZ").normalize(),o}(o,c);if(c.type===n.SPHERE)return function(t,r){if(r.sphereRadius)return new e.Sphere(r.sphereRadius);var n=a(t);if(!n)return null;return n.computeBoundingSphere(),new e.Sphere(n.boundingSphere.radius)}(o,c);if(c.type===n.HULL)return function(r){var n,o,i,s,u=a(r);if(!u||!u.vertices.length)return null;for(n=0;n<u.vertices.length;n++)u.vertices[n].x+=1e-4*(Math.random()-.5),u.vertices[n].y+=1e-4*(Math.random()-.5),u.vertices[n].z+=1e-4*(Math.random()-.5);for(s=t(u),o=new Array(s.vertices.length),n=0;n<s.vertices.length;n++)o[n]=new e.Vec3(s.vertices[n].x,s.vertices[n].y,s.vertices[n].z);for(i=new Array(s.faces.length),n=0;n<s.faces.length;n++)i[n]=[s.faces[n].a,s.faces[n].b,s.faces[n].c];return new e.ConvexPolyhedron(o,i)}(o);if(c.type===n.MESH)return(m=a(o))?function(t){var r,n=u(t);if(!n.length)return null;return r=Object.keys(n).map(Number),new e.Trimesh(n,r)}(m):null;if(c.type)throw new Error('[CANNON.threeToCannon] Invalid type "%s".',c.type);if(!(m=a(o)))return null;switch(m.metadata?m.metadata.type:m.type){case"BoxGeometry":case"BoxBufferGeometry":return i(m);case"CylinderGeometry":case"CylinderBufferGeometry":return function(t){var r,n=t.metadata?t.metadata.parameters:t.parameters;return(r=new e.Cylinder(n.radiusTop,n.radiusBottom,n.height,n.radialSegments))._type=e.Shape.types.CYLINDER,r.radiusTop=n.radiusTop,r.radiusBottom=n.radiusBottom,r.height=n.height,r.numSegments=n.radialSegments,r.orientation=new e.Quaternion,r.orientation.setFromEuler(THREE.Math.degToRad(90),0,0,"XYZ").normalize(),r}(m);case"PlaneGeometry":case"PlaneBufferGeometry":return function(t){t.computeBoundingBox();var r=t.boundingBox;return new e.Box(new e.Vec3((r.max.x-r.min.x)/2||.1,(r.max.y-r.min.y)/2||.1,(r.max.z-r.min.z)/2||.1))}(m);case"SphereGeometry":case"SphereBufferGeometry":return function(t){return new e.Sphere((t.metadata?t.metadata.parameters:t.parameters).radius)}(m);case"TubeGeometry":case"Geometry":case"BufferGeometry":return s(o);default:return console.warn('Unrecognized geometry: "%s". Using bounding box as shape.',m.type),i(m)}};function i(t){if(!u(t).length)return null;t.computeBoundingBox();var r=t.boundingBox;return new e.Box(new e.Vec3((r.max.x-r.min.x)/2,(r.max.y-r.min.y)/2,(r.max.z-r.min.z)/2))}function s(t){var r,n,o=new THREE.Box3,i=t.clone();return i.quaternion.set(0,0,0,1),i.updateMatrixWorld(),o.setFromObject(i),isFinite(o.min.lengthSq())?(r=new e.Box(new e.Vec3((o.max.x-o.min.x)/2,(o.max.y-o.min.y)/2,(o.max.z-o.min.z)/2)),(n=o.translate(i.position.negate()).getCenter(new THREE.Vector3)).lengthSq()&&(r.offset=n),r):null}function a(e){var t,r,n=function(e){var t=[];return e.traverse(function(e){"Mesh"===e.type&&t.push(e)}),t}(e),o=new THREE.Geometry,i=new THREE.Geometry;if(0===n.length)return null;if(1===n.length){var s=new THREE.Vector3,a=new THREE.Quaternion,u=new THREE.Vector3;return n[0].geometry.isBufferGeometry?n[0].geometry.attributes.position&&n[0].geometry.attributes.position.itemSize>2&&o.fromBufferGeometry(n[0].geometry):o=n[0].geometry.clone(),o.metadata=n[0].geometry.metadata,n[0].updateMatrixWorld(),n[0].matrixWorld.decompose(s,a,u),o.scale(u.x,u.y,u.z)}for(;r=n.pop();)if(r.updateMatrixWorld(),r.geometry.isBufferGeometry){if(r.geometry.attributes.position&&r.geometry.attributes.position.itemSize>2){var c=new THREE.Geometry;c.fromBufferGeometry(r.geometry),i.merge(c,r.matrixWorld),c.dispose()}}else i.merge(r.geometry,r.matrixWorld);return(t=new THREE.Matrix4).scale(e.scale),i.applyMatrix(t),i}function u(e){return e.attributes||(e=(new THREE.BufferGeometry).fromGeometry(e)),(e.attributes.position||{}).array||[]}o.Type=n,exports.threeToCannon=o;
  //# sourceMappingURL=three-pathfinding.js.map
  