!function t(e,i,o){function n(r,a){if(!i[r]){if(!e[r]){var h="function"==typeof require&&require;if(!a&&h)return h(r,!0);if(s)return s(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var l=i[r]={exports:{}};e[r][0].call(l.exports,function(t){var i=e[r][1][t];return n(i?i:t)},l,l.exports,t,e,i,o)}return i[r].exports}for(var s="function"==typeof require&&require,r=0;r=7e3}return!1},parse:function(t){var e=this;console.time("FBXLoader"),console.time("FBXLoader: TextParser");var r=(new i).parse(t);console.timeEnd("FBXLoader: TextParser"),console.time("FBXLoader: ObjectParser"),e.hierarchy=(new n).parseHierarchy(r),e.weights=(new o).parse(r,e.hierarchy),e.animations=(new p).parse(r,e.hierarchy),e.textures=(new d).parse(r,e.hierarchy),e.materials=(new v).parse(r,e.hierarchy),e.geometries=(new s).parse(r,e.hierarchy),console.timeEnd("FBXLoader: ObjectParser"),this.texture_cache={},this.material_cache={},this.geometry_cache={},console.time("FBXLoader: MeshParser");var a=this.parseMeshes(r);console.timeEnd("FBXLoader: MeshParser");for(var h=new THREE.Group,c=0;c0&&e.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(t.normals),3)),void 0!==t.uvs&&t.uvs.length>0&&e.addAttribute("uv",new THREE.BufferAttribute(new Float32Array(t.uvs),2)),void 0!==t.indices&&t.indices.length>0&&(t.indices.length>65535?e.setIndex(new THREE.BufferAttribute(new Uint32Array(t.indices),1)):e.setIndex(new THREE.BufferAttribute(new Uint16Array(t.indices),1))),e.verticesNeedUpdate=!0,e.computeBoundingSphere(),e.computeBoundingBox(),t.materialIndices.length>1){e.groups=[];for(var i=0,o=-1;i1?new THREE.MultiMaterial(h):h[0],void 0!==i.bones&&void 0!==i.skinWeights){if(o instanceof THREE.MultiMaterial)for(var c=0;c0?(this.__cache_search_connection_parent[t]=this.__cache_search_connection_parent[t].concat(i),i):(this.__cache_search_connection_parent[t]=[-1],[-1])},searchConnectionChildren:function(t){if(void 0===this.__cache_search_connection_children&&(this.__cache_search_connection_children=[]),void 0!==this.__cache_search_connection_children[t])return this.__cache_search_connection_children[t];this.__cache_search_connection_children[t]=[];for(var e=this.Connections.properties.connections,i=[],o=0;o0?(this.__cache_search_connection_children[t]=this.__cache_search_connection_children[t].concat(i),i):(this.__cache_search_connection_children[t]=[],[])},searchConnectionType:function(t,e){var i=t+","+e;if(void 0===this.__cache_search_connection_type&&(this.__cache_search_connection_type={}),void 0!==this.__cache_search_connection_type[i])return this.__cache_search_connection_type[i];this.__cache_search_connection_type[i]="";for(var o=this.Connections.properties.connections,n=0;n1&&(i=t[1].replace(/^(\w+)::/,""),o=t[2]),{id:e,name:i||"",type:o||""}},parseNodeProperty:function(t,e,i){var o=this.getCurrentNode(),n=o.name;if(void 0!==n){var s=n.match(/Properties(\d)+/);if(s)return void this.parseNodeSpecialProperty(t,e,i)}if("C"==e){var r=i.split(",").slice(1),a=parseInt(r[0]),h=parseInt(r[1]),c=i.split(",").slice(3);e="connections",i=[a,h],i=i.concat(c),void 0===o.properties[e]&&(o.properties[e]=[])}if("Node"==e){var l=parseInt(i);o.properties.id=l,o.id=l}e in o.properties?Array.isArray(o.properties[e])?o.properties[e].push(i):o.properties[e]+=i:Array.isArray(o.properties[e])?o.properties[e].push(i):o.properties[e]=i,this.setCurrentProp(o.properties,e)},parseNodePropertyContinued:function(t){this.currentProp[this.currentPropName]+=t},parseNodeSpecialProperty:function(t,e,i){var o=i.split('",').map(function(t){return t.trim().replace(/^\"/,"").replace(/\s/,"_")}),n=o[0],s=o[1],r=o[2],a=o[3],h=o[4];switch(s){case"int":h=parseInt(h);break;case"double":h=parseFloat(h);break;case"ColorRGB":case"Vector3D":var c=h.split(",");h=new THREE.Vector3(c[0],c[1],c[2])}this.getPrevNode().properties[n]={type:s,type2:r,flag:a,value:h},this.setCurrentProp(this.getPrevNode().properties,n)},nodeEnd:function(){this.popStack()},isFlattenNode:function(t){return"subNodes"in t&&"properties"in t}}),o.prototype.parseCluster=function(t,e,i){var o=t.searchConnectionParent(e),n=A(i.subNodes.Indexes.properties.a),s=C(i.subNodes.Weights.properties.a),r=T(i.subNodes.Transform.properties.a),a=T(i.subNodes.TransformLink.properties.a);return{parent:o,id:parseInt(e),indices:n,weights:s,transform:r,transformlink:a,linkMode:i.properties.Mode}},o.prototype.parse=function(t,e){this.skinIndices=[],this.skinWeights=[],this.matrices=[];var i=t.Objects.subNodes.Deformer,o={};for(var n in i)if("Cluster"===i[n].attrType){if(!("Indexes"in i[n].subNodes))continue;var s=this.parseCluster(t,n,i[n]),r=t.searchConnectionChildren(s.id)[0];o[r]=s}for(var a=[],h=e.hierarchy,c=0;c1&&console.warn("FBXLoader: node "+u.id+" have many weight kids: "+d),a[u.indices[p]].joint.push(e.getBoneIdfromInternalId(t,d[0])),a[u.indices[p]].weight.push(u.weights[p])}}else this.matrices.push(new THREE.Matrix4)}for(var y=0;y3){var e=this.convertPolyIndicesToTri(this.indices,this.materialIndices,this.getPolygonTopologyArray());this.indices=e.res,this.materialIndices=e.materialIndices,this.polyIndices=e.polyIndices}return this},r.prototype.getVertices=function(){if(this.node.__cache_vertices)return this.node.__cache_vertices;if(void 0===this.node.subNodes.Vertices)return console.warn("this.node: "+this.node.attrName+"("+this.node.id+") does not have Vertices"),this.node.__cache_vertices=void 0,null;var t=this.node.subNodes.Vertices.properties.a,e=t.split(",").map(function(t){return parseFloat(t)});return this.node.__cache_vertices=e,this.node.__cache_vertices},r.prototype.getPolygonVertexIndices=function(){if(this.node.__cache_indices&&this.node.__cache_poly_topology_max)return this.node.__cache_indices;if(void 0===this.node.subNodes)return console.error("this.node.subNodes undefined"),void console.log(this.node);if(void 0===this.node.subNodes.PolygonVertexIndex)return console.warn("this.node: "+this.node.attrName+"("+this.node.id+") does not have PolygonVertexIndex "),void(this.node.__cache_indices=void 0);for(var t=this.node.subNodes.PolygonVertexIndex.properties.a,e=t.split(","),i=1,o=null,n=[],s=0;so&&(o=i),e[s]=r^-1,n.push(i),i=1):(e[s]=r,i++)}return null===o&&(console.warn("FBXLoader: topology N not found: "+this.node.attrName),console.warn(this.node),o=3),this.node.__cache_poly_topology_max=o,this.node.__cache_poly_topology_arr=n,this.node.__cache_indices=e,this.node.__cache_indices},r.prototype.getPolygonTopologyMax=function(){return this.node.__cache_indices&&this.node.__cache_poly_topology_max?this.node.__cache_poly_topology_max:(this.getPolygonVertexIndices(this.node),this.node.__cache_poly_topology_max)},r.prototype.getPolygonTopologyArray=function(){return this.node.__cache_indices&&this.node.__cache_poly_topology_max?this.node.__cache_poly_topology_arr:(this.getPolygonVertexIndices(this.node),this.node.__cache_poly_topology_arr)},r.prototype.convertPolyIndicesToTri=function(t,e,i){for(var o=[],n=0,s=0,r=0,a=[];n1)for(var n=0;n0&&(console.warn("multi uv not supported"),e=e[o]);var n=e.subNodes.UVIndex.properties.a,s=e.subNodes.UV.properties.a,r=e.properties.MappingInformationType,a=e.properties.ReferenceInformationType;return this.uv=C(s),this.index=A(n),this.map=r,this.ref=a,this.uv},a.prototype.parse=function(t,e){if("LayerElementUV"in t.subNodes){this.uvNode=this.getNode(t),this.uv=this.getUV(t);var i=this.getMap(t),o=this.getRef(t),n=this.getIndex(t),s=e.getPolygonTopologyArray();switch(i){case"ByPolygonVertex":switch(o){case"Direct":this.uv=this.parseUV_ByPolygonVertex_Direct(this.uv,n,s,2);break;case"IndexToDirect":this.uv=this.parseUV_ByPolygonVertex_IndexToDirect(this.uv,n)}this.uv=w(this.uv,e.getPolygonVertexIndices(t),2);break;case"ByPolygon":switch(o){case"Direct":this.uv=this.parseUV_ByPolygon_Direct();break;case"IndexToDirect":this.uv=this.parseUV_ByPolygon_IndexToDirect()}}return this.uv}},a.prototype.parseUV_ByPolygonVertex_Direct=function(t,e,i,o){return g(t,e,i,o)},a.prototype.parseUV_ByPolygonVertex_IndexToDirect=function(t,e){return f(t,e,2)},a.prototype.parseUV_ByPolygon_Direct=function(t){return console.warn("not implemented"),t},a.prototype.parseUV_ByPolygon_IndexToDirect=function(t){return console.warn("not implemented"),t},a.prototype.parseUV_ByVertex_Direct=function(t){return console.warn("not implemented"),t},h.prototype.getNormal=function(t){return this.node&&this.normal&&this.map&&this.ref?this.normal:(this._parseText(t),this.normal)},h.prototype.getMap=function(t){return this.node&&this.normal&&this.map&&this.ref?this.map:(this._parseText(t),this.map)},h.prototype.getRef=function(t){return this.node&&this.normal&&this.map&&this.ref?this.ref:(this._parseText(t),this.ref)},h.prototype.getNode=function(t){return this.node?this.node:(this.node=t.subNodes.LayerElementNormal,this.node)},h.prototype._parseText=function(t){var e=this.getNode(t)[0];if(void 0===e)return void console.warn("node: "+t.attrName+"("+t.id+") does not have LayerElementNormal");var i=e.properties.MappingInformationType,o=e.properties.ReferenceInformationType,n=e.subNodes.Normals.properties.a;this.normal=C(n),this.map=i,this.ref=o},h.prototype.parse=function(t,e){var i=this.getNormal(t),o=this.getMap(t),n=this.getRef(t),s=e.getPolygonVertexIndices(t),r=e.getPolygonTopologyArray(t);switch(o){case"ByPolygonVertex":switch(n){case"Direct":i=this.parseNormal_ByPolygonVertex_Direct(i,s,r,3);break;case"IndexToDirect":i=this.parseNormal_ByPolygonVertex_IndexToDirect()}break;case"ByPolygon":switch(n){case"Direct":i=this.parseNormal_ByPolygon_Direct();break;case"IndexToDirect":i=this.parseNormal_ByPolygon_IndexToDirect()}}return i},h.prototype.parseNormal_ByPolygonVertex_Direct=function(t,e,i,o){return g(t,e,i,o)},h.prototype.parseNormal_ByPolygonVertex_IndexToDirect=function(t){return console.warn("not implemented"),t},h.prototype.parseNormal_ByPolygon_Direct=function(t){return console.warn("not implemented"),t},h.prototype.parseNormal_ByPolygon_IndexToDirect=function(t){return console.warn("not implemented"),t},h.prototype.parseNormal_ByVertex_Direct=function(t){return console.warn("not implemented"),t},Object.assign(c.prototype,{parse:function(t){if("LayerElementMaterial"in t.subNodes){var e=t.subNodes.LayerElementMaterial[0],i=e.properties.MappingInformationType,o=e.properties.ReferenceInformationType,n=A(e.subNodes.Materials.properties.a);switch(i){case"ByPolygon":switch(o){case"IndexToDirect":this.indexBuffer=this.parse_ByPolygon_IndexToDirect(n);break;default:this.indexBuffer=[0]}break;default:this.indexBuffer=[0]}return this.indexBuffer}},parse_ByPolygon_IndexToDirect:function(t){return t}}),l.prototype.fromNode=function(t){return this.id=t.id,this.internalId=t.id,this.times=t.subNodes.KeyTime.properties.a,this.values=t.subNodes.KeyValueFloat.properties.a,this.attrFlag=t.subNodes.KeyAttrFlags.properties.a,this.attrData=t.subNodes.KeyAttrDataFloat.properties.a,this.times=C(this.times),this.values=C(this.values),this.attrData=C(this.attrData),this.attrFlag=A(this.attrFlag),this.times=this.times.map(function(t){return b(t)}),this},l.prototype.getLength=function(){return this.times[this.times.length-1]},u.prototype.fromNode=function(t,e,i){if(this.id=e.id,this.attr=e.attrName,this.internalId=e.id,!this.attr.match(/S|R|T/))return null;for(var o in e.properties)o.match(/X/)&&(this.attrX=!0),o.match(/Y/)&&(this.attrY=!0),o.match(/Z/)&&(this.attrZ=!0);this.containerIndices=t.searchConnectionParent(this.id),this.curveIdx=t.searchConnectionChildren(this.id);for(var n=this.containerIndices.length-1;n>=0;--n){var s=i.searchRealId(this.containerIndices[n]);if(s>=0&&(this.containerBoneId=s,this.containerId=this.containerIndices[n]),s>=0)break}return this},u.prototype.setCurve=function(t){this.curves.push(t)},p.prototype.parse=function(t,e){function i(t){function e(t){t.x&&(A=t.x.getLength()>A?t.x.getLength():A,C=t.x.times[0]A?t.y.getLength():A,C=t.y.times[0]A?t.z.getLength():A,C=t.z.times[0]C&&(this.stacks[h]={name:r[h].attrName,layers:E,length:A-C,frames:30*(A-C)})}return this},d.prototype.add=function(t){void 0===this.textures&&(this.textures=[]),this.textures.push(t);for(var e=0;e0?e[e.length-1]:t},y.prototype.searchParents=function(t,e){var i=e.searchConnectionParent(t);return i},Object.assign(v.prototype,{parse:function(t){var e=t.Objects.subNodes.Material;for(var i in e){var o=(new m).parse(e[i],t);this.materials[i]=o}return this}}),Object.assign(m.prototype,{parse:function(t,e){return this.id=t.id,this.name=t.attrName,this.type=t.properties.ShadingModel,this.parameters=this.parseParameters(t.properties),this.parentIds=this.searchParents(this.id,e),this},parseParameters:function(t){var e={};return t.Diffuse&&(e.color=(new THREE.Color).fromArray([parseFloat(t.Diffuse.value.x),parseFloat(t.Diffuse.value.y),parseFloat(t.Diffuse.value.z)])),t.Specular&&(e.specular=(new THREE.Color).fromArray([parseFloat(t.Specular.value.x),parseFloat(t.Specular.value.y),parseFloat(t.Specular.value.z)])),t.Shininess&&(e.shininess=t.Shininess.value),t.Emissive&&(e.emissive=(new THREE.Color).fromArray([parseFloat(t.Emissive.value.x),parseFloat(t.Emissive.value.y),parseFloat(t.Emissive.value.z)])),t.EmissiveFactor&&(e.emissiveIntensity=t.EmissiveFactor.value),t.Reflectivity&&(e.reflectivity=t.Reflectivity.value),t.Opacity&&(e.opacity=t.Opacity.value),e.opacity<1&&(e.transparent=!0),e},searchParents:function(t,e){return e.searchConnectionParent(t)}})}()},{}],4:[function(t,e,i){e.exports=Object.assign(function(){},{FACE_1:0,FACE_2:1,FACE_3:2,FACE_4:3,L_SHOULDER_1:4,R_SHOULDER_1:5,L_SHOULDER_2:6,R_SHOULDER_2:7,SELECT:8,START:9,DPAD_UP:12,DPAD_DOWN:13,DPAD_LEFT:14,DPAD_RIGHT:15,VENDOR:16})},{}],5:[function(t,e,i){function o(t,e,i){this.type=t,this.index=e,this.pressed=i.pressed,this.value=i.value}e.exports=o},{}],6:[function(t,e,i){e.exports=THREE.PLYLoader=function(t){this.manager=void 0!==t?t:THREE.DefaultLoadingManager,this.propertyNameMapping={}},THREE.PLYLoader.prototype={constructor:THREE.PLYLoader,load:function(t,e,i,o){var n=this,s=new THREE.XHRLoader(this.manager);s.setResponseType("arraybuffer"),s.load(t,function(t){ e(n.parse(t))},i,o)},setPropertyNameMapping:function(t){this.propertyNameMapping=t},bin2str:function(t){for(var e=new Uint8Array(t),i="",o=0;o=o.elements[a].count&&(a++,h=0);var u=this.parseASCIIElement(o.elements[a].properties,l);this.handleElement(i,o.elements[a].name,u),h++}}return this.postProcess(i)},postProcess:function(t){if(t.useColor){for(var e=0;e"},Slash:{key:"/",shiftKey:"?"},Backquote:{key:"`",shiftKey:"~"},BracketLeft:{key:"[",shiftKey:"{"},Backslash:{key:"\\",shiftKey:"|"},BracketRight:{key:"]",shiftKey:"}"},Quote:{key:"'",shiftKey:'"'},IntlBackslash:{key:"\\",shiftKey:"|"}};i(f,"mac",{OSLeft:{key:"Meta"},OSRight:{key:"Meta"}});var g={Esc:"Escape",Nonconvert:"NonConvert",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Menu:"ContextMenu",MediaNextTrack:"MediaTrackNext",MediaPreviousTrack:"MediaTrackPrevious",SelectMedia:"MediaSelect",HalfWidth:"Hankaku",FullWidth:"Zenkaku",RomanCharacters:"Romaji",Crsel:"CrSel",Exsel:"ExSel",Zoom:"ZoomToggle"},w=o(y,"code");try{var b=r&&"location"in new KeyboardEvent("")}catch(x){}"KeyboardEvent"in t&&"defineProperty"in Object&&!function(){function t(t,e,i){e in t||Object.defineProperty(t,e,i)}if(t(KeyboardEvent.prototype,"code",{get:function(){var t=n(this);return t?t.code:""}}),"key"in KeyboardEvent.prototype){var e=Object.getOwnPropertyDescriptor(KeyboardEvent.prototype,"key");Object.defineProperty(KeyboardEvent.prototype,"key",{get:function(){var t=e.get.call(this);return g.hasOwnProperty(t)?g[t]:t}})}t(KeyboardEvent.prototype,"key",{get:function(){var t=n(this);return t&&"key"in t?t.key:"Unidentified"}}),t(KeyboardEvent.prototype,"location",{get:function(){var t=n(this);return t&&"location"in t?t.location:a}}),t(KeyboardEvent.prototype,"locale",{get:function(){return""}})}(),"queryKeyCap"in t.KeyboardEvent||(t.KeyboardEvent.queryKeyCap=s),t.identifyKey=function(t){if(!("code"in t)){var e=n(t);t.code=e?e.code:"",t.key=e&&"key"in e?e.key:"Unidentified",t.location="location"in t?t.location:"keyLocation"in t?t.keyLocation:e&&"location"in e?e.location:a,t.locale=""}}}(window)},{}],8:[function(t,e,i){var o=t("cannon"),n=t("./src/components/math");e.exports={"dynamic-body":t("./src/components/body/dynamic-body"),"static-body":t("./src/components/body/static-body"),constraint:t("./src/components/constraint"),system:t("./src/system/physics"),registerAll:function(t){this._registered||(t=t||window.AFRAME,n.registerAll(),t.systems.physics||t.registerSystem("physics",this.system),t.components["dynamic-body"]||t.registerComponent("dynamic-body",this["dynamic-body"]),t.components["static-body"]||t.registerComponent("static-body",this["static-body"]),t.components.constraint||t.registerComponent("constraint",this.constraint),this._registered=!0)}},window.CANNON=window.CANNON||o},{"./src/components/body/dynamic-body":11,"./src/components/body/static-body":12,"./src/components/constraint":13,"./src/components/math":14,"./src/system/physics":18,cannon:20}],9:[function(t,e,i){var o=t("cannon");o.shape2mesh=function(t){for(var e=new THREE.Object3D,i=0;i\n```\n\n### Node.js install\n\nInstall the cannon package via NPM:\n\n```bash\nnpm install --save cannon\n```\n\nAlternatively, point to the Github repo directly to get the very latest version:\n\n```bash\nnpm install --save schteppe/cannon.js\n```\n\n### Example\n\nThe sample code below creates a sphere on a plane, steps the simulation, and prints the sphere simulation to the console. Note that Cannon.js uses [SI units](http://en.wikipedia.org/wiki/International_System_of_Units) (metre, kilogram, second, etc.).\n\n```javascript\n// Setup our world\nvar world = new CANNON.World();\nworld.gravity.set(0, 0, -9.82); // m/s²\n\n// Create a sphere\nvar radius = 1; // m\nvar sphereBody = new CANNON.Body({\n mass: 5, // kg\n position: new CANNON.Vec3(0, 0, 10), // m\n shape: new CANNON.Sphere(radius)\n});\nworld.addBody(sphereBody);\n\n// Create a plane\nvar groundBody = new CANNON.Body({\n mass: 0 // mass == 0 makes the body static\n});\nvar groundShape = new CANNON.Plane();\ngroundBody.addShape(groundShape);\nworld.addBody(groundBody);\n\nvar fixedTimeStep = 1.0 / 60.0; // seconds\nvar maxSubSteps = 3;\n\n// Start the simulation loop\nvar lastTime;\n(function simloop(time){\n requestAnimationFrame(simloop);\n if(lastTime !== undefined){\n var dt = (time - lastTime) / 1000;\n world.step(fixedTimeStep, dt, maxSubSteps);\n }\n console.log("Sphere z position: " + sphereBody.position.z);\n lastTime = time;\n})();\n```\n\nIf you want to know how to use cannon.js with a rendering engine, for example Three.js, see the [Examples](examples).\n\n### Features\n* Rigid body dynamics\n* Discrete collision detection\n* Contacts, friction and restitution\n* Constraints\n * PointToPoint (a.k.a. ball/socket joint)\n * Distance\n * Hinge (with optional motor)\n * Lock\n * ConeTwist\n* Gauss-Seidel constraint solver and an island split algorithm\n* Collision filters\n* Body sleeping\n* Experimental SPH / fluid support\n* Various shapes and collision algorithms (see table below)\n\n| | [Sphere](http://schteppe.github.io/cannon.js/docs/classes/Sphere.html) | [Plane](http://schteppe.github.io/cannon.js/docs/classes/Plane.html) | [Box](http://schteppe.github.io/cannon.js/docs/classes/Box.html) | [Convex](http://schteppe.github.io/cannon.js/docs/classes/ConvexPolyhedron.html) | [Particle](http://schteppe.github.io/cannon.js/docs/classes/Particle.html) | [Heightfield](http://schteppe.github.io/cannon.js/docs/classes/Heightfield.html) | [Trimesh](http://schteppe.github.io/cannon.js/docs/classes/Trimesh.html) |\n| :-----------|:------:|:-----:|:---:|:------:|:--------:|:-----------:|:-------:|\n| Sphere | Yes | Yes | Yes | Yes | Yes | Yes | Yes |\n| Plane | - | - | Yes | Yes | Yes | - | Yes |\n| Box | - | - | Yes | Yes | Yes | Yes | (todo) |\n| Cylinder | - | - | Yes | Yes | Yes | Yes | (todo) |\n| Convex | - | - | - | Yes | Yes | Yes | (todo) |\n| Particle | - | - | - | - | - | (todo) | (todo) |\n| Heightfield | - | - | - | - | - | - | (todo) |\n| Trimesh | - | - | - | - | - | - | - |\n\n### Todo\nThe simpler todos are marked with ```@todo``` in the code. Github Issues can and should also be used for todos.\n\n### Help\nCreate an [issue](https://github.com/schteppe/cannon.js/issues) if you need help.\n', readmeFilename:"README.markdown",repository:{type:"git",url:"git+https://github.com/schteppe/cannon.js.git"},version:"0.6.2"}},{}],20:[function(t,e,i){e.exports={version:t("../package.json").version,AABB:t("./collision/AABB"),ArrayCollisionMatrix:t("./collision/ArrayCollisionMatrix"),Body:t("./objects/Body"),Box:t("./shapes/Box"),Broadphase:t("./collision/Broadphase"),Constraint:t("./constraints/Constraint"),ContactEquation:t("./equations/ContactEquation"),Narrowphase:t("./world/Narrowphase"),ConeTwistConstraint:t("./constraints/ConeTwistConstraint"),ContactMaterial:t("./material/ContactMaterial"),ConvexPolyhedron:t("./shapes/ConvexPolyhedron"),Cylinder:t("./shapes/Cylinder"),DistanceConstraint:t("./constraints/DistanceConstraint"),Equation:t("./equations/Equation"),EventTarget:t("./utils/EventTarget"),FrictionEquation:t("./equations/FrictionEquation"),GSSolver:t("./solver/GSSolver"),GridBroadphase:t("./collision/GridBroadphase"),Heightfield:t("./shapes/Heightfield"),HingeConstraint:t("./constraints/HingeConstraint"),LockConstraint:t("./constraints/LockConstraint"),Mat3:t("./math/Mat3"),Material:t("./material/Material"),NaiveBroadphase:t("./collision/NaiveBroadphase"),ObjectCollisionMatrix:t("./collision/ObjectCollisionMatrix"),Pool:t("./utils/Pool"),Particle:t("./shapes/Particle"),Plane:t("./shapes/Plane"),PointToPointConstraint:t("./constraints/PointToPointConstraint"),Quaternion:t("./math/Quaternion"),Ray:t("./collision/Ray"),RaycastVehicle:t("./objects/RaycastVehicle"),RaycastResult:t("./collision/RaycastResult"),RigidVehicle:t("./objects/RigidVehicle"),RotationalEquation:t("./equations/RotationalEquation"),RotationalMotorEquation:t("./equations/RotationalMotorEquation"),SAPBroadphase:t("./collision/SAPBroadphase"),SPHSystem:t("./objects/SPHSystem"),Shape:t("./shapes/Shape"),Solver:t("./solver/Solver"),Sphere:t("./shapes/Sphere"),SplitSolver:t("./solver/SplitSolver"),Spring:t("./objects/Spring"),Transform:t("./math/Transform"),Trimesh:t("./shapes/Trimesh"),Vec3:t("./math/Vec3"),Vec3Pool:t("./utils/Vec3Pool"),World:t("./world/World")}},{"../package.json":19,"./collision/AABB":21,"./collision/ArrayCollisionMatrix":22,"./collision/Broadphase":23,"./collision/GridBroadphase":24,"./collision/NaiveBroadphase":25,"./collision/ObjectCollisionMatrix":26,"./collision/Ray":28,"./collision/RaycastResult":29,"./collision/SAPBroadphase":30,"./constraints/ConeTwistConstraint":31,"./constraints/Constraint":32,"./constraints/DistanceConstraint":33,"./constraints/HingeConstraint":34,"./constraints/LockConstraint":35,"./constraints/PointToPointConstraint":36,"./equations/ContactEquation":38,"./equations/Equation":39,"./equations/FrictionEquation":40,"./equations/RotationalEquation":41,"./equations/RotationalMotorEquation":42,"./material/ContactMaterial":43,"./material/Material":44,"./math/Mat3":46,"./math/Quaternion":47,"./math/Transform":48,"./math/Vec3":49,"./objects/Body":50,"./objects/RaycastVehicle":51,"./objects/RigidVehicle":52,"./objects/SPHSystem":53,"./objects/Spring":54,"./shapes/Box":56,"./shapes/ConvexPolyhedron":57,"./shapes/Cylinder":58,"./shapes/Heightfield":59,"./shapes/Particle":60,"./shapes/Plane":61,"./shapes/Shape":62,"./shapes/Sphere":63,"./shapes/Trimesh":64,"./solver/GSSolver":65,"./solver/Solver":66,"./solver/SplitSolver":67,"./utils/EventTarget":68,"./utils/Pool":70,"./utils/Vec3Pool":73,"./world/Narrowphase":74,"./world/World":75}],21:[function(t,e,i){function o(t){t=t||{},this.lowerBound=new n,t.lowerBound&&this.lowerBound.copy(t.lowerBound),this.upperBound=new n,t.upperBound&&this.upperBound.copy(t.upperBound)}var n=t("../math/Vec3");t("../utils/Utils");e.exports=o;var s=new n;o.prototype.setFromPoints=function(t,e,i,o){var n=this.lowerBound,r=this.upperBound,a=i;n.copy(t[0]),a&&a.vmult(n,n),r.copy(n);for(var h=1;hr.x&&(r.x=c.x),c.xr.y&&(r.y=c.y),c.yr.z&&(r.z=c.z),c.z=n.x&&e.y<=o.y&&i.y>=n.y&&e.z<=o.z&&i.z>=n.z},o.prototype.getCorners=function(t,e,i,o,n,s,r,a){var h=this.lowerBound,c=this.upperBound;t.copy(h),e.set(c.x,h.y,h.z),i.set(c.x,c.y,h.z),o.set(h.x,c.y,c.z),n.set(c.x,h.y,h.z),s.set(h.x,c.y,h.z),r.set(h.x,h.y,c.z),a.copy(c)};var r=[new n,new n,new n,new n,new n,new n,new n,new n];o.prototype.toLocalFrame=function(t,e){var i=r,o=i[0],n=i[1],s=i[2],a=i[3],h=i[4],c=i[5],l=i[6],u=i[7];this.getCorners(o,n,s,a,h,c,l,u);for(var p=0;8!==p;p++){var d=i[p];t.pointToLocal(d,d)}return e.setFromPoints(i)},o.prototype.toWorldFrame=function(t,e){var i=r,o=i[0],n=i[1],s=i[2],a=i[3],h=i[4],c=i[5],l=i[6],u=i[7];this.getCorners(o,n,s,a,h,c,l,u);for(var p=0;8!==p;p++){var d=i[p];t.pointToWorld(d,d)}return e.setFromPoints(i)},o.prototype.overlapsRay=function(t){var e=1/t._direction.x,i=1/t._direction.y,o=1/t._direction.z,n=(this.lowerBound.x-t.from.x)*e,s=(this.upperBound.x-t.from.x)*e,r=(this.lowerBound.y-t.from.y)*i,a=(this.upperBound.y-t.from.y)*i,h=(this.lowerBound.z-t.from.z)*o,c=(this.upperBound.z-t.from.z)*o,l=Math.max(Math.max(Math.min(n,s),Math.min(r,a)),Math.min(h,c)),u=Math.min(Math.min(Math.max(n,s),Math.max(r,a)),Math.max(h,c));return!(u<0)&&!(l>u)}},{"../math/Vec3":49,"../utils/Utils":72}],22:[function(t,e,i){function o(){this.matrix=[]}e.exports=o,o.prototype.get=function(t,e){if(t=t.index,e=e.index,e>t){var i=e;e=t,t=i}return this.matrix[(t*(t+1)>>1)+e-1]},o.prototype.set=function(t,e,i){if(t=t.index,e=e.index,e>t){var o=e;e=t,t=o}this.matrix[(t*(t+1)>>1)+e-1]=i?1:0},o.prototype.reset=function(){for(var t=0,e=this.matrix.length;t!==e;t++)this.matrix[t]=0},o.prototype.setNumObjects=function(t){this.matrix.length=t*(t-1)>>1}},{}],23:[function(t,e,i){function o(){this.world=null,this.useBoundingBoxes=!1,this.dirty=!0}var n=t("../objects/Body"),s=t("../math/Vec3"),r=t("../math/Quaternion");t("../shapes/Shape"),t("../shapes/Plane");e.exports=o,o.prototype.collisionPairs=function(t,e,i){throw new Error("collisionPairs not implemented for this BroadPhase class!")},o.prototype.needBroadphaseCollision=function(t,e){return 0!==(t.collisionFilterGroup&e.collisionFilterMask)&&0!==(e.collisionFilterGroup&t.collisionFilterMask)&&(0===(t.type&n.STATIC)&&t.sleepState!==n.SLEEPING||0===(e.type&n.STATIC)&&e.sleepState!==n.SLEEPING)},o.prototype.intersectionTest=function(t,e,i,o){this.useBoundingBoxes?this.doBoundingBoxBroadphase(t,e,i,o):this.doBoundingSphereBroadphase(t,e,i,o)};var a=new s;new s,new r,new s;o.prototype.doBoundingSphereBroadphase=function(t,e,i,o){var n=a;e.position.vsub(t.position,n);var s=Math.pow(t.boundingRadius+e.boundingRadius,2),r=n.norm2();ri.norm2()},o.prototype.aabbQuery=function(t,e,i){return console.warn(".aabbQuery is not implemented in this Broadphase subclass."),[]}},{"../math/Quaternion":47,"../math/Vec3":49,"../objects/Body":50,"../shapes/Plane":61,"../shapes/Shape":62}],24:[function(t,e,i){function o(t,e,i,o,r){n.apply(this),this.nx=i||10,this.ny=o||10,this.nz=r||10,this.aabbMin=t||new s(100,100,100),this.aabbMax=e||new s((-100),(-100),(-100));var a=this.nx*this.ny*this.nz;if(a<=0)throw"GridBroadphase: Each dimension's n must be >0";this.bins=[],this.binLengths=[],this.bins.length=a,this.binLengths.length=a;for(var h=0;h=l&&(a=l-1),h<0?h=0:h>=u&&(h=u-1),c<0?c=0:c>=p&&(c=p-1),m<0?m=0:m>=l&&(m=l-1),f<0?f=0:f>=u&&(f=u-1),g<0?g=0:g>=p&&(g=p-1),a*=d,h*=y,c*=v,m*=d,f*=y,g*=v;for(var B=a;B<=m;B+=d)for(var T=h;T<=f;T+=y)for(var R=c;R<=g;R+=v){var S=B+T+R;N[S][L[S]++]=r}}for(var n=t.numObjects(),s=t.bodies,h=this.aabbMax,c=this.aabbMin,l=this.nx,u=this.ny,p=this.nz,d=u*p,y=p,v=1,m=h.x,f=h.y,g=h.z,w=c.x,b=c.y,x=c.z,E=l/(m-w),A=u/(f-b),C=p/(g-x),B=(m-w)/l,T=(f-b)/u,R=(g-x)/p,S=.5*Math.sqrt(B*B+T*T+R*R),M=r.types,k=M.SPHERE,P=M.PLANE,N=(M.BOX,M.COMPOUND,M.CONVEXPOLYHEDRON,this.bins),L=this.binLengths,_=this.bins.length,z=0;z!==_;z++)L[z]=0;for(var I=Math.ceil,c=Math.min,h=Math.max,z=0;z!==n;z++){var F=s[z],V=F.shape;switch(V.type){case k:var q=F.position.x,j=F.position.y,H=F.position.z,O=V.radius;o(q-O,j-O,H-O,q+O,j+O,H+O,F);break;case P:V.worldNormalNeedsUpdate&&V.computeWorldNormal(F.quaternion);var D=V.worldNormal,W=w+.5*B-F.position.x,K=b+.5*T-F.position.y,U=x+.5*R-F.position.z,G=a;G.set(W,K,U);for(var X=0,Y=0;X!==l;X++,Y+=d,G.y=K,G.x+=B)for(var Q=0,Z=0;Q!==u;Q++,Z+=y,G.z=U,G.y+=T)for(var J=0,$=0;J!==p;J++,$+=v,G.z+=R)if(G.dot(D)1)for(var it=N[z],X=0;X!==et;X++)for(var F=it[X],Q=0;Q!==X;Q++){var ot=it[Q];this.needBroadphaseCollision(F,ot)&&this.intersectionTest(F,ot,e,i)}}this.makePairsUnique(e,i)}},{"../math/Vec3":49,"../shapes/Shape":62,"./Broadphase":23}],25:[function(t,e,i){function o(){n.apply(this)}e.exports=o;var n=t("./Broadphase"),s=t("./AABB");o.prototype=new n,o.prototype.constructor=o,o.prototype.collisionPairs=function(t,e,i){var o,n,s,r,a=t.bodies,h=a.length;for(o=0;o!==h;o++)for(n=0;n!==o;n++)s=a[o],r=a[n],this.needBroadphaseCollision(s,r)&&this.intersectionTest(s,r,e,i)};new s;o.prototype.aabbQuery=function(t,e,i){i=i||[];for(var o=0;ot){var i=e;e=t,t=i}return t+"-"+e in this.matrix},o.prototype.set=function(t,e,i){if(t=t.id,e=e.id,e>t){var o=e;e=t,t=o}i?this.matrix[t+"-"+e]=!0:delete this.matrix[t+"-"+e]},o.prototype.reset=function(){this.matrix={}},o.prototype.setNumObjects=function(t){}},{}],27:[function(t,e,i){function o(){this.current=[],this.previous=[]}function n(t,e){t.push((4294901760&e)>>16,65535&e)}e.exports=o,o.prototype.getKey=function(t,e){if(eo[n];)n++;if(i!==o[n]){for(var e=o.length-1;e>=n;e--)o[e+1]=o[e];o[n]=i}},o.prototype.tick=function(){var t=this.current;this.current=this.previous,this.previous=t,this.current.length=0},o.prototype.getDiff=function(t,e){for(var i=this.current,o=this.previous,s=i.length,r=o.length,a=0,h=0;ho[a];)a++;c=l===o[a],c||n(t,l)}a=0;for(var h=0;hi[a];)a++;c=i[a]===u,c||n(e,u)}}},{}],28:[function(t,e,i){function o(t,e){this.from=t?t.clone():new r,this.to=e?e.clone():new r,this._direction=new r,this.precision=1e-4,this.checkCollisionResponse=!0,this.skipBackfaces=!1,this.collisionFilterMask=-1,this.collisionFilterGroup=-1,this.mode=o.ANY,this.result=new c,this.hasHit=!1,this.callback=function(t){}}function n(t,e,i,o){o.vsub(e,V),i.vsub(e,y),t.vsub(e,v);var n,s,r=V.dot(V),a=V.dot(y),h=V.dot(v),c=y.dot(y),l=y.dot(v);return(n=c*h-a*l)>=0&&(s=r*l-a*h)>=0&&n+st.boundingSphereRadius)){var a=this[t.type];a&&a.call(this,t,e,i,o,t)}};var g=(new r,new r,new r),w=new r,b=new r,x=new r;new r,new c;o.prototype.intersectBox=function(t,e,i,o,n){return this.intersectConvex(t.convexPolyhedronRepresentation,e,i,o,n)},o.prototype[l.types.BOX]=o.prototype.intersectBox,o.prototype.intersectPlane=function(t,e,i,o,n){var s=this.from,a=this.to,h=this._direction,c=new r(0,0,1);e.vmult(c,c);var l=new r;s.vsub(i,l);var u=l.dot(c);a.vsub(i,l);var p=l.dot(c);if(!(u*p>0||s.distanceTo(a)=0&&y<=1&&(s.lerp(r,y,p),p.vsub(i,d),d.normalize(),this.reportIntersection(d,p,n,o,-1)),this.result._shouldStop)return;v>=0&&v<=1&&(s.lerp(r,v,p),p.vsub(i,d),d.normalize(),this.reportIntersection(d,p,n,o,-1))}},o.prototype[l.types.SPHERE]=o.prototype.intersectSphere;var S=new r,M=(new r,new r,new r);o.prototype.intersectConvex=function(t,e,i,o,s,r){for(var a=S,h=M,c=r&&r.faceList||null,l=t.faces,u=t.vertices,p=t.faceNormals,d=this._direction,y=this.from,v=this.to,m=y.distanceTo(v),f=c?c.length:l.length,E=this.result,A=0;!E._shouldStop&&Am||this.reportIntersection(a,g,s,o,C)}}}}},o.prototype[l.types.CONVEXPOLYHEDRON]=o.prototype.intersectConvex;var k=new r,P=new r,N=new r,L=new r,_=new r,z=new r,I=(new u,[]),F=new h;o.prototype.intersectTrimesh=function(t,e,i,o,s,r){var a=k,c=I,l=F,u=M,p=P,d=N,y=L,v=z,m=_,f=(r&&r.faceList||null,t.indices),E=(t.vertices,t.faceNormals,this.from),A=this.to,C=this._direction;l.position.copy(i),l.quaternion.copy(e),h.vectorToLocalFrame(i,e,C,p),h.pointToLocalFrame(i,e,E,d),h.pointToLocalFrame(i,e,A,y),y.x*=t.scale.x,y.y*=t.scale.y,y.z*=t.scale.z,d.x*=t.scale.x,d.y*=t.scale.y,d.z*=t.scale.z,y.vsub(d,p),p.normalize();var B=d.distanceSquared(y);t.tree.rayQuery(this,l,c);for(var T=0,R=c.length;!this.result._shouldStop&&T!==R;T++){var S=c[T];t.getNormal(S,a),t.getVertex(f[3*S],w),w.vsub(d,u);var V=p.dot(a),q=a.dot(u)/V;if(!(q<0)){p.scale(q,g),g.vadd(d,g),t.getVertex(f[3*S+1],b),t.getVertex(f[3*S+2],x);var j=g.distanceSquared(d);!n(g,b,w,x)&&!n(g,w,b,x)||j>B||(h.vectorToWorldFrame(e,a,m),h.pointToWorldFrame(i,e,g,v),this.reportIntersection(m,v,s,o,S))}}c.length=0},o.prototype[l.types.TRIMESH]=o.prototype.intersectTrimesh,o.prototype.reportIntersection=function(t,e,i,n,s){var r=this.from,a=this.to,h=r.distanceTo(e),c=this.result;if(!(this.skipBackfaces&&t.dot(this._direction)>0))switch(c.hitFaceIndex="undefined"!=typeof s?s:-1,this.mode){case o.ALL:this.hasHit=!0,c.set(r,a,t,e,i,n,h),c.hasHit=!0,this.callback(c);break;case o.CLOSEST:(h=0&&!(t[n].aabb.lowerBound.x<=o.aabb.lowerBound.x);n--)t[n+1]=t[n];t[n+1]=o}return t},o.insertionSortY=function(t){for(var e=1,i=t.length;e=0&&!(t[n].aabb.lowerBound.y<=o.aabb.lowerBound.y);n--)t[n+1]=t[n];t[n+1]=o}return t},o.insertionSortZ=function(t){for(var e=1,i=t.length;e=0&&!(t[n].aabb.lowerBound.z<=o.aabb.lowerBound.z);n--)t[n+1]=t[n];t[n+1]=o}return t},o.prototype.collisionPairs=function(t,e,i){var n,s,r=this.axisList,a=r.length,h=this.axisIndex;for(this.dirty&&(this.sortList(),this.dirty=!1),n=0;n!==a;n++){var c=r[n];for(s=n+1;sv?y>m?this.axisIndex=0:this.axisIndex=2:v>m?this.axisIndex=1:this.axisIndex=2},o.prototype.aabbQuery=function(t,e,i){i=i||[],this.dirty&&(this.sortList(),this.dirty=!1);var o=this.axisIndex,n="x";1===o&&(n="y"),2===o&&(n="z");for(var s=this.axisList,r=(e.lowerBound[n],e.upperBound[n],0);r.499&&(i=2*Math.atan2(s,h),o=Math.PI/2,n=0),c<-.499&&(i=-2*Math.atan2(s,h),o=-Math.PI/2,n=0),isNaN(i)){var l=s*s,u=r*r,p=a*a;i=Math.atan2(2*r*h-2*s*a,1-2*u-2*p),o=Math.asin(2*c),n=Math.atan2(2*s*h-2*r*a,1-2*l-2*p)}break;default:throw new Error("Euler order "+e+" not supported yet.")}t.y=i,t.z=o,t.x=n},o.prototype.setFromEuler=function(t,e,i,o){o=o||"XYZ";var n=Math.cos(t/2),s=Math.cos(e/2),r=Math.cos(i/2),a=Math.sin(t/2),h=Math.sin(e/2),c=Math.sin(i/2);return"XYZ"===o?(this.x=a*s*r+n*h*c,this.y=n*h*r-a*s*c,this.z=n*s*c+a*h*r,this.w=n*s*r-a*h*c):"YXZ"===o?(this.x=a*s*r+n*h*c,this.y=n*h*r-a*s*c,this.z=n*s*c-a*h*r,this.w=n*s*r+a*h*c):"ZXY"===o?(this.x=a*s*r-n*h*c,this.y=n*h*r+a*s*c,this.z=n*s*c+a*h*r,this.w=n*s*r-a*h*c):"ZYX"===o?(this.x=a*s*r-n*h*c,this.y=n*h*r+a*s*c,this.z=n*s*c-a*h*r,this.w=n*s*r+a*h*c):"YZX"===o?(this.x=a*s*r+n*h*c,this.y=n*h*r+a*s*c,this.z=n*s*c-a*h*r,this.w=n*s*r-a*h*c):"XZY"===o&&(this.x=a*s*r-n*h*c,this.y=n*h*r-a*s*c,this.z=n*s*c+a*h*r,this.w=n*s*r+a*h*c),this},o.prototype.clone=function(){return new o(this.x,this.y,this.z,this.w)},o.prototype.slerp=function(t,e,i){i=i||new o;var n,s,r,a,h,c=this.x,l=this.y,u=this.z,p=this.w,d=t.x,y=t.y,v=t.z,m=t.w;return s=c*d+l*y+u*v+p*m,s<0&&(s=-s,d=-d,y=-y,v=-v,m=-m),1-s>1e-6?(n=Math.acos(s),r=Math.sin(n),a=Math.sin((1-e)*n)/r,h=Math.sin(e*n)/r):(a=1-e,h=e),i.x=a*c+h*d,i.y=a*l+h*y,i.z=a*u+h*v,i.w=a*p+h*m,i},o.prototype.integrate=function(t,e,i,n){n=n||new o;var s=t.x*i.x,r=t.y*i.y,a=t.z*i.z,h=this.x,c=this.y,l=this.z,u=this.w,p=.5*e;return n.x+=p*(s*u+r*l-a*c),n.y+=p*(r*u+a*h-s*l),n.z+=p*(a*u+s*c-r*h),n.w+=p*(-s*h-r*c-a*l),n}},{"./Vec3":49}],48:[function(t,e,i){function o(t){t=t||{},this.position=new n,t.position&&this.position.copy(t.position),this.quaternion=new s,t.quaternion&&this.quaternion.copy(t.quaternion)}var n=t("./Vec3"),s=t("./Quaternion");e.exports=o;var r=new s;o.pointToLocalFrame=function(t,e,i,o){var o=o||new n;return i.vsub(t,o),e.conjugate(r),r.vmult(o,o),o},o.prototype.pointToLocal=function(t,e){return o.pointToLocalFrame(this.position,this.quaternion,t,e)},o.pointToWorldFrame=function(t,e,i,o){var o=o||new n;return e.vmult(i,o),o.vadd(t,o),o},o.prototype.pointToWorld=function(t,e){return o.pointToWorldFrame(this.position,this.quaternion,t,e)},o.prototype.vectorToWorldFrame=function(t,e){var e=e||new n;return this.quaternion.vmult(t,e),e},o.vectorToWorldFrame=function(t,e,i){return t.vmult(e,i),i},o.vectorToLocalFrame=function(t,e,i,o){var o=o||new n;return e.w*=-1,e.vmult(i,o),e.w*=-1,o}},{"./Quaternion":47,"./Vec3":49}],49:[function(t,e,i){function o(t,e,i){this.x=t||0,this.y=e||0,this.z=i||0}e.exports=o;var n=t("./Mat3");o.ZERO=new o(0,0,0),o.UNIT_X=new o(1,0,0),o.UNIT_Y=new o(0,1,0),o.UNIT_Z=new o(0,0,1),o.prototype.cross=function(t,e){var i=t.x,n=t.y,s=t.z,r=this.x,a=this.y,h=this.z;return e=e||new o,e.x=a*s-h*n,e.y=h*i-r*s,e.z=r*n-a*i,e},o.prototype.set=function(t,e,i){return this.x=t,this.y=e,this.z=i,this},o.prototype.setZero=function(){this.x=this.y=this.z=0},o.prototype.vadd=function(t,e){return e?(e.x=t.x+this.x,e.y=t.y+this.y,e.z=t.z+this.z,void 0):new o(this.x+t.x,this.y+t.y,this.z+t.z)},o.prototype.vsub=function(t,e){return e?(e.x=this.x-t.x,e.y=this.y-t.y,e.z=this.z-t.z,void 0):new o(this.x-t.x,this.y-t.y,this.z-t.z)},o.prototype.crossmat=function(){return new n([0,-this.z,this.y,this.z,0,-this.x,-this.y,this.x,0])},o.prototype.normalize=function(){var t=this.x,e=this.y,i=this.z,o=Math.sqrt(t*t+e*e+i*i);if(o>0){var n=1/o;this.x*=n,this.y*=n,this.z*=n}else this.x=0,this.y=0,this.z=0;return o},o.prototype.unit=function(t){t=t||new o;var e=this.x,i=this.y,n=this.z,s=Math.sqrt(e*e+i*i+n*n);return s>0?(s=1/s,t.x=e*s,t.y=i*s,t.z=n*s):(t.x=1,t.y=0,t.z=0),t},o.prototype.norm=function(){var t=this.x,e=this.y,i=this.z;return Math.sqrt(t*t+e*e+i*i)},o.prototype.length=o.prototype.norm,o.prototype.norm2=function(){return this.dot(this)},o.prototype.lengthSquared=o.prototype.norm2,o.prototype.distanceTo=function(t){var e=this.x,i=this.y,o=this.z,n=t.x,s=t.y,r=t.z;return Math.sqrt((n-e)*(n-e)+(s-i)*(s-i)+(r-o)*(r-o))},o.prototype.distanceSquared=function(t){var e=this.x,i=this.y,o=this.z,n=t.x,s=t.y,r=t.z;return(n-e)*(n-e)+(s-i)*(s-i)+(r-o)*(r-o)},o.prototype.mult=function(t,e){e=e||new o;var i=this.x,n=this.y,s=this.z;return e.x=t*i,e.y=t*n,e.z=t*s,e},o.prototype.vmul=function(t,e){return e=e||new o,e.x=t.x*this.x,e.y=t.y*this.y,e.z=t.z*this.z,e},o.prototype.scale=o.prototype.mult,o.prototype.addScaledVector=function(t,e,i){return i=i||new o,i.x=this.x+t*e.x,i.y=this.y+t*e.y,i.z=this.z+t*e.z,i},o.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},o.prototype.isZero=function(){return 0===this.x&&0===this.y&&0===this.z},o.prototype.negate=function(t){return t=t||new o,t.x=-this.x,t.y=-this.y,t.z=-this.z,t};var s=new o,r=new o;o.prototype.tangents=function(t,e){var i=this.norm();if(i>0){var o=s,n=1/i;o.set(this.x*n,this.y*n,this.z*n);var a=r;Math.abs(o.x)<.9?(a.set(1,0,0),o.cross(a,t)):(a.set(0,1,0),o.cross(a,t)),o.cross(t,e)}else t.set(1,0,0),e.set(0,1,0)},o.prototype.toString=function(){return this.x+","+this.y+","+this.z},o.prototype.toArray=function(){return[this.x,this.y,this.z]},o.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},o.prototype.lerp=function(t,e,i){var o=this.x,n=this.y,s=this.z;i.x=o+(t.x-o)*e,i.y=n+(t.y-n)*e,i.z=s+(t.z-s)*e},o.prototype.almostEquals=function(t,e){return void 0===e&&(e=1e-6),!(Math.abs(this.x-t.x)>e||Math.abs(this.y-t.y)>e||Math.abs(this.z-t.z)>e)},o.prototype.almostZero=function(t){return void 0===t&&(t=1e-6),!(Math.abs(this.x)>t||Math.abs(this.y)>t||Math.abs(this.z)>t)};var a=new o;o.prototype.isAntiparallelTo=function(t,e){return this.negate(a),a.almostEquals(t,e)},o.prototype.clone=function(){return new o(this.x,this.y,this.z)}},{"./Mat3":46}],50:[function(t,e,i){function o(t){t=t||{},n.apply(this),this.id=o.idCounter++,this.world=null,this.preStep=null,this.postStep=null,this.vlambda=new s,this.collisionFilterGroup="number"==typeof t.collisionFilterGroup?t.collisionFilterGroup:1,this.collisionFilterMask="number"==typeof t.collisionFilterMask?t.collisionFilterMask:1,this.collisionResponse=!0,this.position=new s,this.previousPosition=new s,this.interpolatedPosition=new s,this.initPosition=new s,t.position&&(this.position.copy(t.position),this.previousPosition.copy(t.position),this.interpolatedPosition.copy(t.position),this.initPosition.copy(t.position)),this.velocity=new s,t.velocity&&this.velocity.copy(t.velocity),this.initVelocity=new s,this.force=new s;var e="number"==typeof t.mass?t.mass:0;this.mass=e,this.invMass=e>0?1/e:0,this.material=t.material||null,this.linearDamping="number"==typeof t.linearDamping?t.linearDamping:.01,this.type=e<=0?o.STATIC:o.DYNAMIC,typeof t.type==typeof o.STATIC&&(this.type=t.type),this.allowSleep="undefined"==typeof t.allowSleep||t.allowSleep,this.sleepState=0,this.sleepSpeedLimit="undefined"!=typeof t.sleepSpeedLimit?t.sleepSpeedLimit:.1,this.sleepTimeLimit="undefined"!=typeof t.sleepTimeLimit?t.sleepTimeLimit:1,this.timeLastSleepy=0,this._wakeUpAfterNarrowphase=!1,this.torque=new s,this.quaternion=new a,this.initQuaternion=new a,this.previousQuaternion=new a,this.interpolatedQuaternion=new a,t.quaternion&&(this.quaternion.copy(t.quaternion),this.initQuaternion.copy(t.quaternion),this.previousQuaternion.copy(t.quaternion),this.interpolatedQuaternion.copy(t.quaternion)),this.angularVelocity=new s,t.angularVelocity&&this.angularVelocity.copy(t.angularVelocity),this.initAngularVelocity=new s,this.shapes=[],this.shapeOffsets=[],this.shapeOrientations=[],this.inertia=new s,this.invInertia=new s,this.invInertiaWorld=new r,this.invMassSolve=0,this.invInertiaSolve=new s,this.invInertiaWorldSolve=new r,this.fixedRotation="undefined"!=typeof t.fixedRotation&&t.fixedRotation,this.angularDamping="undefined"!=typeof t.angularDamping?t.angularDamping:.01,this.linearFactor=new s(1,1,1),t.linearFactor&&this.linearFactor.copy(t.linearFactor),this.angularFactor=new s(1,1,1),t.angularFactor&&this.angularFactor.copy(t.angularFactor),this.aabb=new h,this.aabbNeedsUpdate=!0,this.wlambda=new s,t.shape&&this.addShape(t.shape),this.updateMassProperties()}e.exports=o;var n=t("../utils/EventTarget"),s=(t("../shapes/Shape"),t("../math/Vec3")),r=t("../math/Mat3"),a=t("../math/Quaternion"),h=(t("../material/Material"),t("../collision/AABB")),c=t("../shapes/Box");o.prototype=new n,o.prototype.constructor=o,o.COLLIDE_EVENT_NAME="collide",o.DYNAMIC=1,o.STATIC=2,o.KINEMATIC=4,o.AWAKE=0,o.SLEEPY=1,o.SLEEPING=2,o.idCounter=0,o.wakeupEvent={type:"wakeup"},o.prototype.wakeUp=function(){var t=this.sleepState;this.sleepState=0,this._wakeUpAfterNarrowphase=!1,t===o.SLEEPING&&this.dispatchEvent(o.wakeupEvent)},o.prototype.sleep=function(){this.sleepState=o.SLEEPING,this.velocity.set(0,0,0),this.angularVelocity.set(0,0,0),this._wakeUpAfterNarrowphase=!1},o.sleepyEvent={type:"sleepy"},o.sleepEvent={type:"sleep"},o.prototype.sleepTick=function(t){if(this.allowSleep){var e=this.sleepState,i=this.velocity.norm2()+this.angularVelocity.norm2(),n=Math.pow(this.sleepSpeedLimit,2);e===o.AWAKE&&in?this.wakeUp():e===o.SLEEPY&&t-this.timeLastSleepy>this.sleepTimeLimit&&(this.sleep(),this.dispatchEvent(o.sleepEvent))}},o.prototype.updateSolveMassProperties=function(){this.sleepState===o.SLEEPING||this.type===o.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve.setZero(),this.invInertiaWorldSolve.setZero()):(this.invMassSolve=this.invMass,this.invInertiaSolve.copy(this.invInertia),this.invInertiaWorldSolve.copy(this.invInertiaWorld))},o.prototype.pointToLocalFrame=function(t,e){var e=e||new s;return t.vsub(this.position,e),this.quaternion.conjugate().vmult(e,e),e},o.prototype.vectorToLocalFrame=function(t,e){var e=e||new s;return this.quaternion.conjugate().vmult(t,e),e},o.prototype.pointToWorldFrame=function(t,e){var e=e||new s;return this.quaternion.vmult(t,e),e.vadd(this.position,e),e},o.prototype.vectorToWorldFrame=function(t,e){var e=e||new s;return this.quaternion.vmult(t,e),e};var l=new s,u=new a;o.prototype.addShape=function(t,e,i){var o=new s,n=new a;return e&&o.copy(e),i&&n.copy(i),this.shapes.push(t),this.shapeOffsets.push(o),this.shapeOrientations.push(n),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0,t.body=this,this},o.prototype.updateBoundingRadius=function(){for(var t=this.shapes,e=this.shapeOffsets,i=t.length,o=0,n=0;n!==i;n++){var s=t[n];s.updateBoundingSphereRadius();var r=e[n].norm(),a=s.boundingSphereRadius;r+a>o&&(o=r+a)}this.boundingRadius=o};var p=new h;o.prototype.computeAABB=function(){for(var t=this.shapes,e=this.shapeOffsets,i=this.shapeOrientations,o=t.length,n=l,s=u,r=this.quaternion,a=this.aabb,h=p,c=0;c!==o;c++){var d=t[c];r.vmult(e[c],n),n.vadd(this.position,n),i[c].mult(r,s),d.calculateWorldAABB(n,s,h.lowerBound,h.upperBound),0===c?a.copy(h):a.extend(h)}this.aabbNeedsUpdate=!1};var d=new r,y=new r;new r;o.prototype.updateInertiaWorld=function(t){var e=this.invInertia;if(e.x!==e.y||e.y!==e.z||t){var i=d,o=y;i.setRotationFromQuaternion(this.quaternion),i.transpose(o),i.scale(e,i),i.mmult(o,this.invInertiaWorld)}else;};var v=(new s,new s);o.prototype.applyForce=function(t,e){if(this.type===o.DYNAMIC){var i=v;e.cross(t,i),this.force.vadd(t,this.force),this.torque.vadd(i,this.torque)}};var m=new s,f=new s;o.prototype.applyLocalForce=function(t,e){if(this.type===o.DYNAMIC){var i=m,n=f;this.vectorToWorldFrame(t,i),this.vectorToWorldFrame(e,n),this.applyForce(i,n)}};var g=(new s,new s),w=new s;o.prototype.applyImpulse=function(t,e){if(this.type===o.DYNAMIC){var i=e,n=g;n.copy(t),n.mult(this.invMass,n),this.velocity.vadd(n,this.velocity);var s=w;i.cross(t,s),this.invInertiaWorld.vmult(s,s),this.angularVelocity.vadd(s,this.angularVelocity)}};var b=new s,x=new s;o.prototype.applyLocalImpulse=function(t,e){if(this.type===o.DYNAMIC){var i=b,n=x;this.vectorToWorldFrame(t,i),this.vectorToWorldFrame(e,n),this.applyImpulse(i,n)}};var E=new s;o.prototype.updateMassProperties=function(){var t=E;this.invMass=this.mass>0?1/this.mass:0;var e=this.inertia,i=this.fixedRotation;this.computeAABB(),t.set((this.aabb.upperBound.x-this.aabb.lowerBound.x)/2,(this.aabb.upperBound.y-this.aabb.lowerBound.y)/2,(this.aabb.upperBound.z-this.aabb.lowerBound.z)/2),c.calculateInertia(t,this.mass,e),this.invInertia.set(e.x>0&&!i?1/e.x:0,e.y>0&&!i?1/e.y:0,e.z>0&&!i?1/e.z:0),this.updateInertiaWorld(!0)},o.prototype.getVelocityAtWorldPoint=function(t,e){var i=new s;return t.vsub(this.position,i),this.angularVelocity.cross(i,e),this.velocity.vadd(e,e),e};new s,new s,new a,new a;o.prototype.integrate=function(t,e,i){if(this.previousPosition.copy(this.position),this.previousQuaternion.copy(this.quaternion),(this.type===o.DYNAMIC||this.type===o.KINEMATIC)&&this.sleepState!==o.SLEEPING){var n=this.velocity,s=this.angularVelocity,r=this.position,a=this.force,h=this.torque,c=this.quaternion,l=this.invMass,u=this.invInertiaWorld,p=this.linearFactor,d=l*t;n.x+=a.x*d*p.x,n.y+=a.y*d*p.y,n.z+=a.z*d*p.z;var y=u.elements,v=this.angularFactor,m=h.x*v.x,f=h.y*v.y,g=h.z*v.z;s.x+=t*(y[0]*m+y[1]*f+y[2]*g),s.y+=t*(y[3]*m+y[4]*f+y[5]*g),s.z+=t*(y[6]*m+y[7]*f+y[8]*g),r.x+=n.x*t,r.y+=n.y*t,r.z+=n.z*t,c.integrate(this.angularVelocity,t,this.angularFactor,c),e&&(i?c.normalizeFast():c.normalize()),this.aabbNeedsUpdate=!0,this.updateInertiaWorld()}}},{"../collision/AABB":21,"../material/Material":44,"../math/Mat3":46,"../math/Quaternion":47,"../math/Vec3":49,"../shapes/Box":56,"../shapes/Shape":62,"../utils/EventTarget":68}],51:[function(t,e,i){function o(t){this.chassisBody=t.chassisBody,this.wheelInfos=[],this.sliding=!1,this.world=null,this.indexRightAxis="undefined"!=typeof t.indexRightAxis?t.indexRightAxis:1,this.indexForwardAxis="undefined"!=typeof t.indexForwardAxis?t.indexForwardAxis:0,this.indexUpAxis="undefined"!=typeof t.indexUpAxis?t.indexUpAxis:2}function n(t,e,i,o,n){var r=0,a=i,h=x,c=E,l=A;t.getVelocityAtWorldPoint(a,h),e.getVelocityAtWorldPoint(a,c),h.vsub(c,l);var u=o.dot(l),p=s(t,i,o),d=s(e,i,o),y=1,v=y/(p+d);return r=-u*v,n1.1)return 0;var a=S,h=M,c=k;t.getVelocityAtWorldPoint(e,a),i.getVelocityAtWorldPoint(o,h),a.vsub(h,c);var l=n.dot(c),u=.2,p=1/(t.invMass+i.invMass),s=-u*l*p;return s}var a=(t("./Body"),t("../math/Vec3")),h=t("../math/Quaternion"),c=(t("../collision/RaycastResult"),t("../collision/Ray")),l=t("../objects/WheelInfo");e.exports=o;var u=(new a,new a,new a,new a),p=new a,d=new a;new c;o.prototype.addWheel=function(t){t=t||{};var e=new l(t),i=this.wheelInfos.length;return this.wheelInfos.push(e),i},o.prototype.setSteeringValue=function(t,e){var i=this.wheelInfos[e];i.steering=t};new a;o.prototype.applyEngineForce=function(t,e){this.wheelInfos[e].engineForce=t},o.prototype.setBrake=function(t,e){this.wheelInfos[e].brake=t},o.prototype.addToWorld=function(t){this.constraints;t.addBody(this.chassisBody);var e=this;this.preStepCallback=function(){e.updateVehicle(t.dt)},t.addEventListener("preStep",this.preStepCallback),this.world=t},o.prototype.getVehicleAxisWorld=function(t,e){e.set(0===t?1:0,1===t?1:0,2===t?1:0),this.chassisBody.vectorToWorldFrame(e,e)},o.prototype.updateVehicle=function(t){for(var e=this.wheelInfos,i=e.length,o=this.chassisBody,n=0;nc.maxSuspensionForce&&(l=c.maxSuspensionForce),c.raycastResult.hitNormalWorld.scale(l*t,r),c.raycastResult.hitPointWorld.vsub(o.position,h),o.applyImpulse(r,h)}this.updateFriction(t);var u=new a,p=new a,d=new a;for(n=0;n0?1:-1)*c.customSlidingRotationalSpeed*t),Math.abs(c.brake)>Math.abs(c.engineForce)&&(c.deltaRotation=0),c.rotation+=c.deltaRotation,c.deltaRotation*=.99}},o.prototype.updateSuspension=function(t){for(var e=this.chassisBody,i=e.mass,o=this.wheelInfos,n=o.length,s=0;sd&&(t.suspensionLength=d,t.raycastResult.reset());var m=t.raycastResult.hitNormalWorld.dot(t.directionWorld),f=new a;o.getVelocityAtWorldPoint(t.raycastResult.hitPointWorld,f);var g=t.raycastResult.hitNormalWorld.dot(f);if(m>=-.1)t.suspensionRelativeVelocity=0,t.clippedInvContactDotSuspension=10;else{var w=-1/m;t.suspensionRelativeVelocity=g*w,t.clippedInvContactDotSuspension=w}}else t.suspensionLength=t.suspensionRestLength+0*t.maxSuspensionTravel,t.suspensionRelativeVelocity=0,t.directionWorld.scale(-1,t.raycastResult.hitNormalWorld),t.clippedInvContactDotSuspension=1;return n},o.prototype.updateWheelTransformWorld=function(t){t.isInContact=!1;var e=this.chassisBody;e.pointToWorldFrame(t.chassisConnectionPointLocal,t.chassisConnectionPointWorld),e.vectorToWorldFrame(t.directionLocal,t.directionWorld),e.vectorToWorldFrame(t.axleLocal,t.axleWorld)},o.prototype.updateWheelTransform=function(t){var e=u,i=p,o=d,n=this.wheelInfos[t];this.updateWheelTransformWorld(n),n.directionLocal.scale(-1,e),i.copy(n.axleLocal),e.cross(i,o),o.normalize(),i.normalize();var s=n.steering,r=new h;r.setFromAxisAngle(e,s);var a=new h;a.setFromAxisAngle(i,n.rotation);var c=n.worldTransform.quaternion;this.chassisBody.quaternion.mult(r,c),c.mult(a,c),c.normalize();var l=n.worldTransform.position;l.copy(n.directionWorld),l.scale(n.suspensionLength,l),l.vadd(n.chassisConnectionPointWorld,l)};var m=[new a(1,0,0),new a(0,1,0),new a(0,0,1)];o.prototype.getWheelTransformWorld=function(t){return this.wheelInfos[t].worldTransform};var f=new a,g=[],w=[],b=1;o.prototype.updateFriction=function(t){for(var e=f,i=this.wheelInfos,o=i.length,s=this.chassisBody,h=w,c=g,l=0,u=0;uP){this.sliding=!0,p.sliding=!0;var S=M/Math.sqrt(_);p.skidInfo*=S}}}if(this.sliding)for(var u=0;uthis.particles.length&&this.neighbors.pop())};var s=new n;o.prototype.getNeighbors=function(t,e){for(var i=this.particles.length,o=t.id,n=this.smoothingRadius*this.smoothingRadius,r=s,a=0;a!==i;a++){var h=this.particles[a];h.position.vsub(t.position,r),o!==h.id&&r.norm2()=-.1)this.suspensionRelativeVelocity=0,this.clippedInvContactDotSuspension=10;else{var n=-1/i;this.suspensionRelativeVelocity=o*n,this.clippedInvContactDotSuspension=n}}else e.suspensionLength=this.suspensionRestLength,this.suspensionRelativeVelocity=0,e.directionWorld.scale(-1,e.hitNormalWorld),this.clippedInvContactDotSuspension=1}},{"../collision/RaycastResult":29,"../math/Transform":48,"../math/Vec3":49,"../utils/Utils":72}],56:[function(t,e,i){function o(t){n.call(this),this.type=n.types.BOX,this.halfExtents=t,this.convexPolyhedronRepresentation=null,this.updateConvexPolyhedronRepresentation(),this.updateBoundingSphereRadius()}e.exports=o;var n=t("./Shape"),s=t("../math/Vec3"),r=t("./ConvexPolyhedron");o.prototype=new n,o.prototype.constructor=o,o.prototype.updateConvexPolyhedronRepresentation=function(){var t=this.halfExtents.x,e=this.halfExtents.y,i=this.halfExtents.z,o=s,n=[new o((-t),(-e),(-i)),new o(t,(-e),(-i)),new o(t,e,(-i)),new o((-t),e,(-i)),new o((-t),(-e),i),new o(t,(-e),i),new o(t,e,i),new o((-t),e,i)],a=[[3,2,1,0],[4,5,6,7],[5,4,0,1],[2,3,7,6],[0,4,7,3],[1,2,6,5]],h=([new o(0,0,1),new o(0,1,0),new o(1,0,0)],new r(n,a));this.convexPolyhedronRepresentation=h,h.material=this.material},o.prototype.calculateLocalInertia=function(t,e){return e=e||new s,o.calculateInertia(this.halfExtents,t,e),e},o.calculateInertia=function(t,e,i){var o=t;i.x=1/12*e*(2*o.y*2*o.y+2*o.z*2*o.z),i.y=1/12*e*(2*o.x*2*o.x+2*o.z*2*o.z),i.z=1/12*e*(2*o.y*2*o.y+2*o.x*2*o.x)},o.prototype.getSideNormals=function(t,e){var i=t,o=this.halfExtents;if(i[0].set(o.x,0,0),i[1].set(0,o.y,0),i[2].set(0,0,o.z),i[3].set(-o.x,0,0),i[4].set(0,-o.y,0),i[5].set(0,0,-o.z),void 0!==e)for(var n=0;n!==i.length;n++)e.vmult(i[n],i[n]);return i},o.prototype.volume=function(){return 8*this.halfExtents.x*this.halfExtents.y*this.halfExtents.z},o.prototype.updateBoundingSphereRadius=function(){this.boundingSphereRadius=this.halfExtents.norm()};var a=new s;new s;o.prototype.forEachWorldCorner=function(t,e,i){for(var o=this.halfExtents,n=[[o.x,o.y,o.z],[-o.x,o.y,o.z],[-o.x,-o.y,o.z],[-o.x,-o.y,-o.z],[o.x,-o.y,-o.z],[o.x,o.y,-o.z],[-o.x,o.y,-o.z],[o.x,-o.y,o.z]],s=0;so.x&&(o.x=a),c>o.y&&(o.y=c),l>o.z&&(o.z=l),ad&&(d=v,p=y)}for(var m=[],f=i.faces[p],g=f.length,w=0;w=0&&this.clipFaceAgainstHull(r,t,e,m,a,h,c)};var u=new s,p=new s,d=new s,y=new s,v=new s,m=new s;o.prototype.findSeparatingAxis=function(t,e,i,o,n,s,r,a){var h=u,c=p,l=d,f=y,g=v,w=m,b=Number.MAX_VALUE,x=this,E=0;if(x.uniqueAxes)for(var A=0;A!==x.uniqueAxes.length;A++){i.vmult(x.uniqueAxes[A],h);var C=x.testSepAxis(h,t,e,i,o,n);if(C===!1)return!1;C0&&s.negate(s),!0};var f=[],g=[];o.prototype.testSepAxis=function(t,e,i,n,s,r){var a=this;o.project(a,t,i,n,f),o.project(e,t,s,r,g);var h=f[0],c=f[1],l=g[0],u=g[1];if(he.x&&(e.x=s.x),s.ye.y&&(e.y=s.y),s.ze.z&&(e.z=s.z)}},o.prototype.computeWorldFaceNormals=function(t){for(var e=this.faceNormals.length;this.worldFaceNormals.lengtht&&(t=n)}this.boundingSphereRadius=Math.sqrt(t)};var M=new s;o.prototype.calculateWorldAABB=function(t,e,i,o){for(var n,s,r,a,h,c,l=this.vertices.length,u=this.vertices,p=0;pa||void 0===a)&&(a=d.x),d.yh||void 0===h)&&(h=d.y),d.zc||void 0===c)&&(c=d.z)}i.set(n,s,r),o.set(a,h,c)},o.prototype.volume=function(){return 4*Math.PI*this.boundingSphereRadius/3},o.prototype.getAveragePointLocal=function(t){t=t||new s;for(var e=this.vertices.length,i=this.vertices,o=0;o0||u>0&&d<0)return!1}return s?1:-1};var L=(new s,new s),_=new s;o.project=function(t,e,i,o,n){var s=t.vertices.length,a=L,h=0,c=0,l=_,u=t.vertices;l.setZero(),r.vectorToLocalFrame(i,o,e,a),r.pointToLocalFrame(i,o,l,l);var p=l.dot(a);c=h=u[0].dot(a);for(var d=1;dh&&(h=y),yh){var v=c;c=h,h=v}n[0]=h,n[1]=c}},{"../math/Quaternion":47,"../math/Transform":48,"../math/Vec3":49,"./Shape":62}],58:[function(t,e,i){function o(t,e,i,o){var a=o,h=[],c=[],l=[],u=[],p=[],d=Math.cos,y=Math.sin;h.push(new s(e*d(0),e*y(0),.5*-i)),u.push(0),h.push(new s(t*d(0),t*y(0),.5*i)),p.push(1);for(var v=0;ve&&(e=n)}this.maxValue=e},o.prototype.setHeightValueAtIndex=function(t,e,i){var o=this.data;o[t][e]=i,this.clearCachedConvexTrianglePillar(t,e,!1),t>0&&(this.clearCachedConvexTrianglePillar(t-1,e,!0),this.clearCachedConvexTrianglePillar(t-1,e,!1)),e>0&&(this.clearCachedConvexTrianglePillar(t,e-1,!0),this.clearCachedConvexTrianglePillar(t,e-1,!1)),e>0&&t>0&&this.clearCachedConvexTrianglePillar(t-1,e-1,!0)},o.prototype.getRectMinMax=function(t,e,i,o,n){n=n||[];for(var s=this.data,r=this.minValue,a=t;a<=i;a++)for(var h=e;h<=o;h++){var c=s[a][h];c>r&&(r=c)}n[0]=this.minValue,n[1]=r},o.prototype.getIndexOfPosition=function(t,e,i,o){var n=this.elementSize,s=this.data,r=Math.floor(t/n),a=Math.floor(e/n);return i[0]=r,i[1]=a,o&&(r<0&&(r=0),a<0&&(a=0),r>=s.length-1&&(r=s.length-1),a>=s[0].length-1&&(a=s[0].length-1)),!(r<0||a<0||r>=s.length-1||a>=s[0].length-1)};var c=[],l=new a,u=new a,p=new a,d=new a;o.prototype.getTriangleAt=function(t,e,i,o,n,s){var r=c;this.getIndexOfPosition(t,e,r,i);var a=r[0],h=r[1],l=this.data;i&&(a=Math.min(l.length-2,Math.max(0,a)),h=Math.min(l[0].length-2,Math.max(0,h)));var u=this.elementSize,p=Math.pow(t/u-a,2)+Math.pow(e/u-h,2),d=Math.pow(t/u-(a+1),2)+Math.pow(e/u-(h+1),2),y=p>d;return this.getTriangle(a,h,y,o,n,s),y};var y=new a,v=new a,m=new a,f=new a,g=new a;o.prototype.getNormalAt=function(t,e,i,o){var n=y,s=v,r=m,a=f,h=g;this.getTriangleAt(t,e,i,n,s,r),s.vsub(n,a),r.vsub(n,h),a.cross(h,o),o.normalize()},o.prototype.getAabbAtIndex=function(t,e,i){var o=this.data,n=this.elementSize;i.lowerBound.set(t*n,e*n,o[t][e]),i.upperBound.set((t+1)*n,(e+1)*n,o[t+1][e+1])},o.prototype.getHeightAt=function(t,e,i){var o=this.data,s=u,r=p,a=d,h=c;this.getIndexOfPosition(t,e,h,i);var y=h[0],v=h[1];i&&(y=Math.min(o.length-2,Math.max(0,y)),v=Math.min(o[0].length-2,Math.max(0,v)));var m=this.getTriangleAt(t,e,i,s,r,a);n(t,e,s.x,s.y,r.x,r.y,a.x,a.y,l);var f=l;return m?o[y+1][v+1]*f.x+o[y][v+1]*f.y+o[y+1][v]*f.z:o[y][v]*f.x+o[y+1][v]*f.y+o[y][v+1]*f.z},o.prototype.getCacheConvexTrianglePillarKey=function(t,e,i){return t+"_"+e+"_"+(i?1:0)},o.prototype.getCachedConvexTrianglePillar=function(t,e,i){return this._cachedPillars[this.getCacheConvexTrianglePillarKey(t,e,i)]},o.prototype.setCachedConvexTrianglePillar=function(t,e,i,o,n){this._cachedPillars[this.getCacheConvexTrianglePillarKey(t,e,i)]={convex:o,offset:n}},o.prototype.clearCachedConvexTrianglePillar=function(t,e,i){delete this._cachedPillars[this.getCacheConvexTrianglePillarKey(t,e,i)]},o.prototype.getTriangle=function(t,e,i,o,n,s){var r=this.data,a=this.elementSize;i?(o.set((t+1)*a,(e+1)*a,r[t+1][e+1]),n.set(t*a,(e+1)*a,r[t][e+1]),s.set((t+1)*a,e*a,r[t+1][e])):(o.set(t*a,e*a,r[t][e]),n.set((t+1)*a,e*a,r[t+1][e]),s.set(t*a,(e+1)*a,r[t][e+1]))},o.prototype.getConvexTrianglePillar=function(t,e,i){var o=this.pillarConvex,n=this.pillarOffset;if(this.cacheEnabled){var s=this.getCachedConvexTrianglePillar(t,e,i);if(s)return this.pillarConvex=s.convex,void(this.pillarOffset=s.offset);o=new r,n=new a,this.pillarConvex=o,this.pillarOffset=n}var s=this.data,h=this.elementSize,c=o.faces;o.vertices.length=6;for(var l=0;l<6;l++)o.vertices[l]||(o.vertices[l]=new a);c.length=5;for(var l=0;l<5;l++)c[l]||(c[l]=[]);var u=o.vertices,p=(Math.min(s[t][e],s[t+1][e],s[t][e+1],s[t+1][e+1])-this.minValue)/2+this.minValue;i?(n.set((t+.75)*h,(e+.75)*h,p),u[0].set(.25*h,.25*h,s[t+1][e+1]-p),u[1].set(-.75*h,.25*h,s[t][e+1]-p),u[2].set(.25*h,-.75*h,s[t+1][e]-p),u[3].set(.25*h,.25*h,-p-1),u[4].set(-.75*h,.25*h,-p-1),u[5].set(.25*h,-.75*h,-p-1),c[0][0]=0,c[0][1]=1,c[0][2]=2,c[1][0]=5,c[1][1]=4,c[1][2]=3,c[2][0]=2,c[2][1]=5,c[2][2]=3,c[2][3]=0,c[3][0]=3,c[3][1]=4,c[3][2]=1,c[3][3]=0,c[4][0]=1,c[4][1]=4,c[4][2]=5,c[4][3]=2):(n.set((t+.25)*h,(e+.25)*h,p),u[0].set(-.25*h,-.25*h,s[t][e]-p),u[1].set(.75*h,-.25*h,s[t+1][e]-p),u[2].set(-.25*h,.75*h,s[t][e+1]-p),u[3].set(-.25*h,-.25*h,-p-1),u[4].set(.75*h,-.25*h,-p-1),u[5].set(-.25*h,.75*h,-p-1),c[0][0]=0,c[0][1]=1,c[0][2]=2,c[1][0]=5,c[1][1]=4,c[1][2]=3,c[2][0]=0,c[2][1]=2,c[2][2]=5,c[2][3]=3,c[3][0]=1,c[3][1]=0,c[3][2]=3,c[3][3]=4,c[4][0]=4,c[4][1]=5,c[4][2]=2,c[4][3]=1),o.computeNormals(),o.computeEdges(),o.updateBoundingSphereRadius(),this.setCachedConvexTrianglePillar(t,e,i,o,n)},o.prototype.calculateLocalInertia=function(t,e){return e=e||new a,e.set(0,0,0),e},o.prototype.volume=function(){return Number.MAX_VALUE},o.prototype.calculateWorldAABB=function(t,e,i,o){i.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),o.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},o.prototype.updateBoundingSphereRadius=function(){var t=this.data,e=this.elementSize;this.boundingSphereRadius=new a(t.length*e,t[0].length*e,Math.max(Math.abs(this.maxValue),Math.abs(this.minValue))).norm()},o.prototype.setHeightsFromImage=function(t,e){var i=document.createElement("canvas");i.width=t.width,i.height=t.height;var o=i.getContext("2d");o.drawImage(t,0,0);var n=o.getImageData(0,0,t.width,t.height),s=this.data;s.length=0,this.elementSize=Math.abs(e.x)/n.width;for(var r=0;ri.x&&(i.x=n.x),n.yi.y&&(i.y=n.y),n.zi.z&&(i.z=n.z)},o.prototype.updateAABB=function(){this.computeLocalAABB(this.aabb)},o.prototype.updateBoundingSphereRadius=function(){for(var t=0,e=this.vertices,i=new s,o=0,n=e.length/3;o!==n;o++){this.getVertex(o,i);var r=i.norm2();r>t&&(t=r)}this.boundingSphereRadius=Math.sqrt(t)};var b=(new s,new r),x=new a;o.prototype.calculateWorldAABB=function(t,e,i,o){var n=b,s=x;n.position=t,n.quaternion=e,this.aabb.toWorldFrame(n,s),i.copy(s.lowerBound),o.copy(s.upperBound)},o.prototype.volume=function(){return 4*Math.PI*this.boundingSphereRadius/3},o.createTorus=function(t,e,i,n,s){t=t||1,e=e||.5,i=i||8,n=n||6,s=s||2*Math.PI;for(var r=[],a=[],h=0;h<=i;h++)for(var c=0;c<=n;c++){var l=c/n*s,u=h/i*Math.PI*2,p=(t+e*Math.cos(u))*Math.cos(l),d=(t+e*Math.cos(u))*Math.sin(l),y=e*Math.sin(u);r.push(p,d,y)}for(var h=1;h<=i;h++)for(var c=1;c<=n;c++){var v=(n+1)*h+c-1,m=(n+1)*(h-1)+c-1,f=(n+1)*(h-1)+c,g=(n+1)*h+c;a.push(v,m,g),a.push(m,f,g)}return new o(r,a)}},{"../collision/AABB":21,"../math/Quaternion":47,"../math/Transform":48,"../math/Vec3":49,"../utils/Octree":69,"./Shape":62}],65:[function(t,e,i){function o(){n.call(this),this.iterations=10,this.tolerance=1e-7}e.exports=o;var n=(t("../math/Vec3"),t("../math/Quaternion"),t("./Solver"));o.prototype=new n;var s=[],r=[],a=[];o.prototype.solve=function(t,e){var i,o,n,h,c,l,u=0,p=this.iterations,d=this.tolerance*this.tolerance,y=this.equations,v=y.length,m=e.bodies,f=m.length,g=t;if(0!==v)for(var w=0;w!==f;w++)m[w].updateSolveMassProperties();var b=r,x=a,E=s;b.length=v,x.length=v,E.length=v;for(var w=0;w!==v;w++){var A=y[w];E[w]=0,x[w]=A.computeB(g),b[w]=1/A.computeC()}if(0!==v){for(var w=0;w!==f;w++){var C=m[w],B=C.vlambda,T=C.wlambda;B.set(0,0,0),T.set(0,0,0)}for(u=0;u!==p;u++){h=0;for(var R=0;R!==v;R++){var A=y[R];i=x[R],o=b[R],l=E[R],c=A.computeGWlambda(),n=o*(i-c-A.eps*l),l+nA.maxForce&&(n=A.maxForce-l),E[R]+=n,h+=n>0?n:-n,A.addToWlambda(n)}if(h*h=0;i--)e.children[i].data.length||e.children.splice(i,1);Array.prototype.push.apply(t,e.children)}}},{"../collision/AABB":21,"../math/Vec3":49}],70:[function(t,e,i){function o(){this.objects=[],this.type=Object}e.exports=o,o.prototype.release=function(){for(var t=arguments.length,e=0;e!==t;e++)this.objects.push(arguments[e]);return this},o.prototype.get=function(){return 0===this.objects.length?this.constructObject():this.objects.pop()},o.prototype.constructObject=function(){throw new Error("constructObject() not implemented in this Pool subclass yet!")},o.prototype.resize=function(t){for(var e=this.objects;e.length>t;)e.pop();for(;e.lengthe){var i=e;e=t,t=i}return this.data[t+"-"+e]},o.prototype.set=function(t,e,i){if(t>e){var o=e;e=t,t=o}var n=t+"-"+e;this.get(t,e)||this.data.keys.push(n),this.data[n]=i},o.prototype.reset=function(){for(var t=this.data,e=t.keys;e.length>0;){var i=e.pop();delete t[i]}}},{}],72:[function(t,e,i){function o(){}e.exports=o,o.defaults=function(t,e){t=t||{};for(var i in e)i in t||(t[i]=e[i]);return t}},{}],73:[function(t,e,i){function o(){s.call(this),this.type=n}e.exports=o;var n=t("../math/Vec3"),s=t("./Pool");o.prototype=new s,o.prototype.constructObject=function(){return new n}},{"../math/Vec3":49,"./Pool":70}],74:[function(t,e,i){function o(t){this.contactPointPool=[],this.frictionEquationPool=[],this.result=[],this.frictionResult=[],this.v3pool=new p,this.world=t,this.currentContactMaterial=null,this.enableFrictionReduction=!1}function n(t,e,i){for(var o=null,n=t.length,s=0;s!==n;s++){var r=t[s],a=O;t[(s+1)%n].vsub(r,a);var h=D;a.cross(e,h);var c=W;i.vsub(r,c);var l=h.dot(c);if(!(null===o||l>0&&o===!0||l<=0&&o===!1))return!1;null===o&&(o=l>0)}return!0}e.exports=o;var s=t("../collision/AABB"),r=t("../objects/Body"),a=t("../shapes/Shape"),h=t("../collision/Ray"),c=t("../math/Vec3"),l=t("../math/Transform"),u=(t("../shapes/ConvexPolyhedron"),t("../math/Quaternion")),p=(t("../solver/Solver"),t("../utils/Vec3Pool")),d=t("../equations/ContactEquation"),y=t("../equations/FrictionEquation");o.prototype.createContactEquation=function(t,e,i,o,n,s){var r;this.contactPointPool.length?(r=this.contactPointPool.pop(),r.bi=t,r.bj=e):r=new d(t,e),r.enabled=t.collisionResponse&&e.collisionResponse&&i.collisionResponse&&o.collisionResponse;var a=this.currentContactMaterial;r.restitution=a.restitution,r.setSpookParams(a.contactEquationStiffness,a.contactEquationRelaxation,this.world.dt);var h=i.material||t.material,c=o.material||e.material;return h&&c&&h.restitution>=0&&c.restitution>=0&&(r.restitution=h.restitution*c.restitution),r.si=n||i,r.sj=s||o,r},o.prototype.createFrictionEquationsFromContact=function(t,e){var i=t.bi,o=t.bj,n=t.si,s=t.sj,r=this.world,a=this.currentContactMaterial,h=a.friction,c=n.material||i.material,l=s.material||o.material;if(c&&l&&c.friction>=0&&l.friction>=0&&(h=c.friction*l.friction),h>0){var u=h*r.gravity.length(),p=i.invMass+o.invMass;p>0&&(p=1/p);var d=this.frictionEquationPool,v=d.length?d.pop():new y(i,o,u*p),m=d.length?d.pop():new y(i,o,u*p);return v.bi=m.bi=i,v.bj=m.bj=o,v.minForce=m.minForce=-u*p,v.maxForce=m.maxForce=u*p,v.ri.copy(t.ri),v.rj.copy(t.rj),m.ri.copy(t.ri),m.rj.copy(t.rj),t.ni.tangents(v.t,m.t),v.setSpookParams(a.frictionEquationStiffness,a.frictionEquationRelaxation,r.dt),m.setSpookParams(a.frictionEquationStiffness,a.frictionEquationRelaxation,r.dt),v.enabled=m.enabled=t.enabled,e.push(v,m),!0}return!1};var v=new c,m=new c,f=new c;o.prototype.createFrictionFromAverage=function(t){var e=this.result[this.result.length-1];if(this.createFrictionEquationsFromContact(e,this.frictionResult)&&1!==t){var i=this.frictionResult[this.frictionResult.length-2],o=this.frictionResult[this.frictionResult.length-1];v.setZero(),m.setZero(),f.setZero();for(var n=e.bi,s=(e.bj,0);s!==t;s++)e=this.result[this.result.length-1-s],e.bodyA!==n?(v.vadd(e.ni,v),m.vadd(e.ri,m),f.vadd(e.rj,f)):(v.vsub(e.ni,v),m.vadd(e.rj,m),f.vadd(e.ri,f));var r=1/t;m.scale(r,i.ri),f.scale(r,i.rj),o.ri.copy(i.ri),o.rj.copy(i.rj),v.normalize(),v.tangents(i.t,o.t)}};var g=new c,w=new c,b=new u,x=new u;o.prototype.getContacts=function(t,e,i,o,n,s,a){this.contactPointPool=n,this.frictionEquationPool=a,this.result=o,this.frictionResult=s;for(var h=b,c=x,l=g,u=w,p=0,d=t.length;p!==d;p++){var y=t[p],v=e[p],m=null;y.material&&v.material&&(m=i.getContactMaterial(y.material,v.material)||null);for(var f=y.type&r.KINEMATIC&&v.type&r.STATIC||y.type&r.STATIC&&v.type&r.KINEMATIC||y.type&r.KINEMATIC&&v.type&r.KINEMATIC,E=0;EA.boundingSphereRadius+B.boundingSphereRadius)){var T=null;A.material&&B.material&&(T=i.getContactMaterial(A.material,B.material)||null),this.currentContactMaterial=T||m||i.defaultContactMaterial;var R=this[A.type|B.type];if(R){var S=!1;S=A.type0&&W<0){f.vsub(d,g),m.copy(v),m.normalize(),K=g.dot(m),m.scale(K,g),g.vadd(d,g);var U=g.distanceTo(f);if(U0){var S=G,M=X;S.copy(p[(A+1)%3]),M.copy(p[(A+2)%3]);var k=S.norm(),P=M.norm();S.normalize(),M.normalize();var N=K.dot(S),L=K.dot(M);if(N-k&&L-P){var _=Math.abs(R-T-d);if((null===E||_0){for(var N=[],L=0,_=B.length;L!==_;L++){var z=p.get();r.vmult(v[B[L]],z),o.vadd(z,z),N.push(z)}if(n(N,T,i)){if(u)return!0;E=!0;var x=this.createContactEquation(a,h,t,e,c,l);T.mult(-m,x.ri),T.negate(x.ni);var I=p.get();T.mult(-k,I);var F=p.get();T.mult(-m,F),i.vsub(o,x.rj),x.rj.vadd(F,x.rj),x.rj.vadd(I,x.rj),x.rj.vadd(o,x.rj),x.rj.vsub(h.position,x.rj),x.ri.vadd(i,x.ri),x.ri.vsub(a.position,x.ri),p.release(I),p.release(F),this.result.push(x),this.createFrictionEquationsFromContact(x,this.frictionResult);for(var L=0,V=N.length;L!==V;L++)p.release(N[L]);return}for(var L=0;L!==B.length;L++){var q=p.get(),j=p.get();r.vmult(v[B[(L+1)%B.length]],q),r.vmult(v[B[(L+2)%B.length]],j),o.vadd(q,q),o.vadd(j,j);var H=et;j.vsub(q,H);var O=it;H.unit(O);var D=p.get(),W=p.get();i.vsub(q,W);var K=W.dot(O);O.mult(K,D),D.vadd(q,D);var U=p.get();if(D.vsub(i,U),K>0&&K*Kt.boundingSphereRadius+e.boundingSphereRadius)&&t.findSeparatingAxis(e,i,n,o,s,d,u,p)){var y=[],v=vt;t.clipAgainstHull(i,n,e,o,s,d,-100,100,y);for(var m=0,f=0;f!==y.length;f++){if(l)return!0;var g=this.createContactEquation(r,a,t,e,h,c),w=g.ri,b=g.rj;d.negate(g.ni),y[f].normal.negate(v),v.mult(y[f].depth,v),y[f].point.vadd(v,w),b.copy(y[f].point),w.vsub(i,w),b.vsub(o,b),w.vadd(i,w),w.vsub(r.position,w),b.vadd(o,b),b.vsub(a.position,b),this.result.push(g),m++,this.enableFrictionReduction||this.createFrictionEquationsFromContact(g,this.frictionResult)}this.enableFrictionReduction&&m&&this.createFrictionFromAverage(m)}};var mt=new c,ft=new c,gt=new c;o.prototype[a.types.PLANE|a.types.PARTICLE]=o.prototype.planeParticle=function(t,e,i,o,n,s,r,a,h,c,l){var u=mt;u.set(0,0,1),r.quaternion.vmult(u,u);var p=ft;o.vsub(r.position,p);var d=u.dot(p);if(d<=0){if(l)return!0;var y=this.createContactEquation(a,r,e,t,h,c);y.ni.copy(u),y.ni.negate(y.ni),y.ri.set(0,0,0);var v=gt;u.mult(u.dot(o),v),o.vsub(v,v),y.rj.copy(v),this.result.push(y),this.createFrictionEquationsFromContact(y,this.frictionResult)}};var wt=new c;o.prototype[a.types.PARTICLE|a.types.SPHERE]=o.prototype.sphereParticle=function(t,e,i,o,n,s,r,a,h,c,l){var u=wt;u.set(0,0,1),o.vsub(i,u);var p=u.norm2();if(p<=t.radius*t.radius){if(l)return!0;var d=this.createContactEquation(a,r,e,t,h,c);u.normalize(),d.rj.copy(u),d.rj.mult(t.radius,d.rj),d.ni.copy(u),d.ni.negate(d.ni),d.ri.set(0,0,0),this.result.push(d),this.createFrictionEquationsFromContact(d,this.frictionResult)}};var bt=new u,xt=new c,Et=(new c,new c),At=new c,Ct=new c;o.prototype[a.types.PARTICLE|a.types.CONVEXPOLYHEDRON]=o.prototype.convexParticle=function(t,e,i,o,n,s,r,a,h,c,l){var u=-1,p=Et,d=Ct,y=null,v=0,m=xt;if(m.copy(o),m.vsub(i,m),n.conjugate(bt),bt.vmult(m,m),t.pointIsInside(m)){t.worldVerticesNeedsUpdate&&t.computeWorldVertices(i,n),t.worldFaceNormalsNeedsUpdate&&t.computeWorldFaceNormals(n);for(var f=0,g=t.faces.length;f!==g;f++){var w=[t.worldVertices[t.faces[f][0]]],b=t.worldFaceNormals[f];o.vsub(w[0],At);var x=-b.dot(At);if(null===y||Math.abs(x)p.length||b>p[0].length)){g<0&&(g=0),w<0&&(w=0),b<0&&(b=0),x<0&&(x=0),g>=p.length&&(g=p.length-1),w>=p.length&&(w=p.length-1),x>=p[0].length&&(x=p[0].length-1),b>=p[0].length&&(b=p[0].length-1);var E=[];e.getRectMinMax(g,b,w,x,E);var A=E[0],C=E[1];if(!(f.z-y>C||f.z+yp.length||b>p[0].length)){f<0&&(f=0),g<0&&(g=0),w<0&&(w=0),b<0&&(b=0),f>=p.length&&(f=p.length-1),g>=p.length&&(g=p.length-1),b>=p[0].length&&(b=p[0].length-1),w>=p[0].length&&(w=p[0].length-1);var x=[];e.getRectMinMax(f,w,g,b,x);var E=x[0],A=x[1];if(!(m.z-d>A||m.z+d2)return}}}},{"../collision/AABB":21,"../collision/Ray":28,"../equations/ContactEquation":38,"../equations/FrictionEquation":40,"../math/Quaternion":47,"../math/Transform":48,"../math/Vec3":49,"../objects/Body":50,"../shapes/ConvexPolyhedron":57,"../shapes/Shape":62,"../solver/Solver":66,"../utils/Vec3Pool":73}],75:[function(t,e,i){function o(t){t=t||{},h.apply(this),this.dt=-1,this.allowSleep=!!t.allowSleep,this.contacts=[],this.frictionEquations=[],this.quatNormalizeSkip=void 0!==t.quatNormalizeSkip?t.quatNormalizeSkip:0,this.quatNormalizeFast=void 0!==t.quatNormalizeFast&&t.quatNormalizeFast, this.time=0,this.stepnumber=0,this.default_dt=1/60,this.nextId=0,this.gravity=new n,t.gravity&&this.gravity.copy(t.gravity),this.broadphase=void 0!==t.broadphase?t.broadphase:new g,this.bodies=[],this.solver=void 0!==t.solver?t.solver:new r,this.constraints=[],this.narrowphase=new a(this),this.collisionMatrix=new c,this.collisionMatrixPrevious=new c,this.bodyOverlapKeeper=new l,this.shapeOverlapKeeper=new l,this.materials=[],this.contactmaterials=[],this.contactMaterialTable=new y,this.defaultMaterial=new u("default"),this.defaultContactMaterial=new p(this.defaultMaterial,this.defaultMaterial,{friction:.3,restitution:0}),this.doProfiling=!1,this.profile={solve:0,makeContactConstraints:0,broadphase:0,integrate:0,narrowphase:0},this.accumulator=0,this.subsystems=[],this.addBodyEvent={type:"addBody",body:null},this.removeBodyEvent={type:"removeBody",body:null},this.idToBodyMap={},this.broadphase.setWorld(this)}e.exports=o;var n=(t("../shapes/Shape"),t("../math/Vec3")),s=t("../math/Quaternion"),r=t("../solver/GSSolver"),a=(t("../equations/ContactEquation"),t("../equations/FrictionEquation"),t("./Narrowphase")),h=t("../utils/EventTarget"),c=t("../collision/ArrayCollisionMatrix"),l=t("../collision/OverlapKeeper"),u=t("../material/Material"),p=t("../material/ContactMaterial"),d=t("../objects/Body"),y=t("../utils/TupleDictionary"),v=t("../collision/RaycastResult"),m=t("../collision/AABB"),f=t("../collision/Ray"),g=t("../collision/NaiveBroadphase");o.prototype=new h;var w=(new m,new f);if(o.prototype.getContactMaterial=function(t,e){return this.contactMaterialTable.get(t.id,e.id)},o.prototype.numObjects=function(){return this.bodies.length},o.prototype.collisionMatrixTick=function(){var t=this.collisionMatrixPrevious;this.collisionMatrixPrevious=this.collisionMatrix,this.collisionMatrix=t,this.collisionMatrix.reset(),this.bodyOverlapKeeper.tick(),this.shapeOverlapKeeper.tick()},o.prototype.add=o.prototype.addBody=function(t){this.bodies.indexOf(t)===-1&&(t.index=this.bodies.length,this.bodies.push(t),t.world=this,t.initPosition.copy(t.position),t.initVelocity.copy(t.velocity),t.timeLastSleepy=this.time,t instanceof d&&(t.initAngularVelocity.copy(t.angularVelocity),t.initQuaternion.copy(t.quaternion)),this.collisionMatrix.setNumObjects(this.bodies.length),this.addBodyEvent.body=t,this.idToBodyMap[t.id]=t,this.dispatchEvent(this.addBodyEvent))},o.prototype.addConstraint=function(t){this.constraints.push(t)},o.prototype.removeConstraint=function(t){var e=this.constraints.indexOf(t);e!==-1&&this.constraints.splice(e,1)},o.prototype.rayTest=function(t,e,i){i instanceof v?this.raycastClosest(t,e,{skipBackfaces:!0},i):this.raycastAll(t,e,{skipBackfaces:!0},i)},o.prototype.raycastAll=function(t,e,i,o){return i.mode=f.ALL,i.from=t,i.to=e,i.callback=o,w.intersectWorld(this,i)},o.prototype.raycastAny=function(t,e,i,o){return i.mode=f.ANY,i.from=t,i.to=e,i.result=o,w.intersectWorld(this,i)},o.prototype.raycastClosest=function(t,e,i,o){return i.mode=f.CLOSEST,i.from=t,i.to=e,i.result=o,w.intersectWorld(this,i)},o.prototype.remove=function(t){t.world=null;var e=this.bodies.length-1,i=this.bodies,o=i.indexOf(t);if(o!==-1){i.splice(o,1);for(var n=0;n!==i.length;n++)i[n].index=n;this.collisionMatrix.setNumObjects(e),this.removeBodyEvent.body=t,delete this.idToBodyMap[t.id],this.dispatchEvent(this.removeBodyEvent)}},o.prototype.removeBody=o.prototype.remove,o.prototype.getBodyById=function(t){return this.idToBodyMap[t]},o.prototype.getShapeById=function(t){for(var e=this.bodies,i=0,o=e.length;i=t&&o=0;N-=1)(P.bodyA===o[N]&&P.bodyB===n[N]||P.bodyB===o[N]&&P.bodyA===n[N])&&(o.splice(N,1),n.splice(N,1))}this.collisionMatrixTick(),c&&(e=performance.now());var L=C,_=i.length;for(g=0;g!==_;g++)L.push(i[g]);i.length=0;var z=this.frictionEquations.length;for(g=0;g!==z;g++)y.push(this.frictionEquations[g]);this.frictionEquations.length=0,this.narrowphase.getContacts(o,n,this,i,L,this.frictionEquations,y),c&&(l.narrowphase=performance.now()-e),c&&(e=performance.now());for(var g=0;g=0&&q.material.friction>=0&&(O=w.material.friction*q.material.friction),w.material.restitution>=0&&q.material.restitution>=0&&(P.restitution=w.material.restitution*q.material.restitution)),a.addEquation(P),w.allowSleep&&w.type===d.DYNAMIC&&w.sleepState===d.SLEEPING&&q.sleepState===d.AWAKE&&q.type!==d.STATIC){var D=q.velocity.norm2()+q.angularVelocity.norm2(),W=Math.pow(q.sleepSpeedLimit,2);D>=2*W&&(w._wakeUpAfterNarrowphase=!0)}if(q.allowSleep&&q.type===d.DYNAMIC&&q.sleepState===d.SLEEPING&&w.sleepState===d.AWAKE&&w.type!==d.STATIC){var K=w.velocity.norm2()+w.angularVelocity.norm2(),U=Math.pow(w.sleepSpeedLimit,2);K>=2*U&&(q._wakeUpAfterNarrowphase=!0)}this.collisionMatrix.set(w,q,!0),this.collisionMatrixPrevious.get(w,q)||(A.body=q,A.contact=P,w.dispatchEvent(A),A.body=w,q.dispatchEvent(A)),this.bodyOverlapKeeper.set(w.id,q.id),this.shapeOverlapKeeper.set(j.id,H.id)}for(this.emitContactEvents(),c&&(l.makeContactConstraints=performance.now()-e,e=performance.now()),g=0;g!==s;g++){var w=r[g];w._wakeUpAfterNarrowphase&&(w.wakeUp(),w._wakeUpAfterNarrowphase=!1)}var k=p.length;for(g=0;g!==k;g++){var P=p[g];P.update();for(var N=0,G=P.equations.length;N!==G;N++){var X=P.equations[N];a.addEquation(X)}}a.solve(t,this),c&&(l.solve=performance.now()-e),a.removeAllEquations();var Y=Math.pow;for(g=0;g!==s;g++){var w=r[g];if(w.type&u){var Q=Y(1-w.linearDamping,t),Z=w.velocity;Z.mult(Q,Z);var J=w.angularVelocity;if(J){var $=Y(1-w.angularDamping,t);J.mult($,J)}}}for(this.dispatchEvent(E),g=0;g!==s;g++){var w=r[g];w.preStep&&w.preStep.call(w)}c&&(e=performance.now());var tt=this.stepnumber,et=tt%(this.quatNormalizeSkip+1)===0,it=this.quatNormalizeFast;for(g=0;g!==s;g++)r[g].integrate(t,et,it);for(this.clearForces(),this.broadphase.dirty=!0,c&&(l.integrate=performance.now()-e),this.time+=t,this.stepnumber+=1,this.dispatchEvent(x),g=0;g!==s;g++){var w=r[g],ot=w.postStep;ot&&ot.call(w)}if(this.allowSleep)for(g=0;g!==s;g++)r[g].sleepTick(this.time)},o.prototype.emitContactEvents=function(){var t=[],e=[],i={type:"beginContact",bodyA:null,bodyB:null},o={type:"endContact",bodyA:null,bodyB:null},n={type:"beginShapeContact",bodyA:null,bodyB:null,shapeA:null,shapeB:null},s={type:"endShapeContact",bodyA:null,bodyB:null,shapeA:null,shapeB:null};return function(){var r=this.hasAnyEventListener("beginContact"),a=this.hasAnyEventListener("endContact");if((r||a)&&this.bodyOverlapKeeper.getDiff(t,e),r){for(var h=0,c=t.length;h0;)n(T.shift(),t)}function i(t,e){if(void 0!==t.normal)return t.normal;var i=e[t[0]],o=e[t[1]],n=e[t[2]];return v.subVectors(o,i),m.subVectors(n,i),b.crossVectors(m,v),b.normalize(),t.normal=b.clone()}function o(t,e,o){var n=o[t[0]],s=[],r=i(t,o);e.sort(function(t,e){return s[t.x/3]=void 0!==s[t.x/3]?s[t.x/3]:r.dot(g.subVectors(t,n)),s[e.x/3]=void 0!==s[e.x/3]?s[e.x/3]:r.dot(w.subVectors(e,n)),s[t.x/3]-s[e.x/3]});var a=e.length;for(1===a&&(s[e[0].x/3]=r.dot(g.subVectors(e[0],n)));a-- >0&&s[e[a].x/3]>0;);a+10&&(t.visiblePoints=e.splice(a+1))}function n(t,e){for(var n,s,r=B.length,a=[t],h=e.indexOf(t.visiblePoints.pop());r-- >0;)s=B[r],s!==t&&(n=i(s,e).dot(x.subVectors(e[h],e[s[0]])),n>0&&a.push(s));var c,l,u,p,d=r=a.length,y=1===r,v=[],m=0,f=[];[a[0][0],a[0][1],a[0][1],a[0][2],a[0][2],a[0][0]];if(1===a.length)s=a[0],v=[s[0],s[1],s[1],s[2],s[2],s[0]],T.indexOf(s)>-1&&T.splice(T.indexOf(s),1),s.visiblePoints&&(f=f.concat(s.visiblePoints)),B.splice(B.indexOf(s),1);else for(;r-- >0;){s=a[r],T.indexOf(s)>-1&&T.splice(T.indexOf(s),1),s.visiblePoints&&(f=f.concat(s.visiblePoints)),B.splice(B.indexOf(s),1);var g;for(cEdgeIndex=0;cEdgeIndex<3;){for(g=!1,d=a.length,u=s[cEdgeIndex],p=s[(cEdgeIndex+1)%3];d-- >0&&!g;)if(c=a[d],m=0,c!==s)for(;m<3&&!g;)l=m+1,g=c[m]===u&&c[l%3]===p||c[m]===p&&c[l%3]===u,m++;g&&!y||(v.push(u),v.push(p)),cEdgeIndex++}}r=0;for(var w,b=v.length/2;r=a?i.dot(i):e.dot(e)-r*r/a}}();return function(i){for(t(),points=i.vertices,B=[],T=[],x=s=points.length,r=points.slice(0,6),R=0;x-- >0;)points[x].xr[1].x&&(r[1]=points[x]),points[x].y0;)for(h=x-1;h-- >0;)R<(a=r[x].distanceToSquared(r[h]))&&(R=a,c=r[x],l=r[h]);for(x=6,R=0;x-- >0;)a=M(c,l,r[x]),R0;)a=Math.abs(points[x].dot(d)-y),R0;)o(g[x],b,points),void 0!==g[x].visiblePoints&&T.push(g[x]),B.push(g[x]);e(points);for(var k=B.length;k-- >0;)i.faces[k]=new THREE.Face3(B[k][2],B[k][1],B[k][0],B[k].normal);return i.normalsNeedUpdate=!0,i}}()},{}],78:[function(t,e,i){var o=.1;e.exports={schema:{enabled:{"default":!0},mode:{"default":"teleport",oneOf:["teleport","animate"]},animateSpeed:{"default":3}},init:function(){this.active=!0,this.checkpoint=null,this.offset=new THREE.Vector3,this.position=new THREE.Vector3,this.targetPosition=new THREE.Vector3},play:function(){this.active=!0},pause:function(){this.active=!1},setCheckpoint:function(t){this.active&&(this.checkpoint=t,"teleport"===this.data.mode&&(this.sync(),this.el.setAttribute("position",this.targetPosition)))},isVelocityActive:function(){return!(!this.active||!this.checkpoint)},getVelocity:function(){if(this.active){var t=this.data,e=this.offset,i=this.position,n=this.targetPosition;return this.sync(),i.distanceTo(n)s||Math.abs(o)>s},getVelocityDelta:function(){var t=this.getDpad(),e=this.getJoystick(0),i=t.x||e.x,o=t.y||e.y,n=new THREE.Vector3;return Math.abs(i)>s&&(n.x+=i),Math.abs(o)>s&&(n.z+=o),n},isRotationActive:function(){if(!this.data.enabled||!this.isConnected())return!1;var t=this.getJoystick(1);return Math.abs(t.x)>s||Math.abs(t.y)>s},getRotationDelta:function(){var t=this.getJoystick(1);return Math.abs(t.x)<=s&&(t.x=0),Math.abs(t.y)<=s&&(t.y=0),t},updateButtonState:function(){var t=this.getGamepad();if(this.data.enabled&&t)for(var e=0;en?(this.velocity.set(0,0,0),this.el.setAttribute("velocity",this.velocity)):this.updateVelocity(e))},updateRotation:function(t){for(var e,i,n=this.data,r=0,a=n.rotationControls.length;r1?i.setLength(this.data.movementAcceleration*t/1e3):i.multiplyScalar(this.data.movementAcceleration*t/1e3);var h=this.el.getAttribute("rotation");h&&(this.heading.set(s.fly?THREE.Math.degToRad(h.x):0,THREE.Math.degToRad(h.y),0),i.applyEuler(this.heading)),n.add(i)}this.el.setAttribute("velocity",n)}}},{}],86:[function(t,e,i){var o="__auto__";e.exports={schema:{clip:{"default":o},duration:{"default":0}},init:function(){this.model=null,this.mixer=null,this.activeAction=null;var t=this.el.getObject3D("mesh");t?this.load(t):this.el.addEventListener("model-loaded",function(t){this.load(t.detail.model)}.bind(this))},load:function(t){this.model=t,this.mixer=new THREE.AnimationMixer(t),this.data.clip&&this.update({})},remove:function(){this.mixer&&this.mixer.stopAllAction()},update:function(t){if(t){var e=this.data;e.clip!==t.clip&&(this.activeAction&&this.activeAction.stop(),e.clip&&this.playClip(e.clip)),this.activeAction&&e.duration&&this.activeAction.setDuration(e.duration)}},playClip:function(t){if(this.mixer){var e,i=this.data,n=this.model,s=n.animations||(n.geometry||{}).animations||[];if(s.length){if(e=t===o?s[0]:THREE.AnimationClip.findByName(s,i.clip),!e)return void console.error('[animation-mixer] Clip "%s" not found.',i.clip);this.activeAction=this.mixer.clipAction(e,n),this.activeAction.play()}}},tick:function(t,e){this.mixer&&!isNaN(e)&&this.mixer.update(e/1e3)}}},{}],87:[function(t,e,i){THREE.FBXLoader=t("../../lib/FBXLoader"),e.exports={schema:{src:{type:"asset"},crossorigin:{"default":""}},init:function(){this.model=null},update:function(){var t,e=this.data;e.src&&(this.remove(),t=new THREE.FBXLoader,e.crossorigin&&t.setCrossOrigin(e.crossorigin),t.load(e.src,this.load.bind(this)))},load:function(t){this.model=t,this.el.setObject3D("mesh",t),this.el.emit("model-loaded",{format:"fbx",model:t})},remove:function(){this.model&&this.el.removeObject3D("mesh")}}},{"../../lib/FBXLoader":3}],88:[function(t,e,i){e.exports={"animation-mixer":t("./animation-mixer"),"fbx-model":t("./fbx-model"),"json-model":t("./json-model"),"object-model":t("./object-model"),"ply-model":t("./ply-model"),"three-model":t("./three-model"),registerAll:function(t){this._registered||(t=t||window.AFRAME,t.components["animation-mixer"]||t.registerComponent("animation-mixer",this["animation-mixer"]),t.systems["ply-model"]||t.registerSystem("ply-model",this["ply-model"].System),t.components["ply-model"]||t.registerComponent("ply-model",this["ply-model"].Component),t.components["fbx-model"]||t.registerComponent("fbx-model",this["fbx-model"]),t.components["json-model"]||t.registerComponent("json-model",this["json-model"]),t.components["object-model"]||t.registerComponent("object-model",this["object-model"]),t.components["three-model"]||t.registerComponent("three-model",this["three-model"]),this._registered=!0)}}},{"./animation-mixer":86,"./fbx-model":87,"./json-model":89,"./object-model":90,"./ply-model":91,"./three-model":92}],89:[function(t,e,i){e.exports={schema:{src:{type:"asset"},crossorigin:{"default":""}},init:function(){this.model=null},update:function(){var t,e=this.data;e.src&&(this.remove(),t=new THREE.JSONLoader,e.crossorigin&&(t.crossOrigin=e.crossorigin),t.load(e.src,function(t,e){e.forEach(function(e){e.vertexColors=(t.faces[0]||{}).color?THREE.FaceColors:THREE.NoColors,e.skinning=!!(t.bones||[]).length,e.morphTargets=!!(t.morphTargets||[]).length,e.morphNormals=!!(t.morphNormals||[]).length});var i=(t.bones||[]).length?new THREE.SkinnedMesh(t,new THREE.MultiMaterial(e)):new THREE.Mesh(t,new THREE.MultiMaterial(e));this.load(i)}.bind(this)))},load:function(t){this.model=t,this.el.setObject3D("mesh",t),this.el.emit("model-loaded",{format:"json",model:t})},remove:function(){this.model&&this.el.removeObject3D("mesh")}}},{}],90:[function(t,e,i){e.exports={schema:{src:{type:"asset"},crossorigin:{"default":""}},init:function(){this.model=null},update:function(){var t,e=this.data;e.src&&(this.remove(),t=new THREE.ObjectLoader,e.crossorigin&&t.setCrossOrigin(e.crossorigin),t.load(e.src,function(t){t.traverse(function(t){t instanceof THREE.SkinnedMesh&&t.material&&(t.material.skinning=!!(t.geometry&&t.geometry.bones||[]).length)}),this.load(t)}.bind(this)))},load:function(t){this.model=t,this.el.setObject3D("mesh",t),this.el.emit("model-loaded",{format:"json",model:t})},remove:function(){this.model&&this.el.removeObject3D("mesh")}}},{}],91:[function(t,e,i){function o(t){return new THREE.Mesh(t,new THREE.MeshPhongMaterial({color:16777215,shading:THREE.FlatShading,vertexColors:THREE.VertexColors,shininess:0}))}THREE.PLYLoader=t("../../lib/PLYLoader"),e.exports.System={init:function(){this.cache={}},getOrLoadGeometry:function(t,e){var i=this.cache,o=i[t];return!e&&o?o:(i[t]=new Promise(function(e){var i=new THREE.PLYLoader;i.load(t,function(t){e(t)})}),i[t])}},e.exports.Component={schema:{skipCache:{type:"boolean","default":!1},src:{type:"asset"}},init:function(){this.model=null},update:function(){var t=this.data,e=this.el;return t.src?void this.system.getOrLoadGeometry(t.src,t.skipCache).then(function(t){var i=o(t);e.setObject3D("mesh",i),e.emit("model-loaded",{format:"ply",model:i})}):void console.warn("[%s] `src` property is required.",this.name)},remove:function(){this.model&&this.el.removeObject3D("mesh")}}},{"../../lib/PLYLoader":6}],92:[function(t,e,i){var o="__auto__";e.exports={deprecated:!0,schema:{src:{type:"asset"},loader:{"default":"object",oneOf:["object","json"]},enableAnimation:{"default":!0},animation:{"default":o},animationDuration:{"default":0},crossorigin:{"default":""}},init:function(){this.model=null,this.mixer=null,console.warn("[three-model] Component is deprecated. Use json-model or object-model instead.")},update:function(t){t=t||{};var e,i=this.data;if(!i.src)return void this.remove();if(Object.keys(t).length){var o=this.model&&this.model.activeAction;if(i.animation!==t.animation)return o&&o.stop(),void this.playAnimation();o&&i.enableAnimation!==o.isRunning()&&(i.enableAnimation?this.playAnimation():o.stop()),o&&i.animationDuration&&o.setDuration(i.animationDuration)}else if(this.remove(),"object"===i.loader)e=new THREE.ObjectLoader,i.crossorigin&&e.setCrossOrigin(i.crossorigin),e.load(i.src,function(t){t.traverse(function(e){e instanceof THREE.SkinnedMesh&&(t=e)}),t.material&&(t.material.skinning=!!(t.geometry&&t.geometry.bones||[]).length),this.load(t)}.bind(this));else{if("json"!==i.loader)throw new Error('[three-model] Invalid mode "%s".',i.mode);e=new THREE.JSONLoader,i.crossorigin&&(e.crossOrigin=i.crossorigin),e.load(i.src,function(t,e){e.forEach(function(e){e.vertexColors=(t.faces[0]||{}).color?THREE.FaceColors:THREE.NoColors,e.skinning=!!(t.bones||[]).length,e.morphTargets=!!(t.morphTargets||[]).length,e.morphNormals=!!(t.morphNormals||[]).length});var i=(t.bones||[]).length?new THREE.SkinnedMesh(t,new THREE.MultiMaterial(e)):new THREE.Mesh(t,new THREE.MultiMaterial(e));this.load(i)}.bind(this))}},load:function(t){this.model=t,this.mixer=new THREE.AnimationMixer(this.model),this.el.setObject3D("mesh",t),this.el.emit("model-loaded",{format:"three",model:t}),this.data.enableAnimation&&this.playAnimation()},playAnimation:function(){var t,e=this.data,i=this.model.animations||this.model.geometry.animations||[];if(e.enableAnimation&&e.animation&&i.length){if(t=e.animation===o?i[0]:THREE.AnimationClip.findByName(i,e.animation),!t)return void console.error('[three-model] Animation "%s" not found.',e.animation);this.model.activeAction=this.mixer.clipAction(t,this.model),e.animationDuration&&this.model.activeAction.setDuration(e.animationDuration),this.model.activeAction.play()}},remove:function(){this.mixer&&this.mixer.stopAllAction(),this.model&&this.el.removeObject3D("mesh")},tick:function(t,e){this.mixer&&!isNaN(e)&&this.mixer.update(e/1e3)}}},{}],93:[function(t,e,i){e.exports={schema:{defaultRotation:{type:"vec3"},enableDefaultRotation:{"default":!1}},init:function(){this.active=!1,this.targetEl=null,this.fire=this.fire.bind(this)},play:function(){this.el.addEventListener("click",this.fire)},pause:function(){this.el.removeEventListener("click",this.fire)},remove:function(){this.pause()},fire:function(){var t=this.el.sceneEl.querySelector("[checkpoint-controls]");if(!t)throw new Error("No `checkpoint-controls` component found.");t.components["checkpoint-controls"].setCheckpoint(this.el)}}},{}],94:[function(t,e,i){e.exports={init:function(){this.GRABBED_STATE="grabbed",this.grabbing=!1,this.hitEl=null,this.physics=this.el.sceneEl.systems.physics,this.constraint=null,this.onHit=this.onHit.bind(this),this.onGripOpen=this.onGripOpen.bind(this),this.onGripClose=this.onGripClose.bind(this)},play:function(){var t=this.el;t.addEventListener("hit",this.onHit),t.addEventListener("gripdown",this.onGripClose),t.addEventListener("gripup",this.onGripOpen),t.addEventListener("trackpaddown",this.onGripClose),t.addEventListener("trackpadup",this.onGripOpen),t.addEventListener("triggerdown",this.onGripClose),t.addEventListener("triggerup",this.onGripOpen)},pause:function(){var t=this.el;t.removeEventListener("hit",this.onHit),t.removeEventListener("gripdown",this.onGripClose),t.removeEventListener("gripup",this.onGripOpen),t.removeEventListener("trackpaddown",this.onGripClose),t.removeEventListener("trackpadup",this.onGripOpen),t.removeEventListener("triggerdown",this.onGripClose),t.removeEventListener("triggerup",this.onGripOpen)},onGripClose:function(t){this.grabbing=!0},onGripOpen:function(t){var e=this.hitEl;this.grabbing=!1,e&&(e.removeState(this.GRABBED_STATE),this.hitEl=void 0,this.physics.world.removeConstraint(this.constraint),this.constraint=null)},onHit:function(t){var e=t.detail.el;e&&!e.is(this.GRABBED_STATE)&&this.grabbing&&!this.hitEl&&(e.addState(this.GRABBED_STATE),this.hitEl=e,this.constraint=new CANNON.LockConstraint(this.el.body,e.body),this.physics.world.addConstraint(this.constraint))}}},{}],95:[function(t,e,i){var o=t("aframe-physics-system");e.exports={checkpoint:t("./checkpoint"),grab:t("./grab"),"jump-ability":t("./jump-ability"),"kinematic-body":t("./kinematic-body"),"sphere-collider":t("./sphere-collider"),"toggle-velocity":t("./toggle-velocity"),registerAll:function(t){this._registered||(t=t||window.AFRAME,o.registerAll(),t.components.checkpoint||t.registerComponent("checkpoint",this.checkpoint),t.components.grab||t.registerComponent("grab",this.grab),t.components["jump-ability"]||t.registerComponent("jump-ability",this["jump-ability"]),t.components["kinematic-body"]||t.registerComponent("kinematic-body",this["kinematic-body"]),t.components["sphere-collider"]||t.registerComponent("sphere-collider",this["sphere-collider"]),t.components["toggle-velocity"]||t.registerComponent("toggle-velocity",this["toggle-velocity"]),this._registered=!0)}}},{"./checkpoint":93,"./grab":94,"./jump-ability":96,"./kinematic-body":97,"./sphere-collider":98,"./toggle-velocity":99,"aframe-physics-system":8}],96:[function(t,e,i){var o=-9.8,n=-15;e.exports={dependencies:["velocity"],schema:{on:{"default":"keydown:Space gamepadbuttondown:0"},playerHeight:{"default":1.764},maxJumps:{"default":1},distance:{"default":5},soundJump:{"default":""},soundLand:{"default":""},debug:{"default":!1}},init:function(){this.velocity=0,this.numJumps=0;var t=this.beginJump.bind(this),e=this.data.on.split(" ");this.bindings={};for(var i=0;i.5&&(a=c.id===d.bi.id?Math.abs(d.rj.y+d.bj.position.y):Math.abs(d.ri.y+d.bi.position.y),a>p&&(p=a,o.copy(i),h=c.id===d.bi.id?d.bj:d.bi))}if(e.copy(t).normalize(),h&&e.y<.5?(l.enableSlopes?o.y<1-n&&o.copy(this.raycastToGround(h,o)):o.set(0,1,0),t=t.projectOnPlane(o)):t.add(this.system.world.gravity.scale(4*r/1e3)),h&&h.el&&h.el.components.velocity){var v=h.el.getAttribute("velocity");c.position.copy({x:c.position.x+v.x*r/1e3,y:c.position.y+v.y*r/1e3,z:c.position.z+v.z*r/1e3}),this.el.setAttribute("position",c.position)}c.velocity.copy(t),this.el.setAttribute("velocity",t)}}}(),raycastToGround:function(t,e){var i,n,s=this.body.position,r=this.body.position.clone();return r.y-=this.data.height,i=new o.Ray(s,r),i._updateDirection(),i.intersectBody(t),i.hasHit?(n=i.result.hitNormalWorld,Math.abs(n.y)>Math.abs(e.y)?n:e):e}}},{}],98:[function(t,e,i){e.exports={schema:{objects:{"default":""},state:{"default":"collided"},radius:{"default":.05}},init:function(){this.els=[],this.collisions=[]},update:function(){var t,e=this.data;t=e.objects?this.el.sceneEl.querySelectorAll(e.objects):this.el.sceneEl.children,this.els=Array.prototype.slice.call(t)},tick:function(){var t=new THREE.Vector3,e=new THREE.Vector3;return function(){function i(i){var o,n,r;i.isEntity&&(n=i.getObject3D("mesh"),n&&n.geometry&&(n.getWorldPosition(e),n.geometry.computeBoundingSphere(),o=n.geometry.boundingSphere.radius,r=t.distanceTo(e),re.distance?1:-1}).forEach(o),0===a.length&&n.emit("hit",{el:null}),this.collisions.filter(function(t){return a.indexOf(t)===-1}).forEach(function(t){t.el.removeState(s.state)}),this.collisions=a)}}()}},{}],99:[function(t,e,i){e.exports={dependencies:["velocity"],schema:{axis:{"default":"x",oneOf:["x","y","z"]},min:{"default":0},max:{"default":0},speed:{"default":1}},init:function(){var t={x:0,y:0,z:0};t[this.data.axis]=this.data.speed,this.el.setAttribute("velocity",t),this.el.sceneEl.addBehavior&&this.el.sceneEl.addBehavior(this)},remove:function(){},update:function(){this.tick()},tick:function(){var t=this.data,e=this.el.getAttribute("velocity"),i=this.el.getAttribute("position");e[t.axis]>0&&i[t.axis]>t.max?(e[t.axis]=-t.speed,this.el.setAttribute("velocity",e)):e[t.axis]<0&&i[t.axis]