!function t(e,i,o){function n(r,a){if(!i[r]){if(!e[r]){var l="function"==typeof require&&require;if(!a&&l)return l(r,!0);if(s)return s(r,!0);var h=new Error("Cannot find module '"+r+"'");throw h.code="MODULE_NOT_FOUND",h}var c=i[r]={exports:{}};e[r][0].call(c.exports,function(t){var i=e[r][1][t];return n(i||t)},c,c.exports,t,e,i,o)}return i[r].exports}for(var s="function"==typeof require&&require,r=0;r0&&i.has(h[0].ID))n=i.get(h[0].ID);else if(void 0!==l&&"/"!==l[0]&&null===l.match(/^[a-zA-Z]:/))n=l;else{var c=a.split(/[\\\/]/);n=c.length>0?c[c.length-1]:a}var u=e.path;0!==n.indexOf("blob:")&&0!==n.indexOf("data:")||e.setPath(void 0);var p=e.load(n);p.name=r,p.FBX_ID=s;var d=t.properties.WrapModeU,f=t.properties.WrapModeV,v=void 0!==d?d.value:0,m=void 0!==f?f.value:0;return p.wrapS=0===v?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,p.wrapT=0===m?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,e.setPath(u),p}(s[r],e,i,o);n.set(parseInt(r),a)}}return n}function o(t,e,i){var o=new Map;if("Material"in t.Objects.subNodes){var n=t.Objects.subNodes.Material;for(var s in n){var r=function(t,e,i){var o=t.id,n=t.attrName,s=t.properties.ShadingModel;"object"==typeof s&&(s=s.value);if(!i.has(o))return null;var r,a=i.get(o).children,l=function(t,e,i){var o={};t.Diffuse&&(o.color=C(t.Diffuse));t.Specular&&(o.specular=C(t.Specular));t.Shininess&&(o.shininess=t.Shininess.value);t.Emissive&&(o.emissive=C(t.Emissive));t.EmissiveFactor&&(o.emissiveIntensity=t.EmissiveFactor.value);t.Opacity&&(o.opacity=t.Opacity.value);o.opacity<1&&(o.transparent=!0);for(var n=0,s=i.length;n4){A||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),A=!0);var N=[0,0,0,0],_=[0,0,0,0];L.forEach(function(t,e){var i=t,o=k[e];_.forEach(function(t,e,n){if(i>t){n[e]=i,i=t;var s=N[e];N[e]=o,o=s}})}),k=N,L=_}for(W=L.length;W<4;++W)L[W]=0,k[W]=0;z.skinWeights.fromArray(L),z.skinIndices.fromArray(k)}if(a&&z.normal.fromArray(r(R,C,M,a)),l&&z.uv.fromArray(r(R,C,M,l)),h&&z.color.fromArray(r(R,C,M,h)),S.push(z),B){var F=new f;if(F.genTrianglesFromVertices(S),void 0!==c){var V=r(R,C,M,c);F.materialIndex=V[0]}else F.materialIndex=0;i.faces.push(F),S=[],C++,B=!1}}var q=i.flattenToBuffers(),D=new THREE.BufferGeometry;D.name=t.name,D.addAttribute("position",new THREE.Float32BufferAttribute(q.vertexBuffer,3)),q.normalBuffer.length>0&&D.addAttribute("normal",new THREE.Float32BufferAttribute(q.normalBuffer,3));q.uvBuffer.length>0&&D.addAttribute("uv",new THREE.Float32BufferAttribute(q.uvBuffer,2));o.LayerElementColor&&D.addAttribute("color",new THREE.Float32BufferAttribute(q.colorBuffer,3));e&&(D.addAttribute("skinIndex",new THREE.Float32BufferAttribute(q.skinIndexBuffer,4)),D.addAttribute("skinWeight",new THREE.Float32BufferAttribute(q.skinWeightBuffer,4)),D.FBX_Deformer=e);for(var O=q.materialIndexBuffer,H=O[0],j=0,W=0;W1?C=R:R.length>0?C=R[0]:(C=new THREE.MeshStandardMaterial({color:3342591}),R.push(C)),"color"in b.attributes)for(var L=0,P=R.length;L-1){a[G].add(m);break}}null===m.parent&&s.add(m)}s.updateMatrixWorld(!0);var K=t.Objects.subNodes.Pose;for(var p in K)if("BindPose"===K[p].attrType){K=K[p];break}if(K)for(var X=K.subNodes.PoseNode,Y=new Map,Q=0,Z=X.length;Q=0;--l){var h=B(o.skeleton.bones,function(t){return t.FBX_ID===a[l].ID});if(h>-1){s.containerBoneID=h,s.containerID=a[l].ID;var c=n[s.containerID.toString()];"PreRotation"in c.properties&&(s.preRotations=S(c.properties.PreRotation).multiplyScalar(Math.PI/180));break}}return s}(t,o[c],e,i);h.push(u)}for(var p=new Map,d=0;dL.min&&(a.stacks[c]={name:r[c].attrName,layers:k,length:L.max-L.min,frames:30*(L.max-L.min)})}return a}(t,e,s)),s}function l(t,e){t.x&&h(t.x,e),t.y&&h(t.y,e),t.z&&h(t.z,e)}function h(t,e){e.max=t.times[t.times.length-1]>e.max?t.times[t.times.length-1]:e.max,e.min=t.times[0]=e.length&&e===R(t,0,e.length)}(e))l=(new y).parse(e);else{var h=R(e);if(!function(t){function e(e){var i=t[e-1];return t=t.slice(o+e),o++,i}for(var i=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],o=0,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){if(n.match(/Properties(\d)+/))return void this.parseNodeSpecialProperty(t,e,i)}if("C"===e){var s=i.split(",").slice(1),r=parseInt(s[0]),a=parseInt(s[1]),l=i.split(",").slice(3);e="connections",z(i=[r,a],l),void 0===o.properties[e]&&(o.properties[e]=[])}if("Node"===e){var h=parseInt(i);o.properties.id=h,o.id=h}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){for(var o=i.split('",'),n=0,s=o.length;n=t.size():t.getOffset()+160+16>=t.size()},parseNode:function(t,e){var i=e>=7500?t.getUint64():t.getUint32(),o=e>=7500?t.getUint64():t.getUint32(),n=(e>=7500?t.getUint64():t.getUint32(),t.getUint8()),s=t.getString(n);if(0===i)return null;for(var r=[],a=0;a0?r[0]:"",h=r.length>1?r[1]:"",c=r.length>2?r[2]:"",u={},p={},d=!1;for(1===o&&t.getOffset()===i&&(d=!0);i>t.getOffset();){var f=this.parseNode(t,e);if(null!==f)if(!0!==f.singleProperty)if("Connections"!==s||"C"!==f.name)if(f.name.match(/^Properties\d+$/))for(var v=Object.keys(f.properties),a=0,m=v.length;a0;){var i=this.getUint8();if(t--,0===i)break;e+=String.fromCharCode(i)}return this.skip(t),e}}),Object.assign(w.prototype,{add:function(t,e){this[t]=e},searchConnectionParent:function(t){if(void 0===this.__cache_search_connection_parent&&(this.__cache_search_connection_parent=[]),void 0!==this.__cache_search_connection_parent[t])return this.__cache_search_connection_parent[t];this.__cache_search_connection_parent[t]=[];for(var e=this.Connections.properties.connections,i=[],o=0;o0?(z(this.__cache_search_connection_parent[t],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?(z(this.__cache_search_connection_children[t],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;n=o.elements[r].count&&(r++,a=0);var c=this.parseASCIIElement(o.elements[r].properties,h);this.handleElement(i,o.elements[r].name,c),a++}}return this.postProcess(i)},postProcess:function(t){if(t.useColor){for(var e=0;ee;e++)i.push(this._createVertex(e));for(this.cellShape=new THREE.Shape,this.cellShape.moveTo(i[0].x,i[0].y),e=1;6>e;e++)this.cellShape.lineTo(i[e].x,i[e].y);this.cellShape.lineTo(i[0].x,i[0].y),this.cellShape.autoClose=!0,this.cellGeo=new THREE.Geometry,this.cellGeo.vertices=i,this.cellGeo.verticesNeedUpdate=!0,this.cellShapeGeo=new THREE.ShapeGeometry(this.cellShape),this._cellWidth=2*this.cellSize,this._cellLength=.5*o.SQRT3*this._cellWidth,this._hashDelimeter=".",this._directions=[new o.Cell(1,-1,0),new o.Cell(1,0,-1),new o.Cell(0,1,-1),new o.Cell(-1,1,0),new o.Cell(-1,0,1),new o.Cell(0,-1,1)],this._diagonals=[new o.Cell(2,-1,-1),new o.Cell(1,1,-2),new o.Cell(-1,2,-1),new o.Cell(-2,1,1),new o.Cell(-1,-1,2),new o.Cell(1,-2,1)],this._list=[],this._vec3=new THREE.Vector3,this._cel=new o.Cell,this._conversionVec=new THREE.Vector3,this._geoCache=[],this._matCache=[]},o.HexGrid.TWO_THIRDS=2/3,o.HexGrid.prototype={cellToPixel:function(t){return this._vec3.x=t.q*this._cellWidth*.75,this._vec3.y=t.h,this._vec3.z=-(t.s-t.r)*this._cellLength*.5,this._vec3},pixelToCell:function(t){var e=t.x*(o.HexGrid.TWO_THIRDS/this.cellSize),i=(-t.x/3+o.SQRT3/3*t.z)/this.cellSize;return this._cel.set(e,i,-e-i),this._cubeRound(this._cel)},getCellAt:function(t){var e=t.x*(o.HexGrid.TWO_THIRDS/this.cellSize),i=(-t.x/3+o.SQRT3/3*t.z)/this.cellSize;return this._cel.set(e,i,-e-i),this._cubeRound(this._cel),this.cells[this.cellToHash(this._cel)]},getNeighbors:function(t,e,i){var o,n,s=this._directions.length;for(this._list.length=0,o=0;s>o;o++)this._cel.copy(t),this._cel.add(this._directions[o]),!(n=this.cells[this.cellToHash(this._cel)])||i&&!i(t,n)||this._list.push(n);if(e)for(o=0;s>o;o++)this._cel.copy(t),this._cel.add(this._diagonals[o]),!(n=this.cells[this.cellToHash(this._cel)])||i&&!i(t,n)||this._list.push(n);return this._list},getRandomCell:function(){var t,e=0,i=o.Tools.randomInt(0,this.numCells);for(t in this.cells){if(e===i)return this.cells[t];e++}return this.cells[t]},cellToHash:function(t){return t.q+this._hashDelimeter+t.r+this._hashDelimeter+t.s},distance:function(t,e){var i=Math.max(Math.abs(t.q-e.q),Math.abs(t.r-e.r),Math.abs(t.s-e.s));return i+=e.h-t.h},clearPath:function(){var t,e;for(t in this.cells)e=this.cells[t],e._calcCost=0,e._priority=0,e._parent=null,e._visited=!1},traverse:function(t){var e;for(e in this.cells)t(this.cells[e])},generateTile:function(t,e,i){var n=Math.abs(t.h);1>n&&(n=1);var s=this._geoCache[n];s||(this.extrudeSettings.amount=n,s=new THREE.ExtrudeGeometry(this.cellShape,this.extrudeSettings),this._geoCache[n]=s);var r=new o.Tile({size:this.cellSize,scale:e,cell:t,geometry:s,material:i});return t.tile=r,r},generateTiles:function(t){t=t||{};var e=[],i={tileScale:.95,cellSize:this.cellSize,material:null,extrudeSettings:{amount:1,bevelEnabled:!0,bevelSegments:1,steps:1,bevelSize:.5,bevelThickness:.5}};i=o.Tools.merge(i,t),this.cellSize=i.cellSize,this._cellWidth=2*this.cellSize,this._cellLength=.5*o.SQRT3*this._cellWidth,this.autogenerated=!0,this.extrudeSettings=i.extrudeSettings;var n,s,r;for(n in this.cells)r=this.cells[n],(s=this.generateTile(r,i.tileScale,i.material)).position.copy(this.cellToPixel(r)),s.position.y=0,e.push(s);return e},generateTilePoly:function(t){t||(t=new THREE.MeshBasicMaterial({color:2405631}));var e=new THREE.Mesh(this.cellShapeGeo,t);return this._vec3.set(1,0,0),e.rotateOnAxis(this._vec3,o.PI/2),e},generate:function(t){t=t||{},this.size=void 0===t.size?this.size:t.size;var e,i,n,s;for(e=-this.size;en;n++)for(s=-t;t+1>s;s++)if(r=-n-s,Math.abs(n)<=t&&Math.abs(s)<=t&&Math.abs(r)<=t){this._cel.set(n,s,r);var l=new THREE.Line(a,i);l.position.copy(this.cellToPixel(this._cel)),l.rotation.x=90*o.DEG_TO_RAD,e.add(l)}},add:function(t){var e=this.cellToHash(t);if(!this.cells[e])return this.cells[e]=t,this.numCells++,t},remove:function(t){var e=this.cellToHash(t);this.cells[e]&&(delete this.cells[e],this.numCells--)},dispose:function(){this.cells=null,this.numCells=0,this.cellShape=null,this.cellGeo.dispose(),this.cellGeo=null,this.cellShapeGeo.dispose(),this.cellShapeGeo=null,this._list=null,this._vec3=null,this._conversionVec=null,this._geoCache=null,this._matCache=null},load:function(t,e,i){var n=this;o.Tools.getJSON({url:t,callback:function(t){n.fromJSON(t),e.call(i||null,t)},cache:!1,scope:n})},fromJSON:function(t){var e,i,n=t.cells;for(this.cells={},this.numCells=0,this.size=t.size,this.cellSize=t.cellSize,this._cellWidth=2*this.cellSize,this._cellLength=.5*o.SQRT3*this._cellWidth,this.extrudeSettings=t.extrudeSettings,this.autogenerated=t.autogenerated,e=0;es&&n>r?e=-i-o:s>r?i=-e-o:o=-e-i,this._cel.set(e,i,o)}},o.HexGrid.prototype.constructor=o.HexGrid,o.SqrGrid=function(t){t=t||{},this.type=o.SQR,this.size=5,this.cellSize=void 0===t.cellSize?10:t.cellSize,this.cells={},this.numCells=0,this.extrudeSettings=null,this.autogenerated=!1;var e=[];e.push(new THREE.Vector3),e.push(new THREE.Vector3(-this.cellSize,this.cellSize)),e.push(new THREE.Vector3(this.cellSize,this.cellSize)),e.push(new THREE.Vector3(this.cellSize,-this.cellSize)),this.cellShape=new THREE.Shape,this.cellShape.moveTo(-this.cellSize,-this.cellSize),this.cellShape.lineTo(-this.cellSize,this.cellSize),this.cellShape.lineTo(this.cellSize,this.cellSize),this.cellShape.lineTo(this.cellSize,-this.cellSize),this.cellShape.lineTo(-this.cellSize,-this.cellSize),this.cellGeo=new THREE.Geometry,this.cellGeo.vertices=e,this.cellGeo.verticesNeedUpdate=!0,this.cellShapeGeo=new THREE.ShapeGeometry(this.cellShape),this._fullCellSize=2*this.cellSize,this._hashDelimeter=".",this._directions=[new o.Cell(1,0,0),new o.Cell(0,-1,0),new o.Cell(-1,0,0),new o.Cell(0,1,0)],this._diagonals=[new o.Cell(-1,-1,0),new o.Cell(-1,1,0),new o.Cell(1,1,0),new o.Cell(1,-1,0)],this._list=[],this._vec3=new THREE.Vector3,this._cel=new o.Cell,this._conversionVec=new THREE.Vector3,this._geoCache=[],this._matCache=[]},o.SqrGrid.prototype={cellToPixel:function(t){return this._vec3.x=t.q*this._fullCellSize,this._vec3.y=t.h,this._vec3.z=t.r*this._fullCellSize,this._vec3},pixelToCell:function(t){var e=Math.round(t.x/this._fullCellSize),i=Math.round(t.z/this._fullCellSize);return this._cel.set(e,i,0)},getCellAt:function(t){var e=Math.round(t.x/this._fullCellSize),i=Math.round(t.z/this._fullCellSize);return this._cel.set(e,i),this.cells[this.cellToHash(this._cel)]},getNeighbors:function(t,e,i){var o,n,s=this._directions.length;for(this._list.length=0,o=0;s>o;o++)this._cel.copy(t),this._cel.add(this._directions[o]),!(n=this.cells[this.cellToHash(this._cel)])||i&&!i(t,n)||this._list.push(n);if(e)for(o=0;s>o;o++)this._cel.copy(t),this._cel.add(this._diagonals[o]),!(n=this.cells[this.cellToHash(this._cel)])||i&&!i(t,n)||this._list.push(n);return this._list},getRandomCell:function(){var t,e=0,i=o.Tools.randomInt(0,this.numCells);for(t in this.cells){if(e===i)return this.cells[t];e++}return this.cells[t]},cellToHash:function(t){return t.q+this._hashDelimeter+t.r},distance:function(t,e){var i=Math.max(Math.abs(t.q-e.q),Math.abs(t.r-e.r));return i+=e.h-t.h},clearPath:function(){var t,e;for(t in this.cells)e=this.cells[t],e._calcCost=0,e._priority=0,e._parent=null,e._visited=!1},traverse:function(t){var e;for(e in this.cells)t(this.cells[e])},generateTile:function(t,e,i){var n=Math.abs(t.h);1>n&&(n=1);var s=this._geoCache[n];s||(this.extrudeSettings.amount=n,s=new THREE.ExtrudeGeometry(this.cellShape,this.extrudeSettings),this._geoCache[n]=s);var r=new o.Tile({size:this.cellSize,scale:e,cell:t,geometry:s,material:i});return t.tile=r,r},generateTiles:function(t){t=t||{};var e=[],i={tileScale:.95,cellSize:this.cellSize,material:null,extrudeSettings:{amount:1,bevelEnabled:!0,bevelSegments:1,steps:1,bevelSize:.5,bevelThickness:.5}};i=o.Tools.merge(i,t),this.cellSize=i.cellSize,this._fullCellSize=2*this.cellSize,this.autogenerated=!0,this.extrudeSettings=i.extrudeSettings;var n,s,r;for(n in this.cells)r=this.cells[n],(s=this.generateTile(r,i.tileScale,i.material)).position.copy(this.cellToPixel(r)),s.position.y=0,e.push(s);return e},generateTilePoly:function(t){t||(t=new THREE.MeshBasicMaterial({color:2405631}));var e=new THREE.Mesh(this.cellShapeGeo,t);return this._vec3.set(1,0,0),e.rotateOnAxis(this._vec3,o.PI/2),e},generate:function(t){t=t||{},this.size=void 0===t.size?this.size:t.size;var e,i,n,s=Math.ceil(this.size/2);for(e=-s;s>e;e++)for(i=-s;s>i;i++)n=new o.Cell(e,i+1),this.add(n)},generateOverlay:function(t,e,i){var n,s,r=Math.ceil(t/2);for(n=-r;r>n;n++)for(s=-r;r>s;s++){this._cel.set(n,s);var a=new THREE.Line(this.cellGeo,i);a.position.copy(this.cellToPixel(this._cel)),a.rotation.x=90*o.DEG_TO_RAD,e.add(a)}},add:function(t){var e=this.cellToHash(t);if(!this.cells[e])return this.cells[e]=t,this.numCells++,t},remove:function(t){var e=this.cellToHash(t);this.cells[e]&&(delete this.cells[e],this.numCells--)},dispose:function(){this.cells=null,this.numCells=0,this.cellShape=null,this.cellGeo.dispose(),this.cellGeo=null,this.cellShapeGeo.dispose(),this.cellShapeGeo=null,this._list=null,this._vec3=null,this._conversionVec=null,this._geoCache=null,this._matCache=null},load:function(t,e,i){o.Tools.getJSON({url:t,callback:function(t){this.fromJSON(t),e.call(i||null,t)},cache:!1,scope:this})},fromJSON:function(t){var e,i,n=t.cells;for(this.cells={},this.numCells=0,this.size=t.size,this.cellSize=t.cellSize,this._fullCellSize=2*this.cellSize,this.extrudeSettings=t.extrudeSettings,this.autogenerated=t.autogenerated,e=0;ee;e++)this.add(o[e])},remove:function(t){var e=this.getNode(t);return!(!e||e.free)&&(e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),e.prev||(this.first=e.next),e.next||(this.last=e.prev),e.free=!0,e.prev=null,e.next=null,this.length--,!0)},shift:function(){var t=this.first;return 0===this.length?null:(t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),this.first=t.next,t.next||(this.last=null),t.free=!0,t.prev=null,t.next=null,this.length--,t.obj)},pop:function(){var t=this.last;return 0===this.length?null:(t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),this.last=t.prev,t.prev||(this.first=null),t.free=!0,t.prev=null,t.next=null,this.length--,t.obj)},concat:function(t){for(var e=t.first;e;)this.add(e.obj),e=e.next},clear:function(){for(var t=this.first;t;)t.free=!0,t=t.next;this.first=null,this.length=0},dispose:function(){for(var t=this.first;t;)t.obj=null,t=t.next;this.first=null,this.objToNodeMap=null},dump:function(t){console.log("===================="+t+"=====================");for(var e=this.first;e;)console.log("{"+e.obj.toString()+"} previous="+(e.prev?e.prev.obj:"NULL")),e=e.next();console.log("==================================="),console.log("Last: {"+(this.last?this.last.obj:"NULL")+"} First: {"+(this.first?this.first.obj:"NULL")+"}")}}).constructor=t,o.LinkedList=t}(),function(){var t=function(t,e,i,o,n){this._listener=e,this.isOnce=i,this.context=o,this.signal=t,this._priority=n||0};(t.prototype={active:!0,params:null,execute:function(t){var e,i;return this.active&&this._listener&&(i=this.params?this.params.concat(t):t,e=this._listener.apply(this.context,i),this.isOnce&&this.detach()),e},detach:function(){return this.isBound()?this.signal.remove(this._listener,this.context):null},isBound:function(){return!!this.signal&&!!this._listener},_destroy:function(){delete this.signal,delete this._listener,delete this.context},toString:function(){return"[SignalBinding isOnce:"+this.isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}}).constructor=t;var e=function(){this._bindings=[],this._prevParams=null;var t=this;this.dispatch=function(){e.prototype.dispatch.apply(t,arguments)}};e.prototype={memorize:!1,_shouldPropagate:!0,active:!0,validateListener:function(t,e){if("function"!=typeof t)throw new Error("Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}",e))},_registerListener:function(e,i,o,n){var s,r=this._indexOfListener(e,o);if(-1!==r){if((s=this._bindings[r]).isOnce!==i)throw new Error("You cannot add"+(i?"":"Once")+"() then add"+(i?"Once":"")+"() the same listener without removing the relationship first.")}else s=new t(this,e,i,o,n),this._addBinding(s);return this.memorize&&this._prevParams&&s.execute(this._prevParams),s},_addBinding:function(t){var e=this._bindings.length;do{e--}while(this._bindings[e]&&t._priority<=this._bindings[e]._priority);this._bindings.splice(e+1,0,t)},_indexOfListener:function(t,e){for(var i,o=this._bindings.length;o--;)if((i=this._bindings[o])._listener===t&&i.context===e)return o;return-1},has:function(t,e){return-1!==this._indexOfListener(t,e)},add:function(t,e,i){return this.validateListener(t,"add"),this._registerListener(t,!1,e,i)},addOnce:function(t,e,i){return this.validateListener(t,"addOnce"),this._registerListener(t,!0,e,i)},remove:function(t,e){this.validateListener(t,"remove");var i=this._indexOfListener(t,e);return-1!==i&&(this._bindings[i]._destroy(),this._bindings.splice(i,1)),t},removeAll:function(t){void 0===t&&(t=null);for(var e=this._bindings.length;e--;)t?this._bindings[e].context===t&&(this._bindings[e]._destroy(),this._bindings.splice(e,1)):this._bindings[e]._destroy();t||(this._bindings.length=0)},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(){if(this.active){var t,e=Array.prototype.slice.call(arguments),i=this._bindings.length;if(this.memorize&&(this._prevParams=e),i){t=this._bindings.slice(),this._shouldPropagate=!0;do{i--}while(t[i]&&this._shouldPropagate&&!1!==t[i].execute(e))}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(),delete this._bindings,delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}},e.prototype.constructor=e,o.Signal=e}(),o.AStarFinder=function(t){t=t||{};var e={allowDiagonal:!1,heuristicFilter:null};e=o.Tools.merge(e,t),this.allowDiagonal=e.allowDiagonal,this.heuristicFilter=e.heuristicFilter,this.list=new o.LinkedList},o.AStarFinder.prototype={findPath:function(t,e,i,n){var s,r,a,l,h,c;for(i=i||this.heuristicFilter,n.clearPath(),this.list.clear(),this.list.add(t);this.list.length>0;){if(this.list.sort(this.compare),s=this.list.shift(),s._visited=!0,s===e)return o.PathUtil.backtrace(e);for(h=0,c=(a=n.getNeighbors(s,this.allowDiagonal,i)).length;c>h;h++)if((l=a[h]).walkable&&(r=s._calcCost+n.distance(s,l),!l._visited||rt?1:-1,s=o>e?1:-1,l=r-a;t!==i||e!==o;)u.push([t,e]),(h=2*l)>-a&&(l-=a,t+=n),r>h&&(l+=r,e+=s);return u},expandPath:function(t){var e,i,o,n,s,r,a=[],l=t.length;if(2>l)return a;for(s=0;l-1>s;++s)for(e=t[s],i=t[s+1],o=this.interpolate(e[0],e[1],i[0],i[1]),n=o.length,r=0;n-1>r;++r)a.push(o[r]);return a.push(t[l-1]),a},smoothenPath:function(t,e){var i,o,n,s,r,a,l,h,c,u,p,d,f=e.length,v=e[0][0],m=e[0][1],y=e[f-1][0],g=e[f-1][1];for(r=[[i=v,o=m]],l=2;f>l;++l){for(n=(c=e[l])[0],s=c[1],u=this.interpolate(i,o,n,s),d=!1,h=1;h0?(t=i[0],e=t.object.userData.structure,this.pickedObject!=e&&(this.pickedObject&&this.signal.dispatch(o.MouseCaster.OUT,this.pickedObject),this.pickedObject=e,this.selectedObject=null,this.signal.dispatch(o.MouseCaster.OVER,this.pickedObject)),this.position.copy(t.point),this.screenPosition.z=t.distance):(this.pickedObject&&this.signal.dispatch(o.MouseCaster.OUT,this.pickedObject),this.pickedObject=null,this.selectedObject=null),this.allHits=i}},preventDefault:function(){this._preventDefault=!0},_onDocumentMouseDown:function(t){return(t=t||window.event).preventDefault(),this._preventDefault?(this._preventDefault=!1,!1):(this.pickedObject&&(this.selectedObject=this.pickedObject),this.shift=t.shiftKey,this.ctrl=t.ctrlKey,this.down=1===t.which,this.rightDown=3===t.which,void this.signal.dispatch(o.MouseCaster.DOWN,this.pickedObject))},_onDocumentMouseUp:function(t){return t.preventDefault(),this._preventDefault?(this._preventDefault=!1,!1):(this.shift=t.shiftKey,this.ctrl=t.ctrlKey,this.signal.dispatch(o.MouseCaster.UP,this.pickedObject),this.selectedObject&&this.pickedObject&&this.selectedObject.uniqueID===this.pickedObject.uniqueID&&this.signal.dispatch(o.MouseCaster.CLICK,this.pickedObject),this.down=1!==t.which&&this.down,void(this.rightDown=3!==t.which&&this.rightDown))},_onDocumentMouseMove:function(t){t.preventDefault(),this.screenPosition.x=t.clientX/window.innerWidth*2-1,this.screenPosition.y=-t.clientY/window.innerHeight*2+1},_onMouseWheel:function(t){if(this.active){t.preventDefault(),t.stopPropagation();var e=0;void 0!==t.wheelDelta?e=t.wheelDelta:void 0!==t.detail&&(e=-t.detail),e>0?this.wheel++:this.wheel--,this.signal.dispatch(o.MouseCaster.WHEEL,this.wheel)}}},o.MouseCaster.prototype.constructor=o.MouseCaster,o.Scene=function(t,e){var i={element:document.body,alpha:!0,antialias:!0,clearColor:"#fff",sortObjects:!1,fog:null,light:new THREE.DirectionalLight(16777215),lightPosition:null,cameraType:"PerspectiveCamera",cameraPosition:null,orthoZoom:4},n={minDistance:100,maxDistance:1e3,zoomSpeed:2,noZoom:!1};if(i=o.Tools.merge(i,t),"boolean"!=typeof e&&(n=o.Tools.merge(n,e)),this.renderer=new THREE.WebGLRenderer({alpha:i.alpha,antialias:i.antialias}),this.renderer.setClearColor(i.clearColor,0),this.renderer.sortObjects=i.sortObjects,this.width=window.innerWidth,this.height=window.innerHeight,this.orthoZoom=i.orthoZoom,this.container=new THREE.Scene,this.container.fog=i.fog,this.container.add(new THREE.AmbientLight(14540253)),i.lightPosition||i.light.position.set(-1,1,-1).normalize(),this.container.add(i.light),"OrthographicCamera"===i.cameraType){var s=window.innerWidth/this.orthoZoom,r=window.innerHeight/this.orthoZoom;this.camera=new THREE.OrthographicCamera(s/-2,s/2,r/2,r/-2,1,5e3)}else this.camera=new THREE.PerspectiveCamera(50,this.width/this.height,1,5e3);this.contolled=!!e,this.contolled&&(this.controls=new THREE.OrbitControls(this.camera,this.renderer.domElement),this.controls.minDistance=n.minDistance,this.controls.maxDistance=n.maxDistance,this.controls.zoomSpeed=n.zoomSpeed,this.controls.noZoom=n.noZoom),i.cameraPosition&&this.camera.position.copy(i.cameraPosition),window.addEventListener("resize",function(){if(this.width=window.innerWidth,this.height=window.innerHeight,"OrthographicCamera"===this.camera.type){var t=this.width/this.orthoZoom,e=this.height/this.orthoZoom;this.camera.left=t/-2,this.camera.right=t/2,this.camera.top=e/2,this.camera.bottom=e/-2}else this.camera.aspect=this.width/this.height;this.camera.updateProjectionMatrix(),this.renderer.setSize(this.width,this.height)}.bind(this),!1),this.attachTo(i.element)},o.Scene.prototype={attachTo:function(t){t.style.width=this.width+"px",t.style.height=this.height+"px",this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),t.appendChild(this.renderer.domElement)},add:function(t){this.container.add(t)},remove:function(t){this.container.remove(t)},render:function(){this.contolled&&this.controls.update(),this.renderer.render(this.container,this.camera)},updateOrthoZoom:function(){if(this.orthoZoom<=0)this.orthoZoom=0;else{var t=this.width/this.orthoZoom,e=this.height/this.orthoZoom;this.camera.left=t/-2,this.camera.right=t/2,this.camera.top=e/2,this.camera.bottom=e/-2,this.camera.updateProjectionMatrix()}},focusOn:function(t){this.camera.lookAt(t.position)}},o.Scene.prototype.constructor=o.Scene,o.SelectionManager=function(t){this.mouse=t,this.onSelect=new o.Signal,this.onDeselect=new o.Signal,this.selected=null,this.toggleSelection=!1,this.mouse.signal.add(this.onMouse,this)},o.SelectionManager.prototype={select:function(t,e){t&&(e=e||!0,this.selected!==t&&this.clearSelection(e),t.selected?this.toggleSelection&&(e&&this.onDeselect.dispatch(t),t.deselect()):t.select(),this.selected=t,e&&this.onSelect.dispatch(t))},clearSelection:function(t){t=t||!0,this.selected&&(t&&this.onDeselect.dispatch(this.selected),this.selected.deselect()),this.selected=null},onMouse:function(t,e){switch(t){case o.MouseCaster.DOWN:e||this.clearSelection();break;case o.MouseCaster.CLICK:this.select(e)}}},o.SelectionManager.prototype.constructor=o.SelectionManager,o.Tools={clamp:function(t,e,i){return Math.max(e,Math.min(i,t))},sign:function(t){return t&&t/Math.abs(t)},random:function(t,e){return 1===arguments.length?Math.random()*t-.5*t:Math.random()*(e-t)+t},randomInt:function(t,e){return 1===arguments.length?Math.random()*t-.5*t|0:Math.random()*(e-t+1)+t|0},normalize:function(t,e,i){return(t-e)/(i-e)},getShortRotation:function(t){return(t%=this.TAU)>this.PI?t-=this.TAU:t<-this.PI&&(t+=this.TAU),t},generateID:function(){return Math.random().toString(36).slice(2)+Date.now()},isPlainObject:function(t){if("object"!=typeof t||t.nodeType||t===t.window)return!1;try{if(t.constructor&&!Object.prototype.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0},merge:function(t,e){var i=this,o=Array.isArray(e),n=o&&[]||{};return o?(t=t||[],n=n.concat(t),e.forEach(function(e,o){void 0===n[o]?n[o]=e:i.isPlainObject(e)?n[o]=i.merge(t[o],e):-1===t.indexOf(e)&&n.push(e)}),n):(t&&i.isPlainObject(t)&&Object.keys(t).forEach(function(e){n[e]=t[e]}),Object.keys(e).forEach(function(o){e[o]&&i.isPlainObject(e[o])&&t[o]?n[o]=i.merge(t[o],e[o]):n[o]=e[o]}),n)},now:function(){return window.nwf?window.nwf.system.Performance.elapsedTime:window.performance.now()},empty:function(t){for(;t.lastChild;)t.removeChild(t.lastChild)},radixSort:function(t,e,i,o){if(e=e||0,i=i||t.length,o=o||31,!(e>=i-1||0>o)){for(var n=e,s=i,r=1<n;)if(t[n]&r){--s;var a=t[n];t[n]=t[s],t[s]=a}else++n;this.radixSort(t,e,s,o-1),this.radixSort(t,s,i,o-1)}},randomizeRGB:function(t,e){var i,o,n=t.split(","),s="rgb(";for(e=this.randomInt(e),i=0;3>i;i++)0>(o=parseInt(n[i])+e)?o=0:o>255&&(o=255),s+=o+",";return s=s.substring(0,s.length-1),s+=")"},getJSON:function(t){var e=new XMLHttpRequest,i=void 0!==t.cache&&t.cache?t.url:t.url+"?t="+Math.floor(1e4*Math.random())+Date.now();e.onreadystatechange=function(){if(200!==this.status)0!==this.status&&console.warn("[Tools.getJSON] Error: "+this.status+" ("+this.statusText+") :: "+t.url);else{var e=null;try{e=JSON.parse(this.responseText)}catch(t){return}t.callback.call(t.scope||null,e)}},e.open("GET",i,!0),e.setRequestHeader("Accept","application/json"),e.setRequestHeader("Content-Type","application/json"),e.send("")}}},{}],10:[function(t,e,i){!function(t){function e(t,e){return-1!==String(t).indexOf(e)}function i(t,e,i){u!==e&&c!==e&&h!==e||Object.keys(i).forEach(function(e){t[e]=i[e]})}function o(t){var e="keyCode"in t?t.keyCode:"which"in t?t.which:0,i=function(){if(g||"keyLocation"in t){var i=g?t.location:t.keyLocation;if(i&&e in f[i])return f[i][e]}return"keyIdentifier"in t&&t.keyIdentifier in d?d[t.keyIdentifier]:e in p?p[e]:null}();if(!i)return null;var o=function(){var e=v[i.code];return e?t.shiftKey&&"shiftKey"in e?e.shiftKey:e.key:i.code}();return{code:i.code,key:o,location:i.location,keyCap:i.keyCap}}var n="KeyboardEvent"in t;n||(t.KeyboardEvent=function(){throw TypeError("Illegal constructor")}),t.KeyboardEvent.DOM_KEY_LOCATION_STANDARD=0,t.KeyboardEvent.DOM_KEY_LOCATION_LEFT=1,t.KeyboardEvent.DOM_KEY_LOCATION_RIGHT=2,t.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD=3;var s=window.KeyboardEvent.DOM_KEY_LOCATION_STANDARD,r=window.KeyboardEvent.DOM_KEY_LOCATION_LEFT,a=window.KeyboardEvent.DOM_KEY_LOCATION_RIGHT,l=window.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD,h=e(navigator.platform,"Win")?"win":e(navigator.platform,"Mac")?"mac":e(navigator.platform,"CrOS")?"cros":e(navigator.platform,"Linux")?"linux":e(navigator.userAgent,"iPad")||e(navigator.platform,"iPod")||e(navigator.platform,"iPhone")?"ios":"",c=e(navigator.userAgent,"Chrome/")?"chrome":e(navigator.vendor,"Apple")?"safari":e(navigator.userAgent,"MSIE")?"ie":e(navigator.userAgent,"Gecko/")?"moz":e(navigator.userAgent,"Opera/")?"opera":"",u=c+"-"+h,p={3:{code:"Cancel"},6:{code:"Help"},8:{code:"Backspace"},9:{code:"Tab"},12:{code:"Clear"},13:{code:"Enter"},16:{code:"Shift"},17:{code:"Control"},18:{code:"Alt"},19:{code:"Pause"},20:{code:"CapsLock"},21:{code:"KanaMode"},22:{code:"HangulMode"},23:{code:"JunjaMode"},24:{code:"FinalMode"},25:{code:"KanjiMode"},27:{code:"Escape"},28:{code:"Convert"},29:{code:"NonConvert"},30:{code:"Accept"},31:{code:"ModeChange"},32:{code:"Space"},33:{code:"PageUp"},34:{code:"PageDown"},35:{code:"End"},36:{code:"Home"},37:{code:"ArrowLeft"},38:{code:"ArrowUp"},39:{code:"ArrowRight"},40:{code:"ArrowDown"},41:{code:"Select"},42:{code:"Print"},43:{code:"Execute"},44:{code:"PrintScreen"},45:{code:"Insert"},46:{code:"Delete"},47:{code:"Help"},48:{code:"Digit0",keyCap:"0"},49:{code:"Digit1",keyCap:"1"},50:{code:"Digit2",keyCap:"2"},51:{code:"Digit3",keyCap:"3"},52:{code:"Digit4",keyCap:"4"},53:{code:"Digit5",keyCap:"5"},54:{code:"Digit6",keyCap:"6"},55:{code:"Digit7",keyCap:"7"},56:{code:"Digit8",keyCap:"8"},57:{code:"Digit9",keyCap:"9"},65:{code:"KeyA",keyCap:"a"},66:{code:"KeyB",keyCap:"b"},67:{code:"KeyC",keyCap:"c"},68:{code:"KeyD",keyCap:"d"},69:{code:"KeyE",keyCap:"e"},70:{code:"KeyF",keyCap:"f"},71:{code:"KeyG",keyCap:"g"},72:{code:"KeyH",keyCap:"h"},73:{code:"KeyI",keyCap:"i"},74:{code:"KeyJ",keyCap:"j"},75:{code:"KeyK",keyCap:"k"},76:{code:"KeyL",keyCap:"l"},77:{code:"KeyM",keyCap:"m"},78:{code:"KeyN",keyCap:"n"},79:{code:"KeyO",keyCap:"o"},80:{code:"KeyP",keyCap:"p"},81:{code:"KeyQ",keyCap:"q"},82:{code:"KeyR",keyCap:"r"},83:{code:"KeyS",keyCap:"s"},84:{code:"KeyT",keyCap:"t"},85:{code:"KeyU",keyCap:"u"},86:{code:"KeyV",keyCap:"v"},87:{code:"KeyW",keyCap:"w"},88:{code:"KeyX",keyCap:"x"},89:{code:"KeyY",keyCap:"y"},90:{code:"KeyZ",keyCap:"z"},91:{code:"OSLeft",location:r},92:{code:"OSRight",location:a},93:{code:"ContextMenu"},95:{code:"Standby"},96:{code:"Numpad0",keyCap:"0",location:l},97:{code:"Numpad1",keyCap:"1",location:l},98:{code:"Numpad2",keyCap:"2",location:l},99:{code:"Numpad3",keyCap:"3",location:l},100:{code:"Numpad4",keyCap:"4",location:l},101:{code:"Numpad5",keyCap:"5",location:l},102:{code:"Numpad6",keyCap:"6",location:l},103:{code:"Numpad7",keyCap:"7",location:l},104:{code:"Numpad8",keyCap:"8",location:l},105:{code:"Numpad9",keyCap:"9",location:l},106:{code:"NumpadMultiply",keyCap:"*",location:l},107:{code:"NumpadAdd",keyCap:"+",location:l},108:{code:"NumpadComma",keyCap:",",location:l},109:{code:"NumpadSubtract",keyCap:"-",location:l},110:{code:"NumpadDecimal",keyCap:".",location:l},111:{code:"NumpadDivide",keyCap:"/",location:l},112:{code:"F1"},113:{code:"F2"},114:{code:"F3"},115:{code:"F4"},116:{code:"F5"},117:{code:"F6"},118:{code:"F7"},119:{code:"F8"},120:{code:"F9"},121:{code:"F10"},122:{code:"F11"},123:{code:"F12"},124:{code:"F13"},125:{code:"F14"},126:{code:"F15"},127:{code:"F16"},128:{code:"F17"},129:{code:"F18"},130:{code:"F19"},131:{code:"F20"},132:{code:"F21"},133:{code:"F22"},134:{code:"F23"},135:{code:"F24"},144:{code:"NumLock",location:l},145:{code:"ScrollLock"},160:{code:"ShiftLeft",location:r},161:{code:"ShiftRight",location:a},162:{code:"ControlLeft",location:r},163:{code:"ControlRight",location:a},164:{code:"AltLeft",location:r},165:{code:"AltRight",location:a},166:{code:"BrowserBack"},167:{code:"BrowserForward"},168:{code:"BrowserRefresh"},169:{code:"BrowserStop"},170:{code:"BrowserSearch"},171:{code:"BrowserFavorites"},172:{code:"BrowserHome"},173:{code:"VolumeMute"},174:{code:"VolumeDown"},175:{code:"VolumeUp"},176:{code:"MediaTrackNext"},177:{code:"MediaTrackPrevious"},178:{code:"MediaStop"},179:{code:"MediaPlayPause"},180:{code:"LaunchMail"},181:{code:"MediaSelect"},182:{code:"LaunchApp1"},183:{code:"LaunchApp2"},186:{code:"Semicolon",keyCap:";"},187:{code:"Equal",keyCap:"="},188:{code:"Comma",keyCap:","},189:{code:"Minus",keyCap:"-"},190:{code:"Period",keyCap:"."},191:{code:"Slash",keyCap:"/"},192:{code:"Backquote",keyCap:"`"},219:{code:"BracketLeft",keyCap:"["},220:{code:"Backslash",keyCap:"\\"},221:{code:"BracketRight",keyCap:"]"},222:{code:"Quote",keyCap:"'"},226:{code:"IntlBackslash",keyCap:"\\"},229:{code:"Process"},246:{code:"Attn"},247:{code:"CrSel"},248:{code:"ExSel"},249:{code:"EraseEof"},250:{code:"Play"},251:{code:"ZoomToggle"},254:{code:"Clear"}};i(p,"moz",{59:{code:"Semicolon",keyCap:";"},61:{code:"Equal",keyCap:"="},107:{code:"Equal",keyCap:"="},109:{code:"Minus",keyCap:"-"},187:{code:"NumpadAdd",keyCap:"+",location:l},189:{code:"NumpadSubtract",keyCap:"-",location:l}}),i(p,"moz-mac",{12:{code:"NumLock",location:l},173:{code:"Minus",keyCap:"-"}}),i(p,"moz-win",{173:{code:"Minus",keyCap:"-"}}),i(p,"chrome-mac",{93:{code:"OSRight",location:a}}),i(p,"safari",{3:{code:"Enter"},25:{code:"Tab"}}),i(p,"ios",{10:{code:"Enter",location:s}}),i(p,"safari-mac",{91:{code:"OSLeft",location:r},93:{code:"OSRight",location:a},229:{code:"KeyQ",keyCap:"Q"}});var d={};"cros"===h&&(d["U+00A0"]={code:"ShiftLeft",location:r},d["U+00A1"]={code:"ShiftRight",location:a},d["U+00A2"]={code:"ControlLeft",location:r},d["U+00A3"]={code:"ControlRight",location:a},d["U+00A4"]={code:"AltLeft",location:r},d["U+00A5"]={code:"AltRight",location:a}),"chrome-mac"===u&&(d["U+0010"]={code:"ContextMenu"}),"safari-mac"===u&&(d["U+0010"]={code:"ContextMenu"}),"ios"===h&&(d["U+0010"]={code:"Function"},d["U+001C"]={code:"ArrowLeft"},d["U+001D"]={code:"ArrowRight"},d["U+001E"]={code:"ArrowUp"},d["U+001F"]={code:"ArrowDown"},d["U+0001"]={code:"Home"},d["U+0004"]={code:"End"},d["U+000B"]={code:"PageUp"},d["U+000C"]={code:"PageDown"});var f=[];f[r]={16:{code:"ShiftLeft",location:r},17:{code:"ControlLeft",location:r},18:{code:"AltLeft",location:r}},f[a]={16:{code:"ShiftRight",location:a},17:{code:"ControlRight",location:a},18:{code:"AltRight",location:a}},f[l]={13:{code:"NumpadEnter",location:l}},i(f[l],"moz",{109:{code:"NumpadSubtract",location:l},107:{code:"NumpadAdd",location:l}}),i(f[r],"moz-mac",{224:{code:"OSLeft",location:r}}),i(f[a],"moz-mac",{224:{code:"OSRight",location:a}}),i(f[a],"moz-win",{91:{code:"OSRight",location:a}}),i(f[a],"mac",{93:{code:"OSRight",location:a}}),i(f[l],"chrome-mac",{12:{code:"NumLock",location:l}}),i(f[l],"safari-mac",{12:{code:"NumLock",location:l},187:{code:"NumpadAdd",location:l},189:{code:"NumpadSubtract",location:l},190:{code:"NumpadDecimal",location:l},191:{code:"NumpadDivide",location:l}});var v={ShiftLeft:{key:"Shift"},ShiftRight:{key:"Shift"},ControlLeft:{key:"Control"},ControlRight:{key:"Control"},AltLeft:{key:"Alt"},AltRight:{key:"Alt"},OSLeft:{key:"OS"},OSRight:{key:"OS"},NumpadEnter:{key:"Enter"},Space:{key:" "},Digit0:{key:"0",shiftKey:")"},Digit1:{key:"1",shiftKey:"!"},Digit2:{key:"2",shiftKey:"@"},Digit3:{key:"3",shiftKey:"#"},Digit4:{key:"4",shiftKey:"$"},Digit5:{key:"5",shiftKey:"%"},Digit6:{key:"6",shiftKey:"^"},Digit7:{key:"7",shiftKey:"&"},Digit8:{key:"8",shiftKey:"*"},Digit9:{key:"9",shiftKey:"("},KeyA:{key:"a",shiftKey:"A"},KeyB:{key:"b",shiftKey:"B"},KeyC:{key:"c",shiftKey:"C"},KeyD:{key:"d",shiftKey:"D"},KeyE:{key:"e",shiftKey:"E"},KeyF:{key:"f",shiftKey:"F"},KeyG:{key:"g",shiftKey:"G"},KeyH:{key:"h",shiftKey:"H"},KeyI:{key:"i",shiftKey:"I"},KeyJ:{key:"j",shiftKey:"J"},KeyK:{key:"k",shiftKey:"K"},KeyL:{key:"l",shiftKey:"L"},KeyM:{key:"m",shiftKey:"M"},KeyN:{key:"n",shiftKey:"N"},KeyO:{key:"o",shiftKey:"O"},KeyP:{key:"p",shiftKey:"P"},KeyQ:{key:"q",shiftKey:"Q"},KeyR:{key:"r",shiftKey:"R"},KeyS:{key:"s",shiftKey:"S"},KeyT:{key:"t",shiftKey:"T"},KeyU:{key:"u",shiftKey:"U"},KeyV:{key:"v",shiftKey:"V"},KeyW:{key:"w",shiftKey:"W"},KeyX:{key:"x",shiftKey:"X"},KeyY:{key:"y",shiftKey:"Y"},KeyZ:{key:"z",shiftKey:"Z"},Numpad0:{key:"0"},Numpad1:{key:"1"},Numpad2:{key:"2"},Numpad3:{key:"3"},Numpad4:{key:"4"},Numpad5:{key:"5"},Numpad6:{key:"6"},Numpad7:{key:"7"},Numpad8:{key:"8"},Numpad9:{key:"9"},NumpadMultiply:{key:"*"},NumpadAdd:{key:"+"},NumpadComma:{key:","},NumpadSubtract:{key:"-"},NumpadDecimal:{key:"."},NumpadDivide:{key:"/"},Semicolon:{key:";",shiftKey:":"},Equal:{key:"=",shiftKey:"+"},Comma:{key:",",shiftKey:"<"},Minus:{key:"-",shiftKey:"_"},Period:{key:".",shiftKey:">"},Slash:{key:"/",shiftKey:"?"},Backquote:{key:"`",shiftKey:"~"},BracketLeft:{key:"[",shiftKey:"{"},Backslash:{key:"\\",shiftKey:"|"},BracketRight:{key:"]",shiftKey:"}"},Quote:{key:"'",shiftKey:'"'},IntlBackslash:{key:"\\",shiftKey:"|"}};i(v,"mac",{OSLeft:{key:"Meta"},OSRight:{key:"Meta"}});var m={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"},y=function(t,e){var i={};return Object.keys(t).forEach(function(o){var n=t[o];e in n&&(i[n[e]]=n)}),i}(p,"code");try{var g=n&&"location"in new KeyboardEvent("")}catch(t){}"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=o(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 m.hasOwnProperty(t)?m[t]:t}})}t(KeyboardEvent.prototype,"key",{get:function(){var t=o(this);return t&&"key"in t?t.key:"Unidentified"}}),t(KeyboardEvent.prototype,"location",{get:function(){var t=o(this);return t&&"location"in t?t.location:s}}),t(KeyboardEvent.prototype,"locale",{get:function(){return""}})}(),"queryKeyCap"in t.KeyboardEvent||(t.KeyboardEvent.queryKeyCap=function(t,e){if(t=String(t),!y.hasOwnProperty(t))return"Undefined";if(e&&"en-us"!==String(e).toLowerCase())throw Error("Unsupported locale");var i=y[t];return i.keyCap||i.code||"Undefined"}),t.identifyKey=function(t){if(!("code"in t)){var e=o(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:s,t.locale=""}}}(window)},{}],11:[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":14,"./src/components/body/static-body":15,"./src/components/constraint":16,"./src/components/math":17,"./src/system/physics":21,cannon:23}],12:[function(t,e,i){var o=t("cannon");o.shape2mesh=function(t){for(var e=new THREE.Object3D,i=0;ir.x&&(r.x=h.x),h.xr.y&&(r.y=h.y),h.yr.z&&(r.z=h.z),h.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 l=this.lowerBound,h=this.upperBound;t.copy(l),e.set(h.x,l.y,l.z),i.set(h.x,h.y,l.z),o.set(l.x,h.y,h.z),n.set(h.x,l.y,l.z),s.set(l.x,h.y,l.z),r.set(l.x,l.y,h.z),a.copy(h)};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],l=i[4],h=i[5],c=i[6],u=i[7];this.getCorners(o,n,s,a,l,h,c,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],l=i[4],h=i[5],c=i[6],u=i[7];this.getCorners(o,n,s,a,l,h,c,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,l=(this.lowerBound.z-t.from.z)*o,h=(this.upperBound.z-t.from.z)*o,c=Math.max(Math.max(Math.min(n,s),Math.min(r,a)),Math.min(l,h)),u=Math.min(Math.min(Math.max(n,s),Math.max(r,a)),Math.max(l,h));return!(u<0)&&!(c>u)}},{"../math/Vec3":52,"../utils/Utils":75}],25:[function(t,e,i){function o(){this.matrix=[]}e.exports=o,o.prototype.get=function(t,e){if(t=t.index,(e=e.index)>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)>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}},{}],26:[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);n.norm2()i.norm2()},o.prototype.aabbQuery=function(t,e,i){return console.warn(".aabbQuery is not implemented in this Broadphase subclass."),[]}},{"../math/Quaternion":50,"../math/Vec3":52,"../objects/Body":53,"../shapes/Plane":64,"../shapes/Shape":65}],27:[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 l=0;l=c&&(a=c-1),l<0?l=0:l>=u&&(l=u-1),h<0?h=0:h>=p&&(h=p-1),m<0?m=0:m>=c&&(m=c-1),y<0?y=0:y>=u&&(y=u-1),g<0?g=0:g>=p&&(g=p-1),l*=f,h*=v,m*=d,y*=f,g*=v;for(var C=a*=d;C<=m;C+=d)for(var A=l;A<=y;A+=f)for(var R=h;R<=g;R+=v){var M=C+A+R;L[M][P[M]++]=r}}for(var n=t.numObjects(),s=t.bodies,l=this.aabbMax,h=this.aabbMin,c=this.nx,u=this.ny,p=this.nz,d=u*p,f=p,v=1,m=l.x,y=l.y,g=l.z,w=h.x,b=h.y,x=h.z,E=c/(m-w),T=u/(y-b),S=p/(g-x),C=(m-w)/c,A=(y-b)/u,R=(g-x)/p,M=.5*Math.sqrt(C*C+A*A+R*R),B=r.types,z=B.SPHERE,k=B.PLANE,L=(B.BOX,B.COMPOUND,B.CONVEXPOLYHEDRON,this.bins),P=this.binLengths,I=this.bins.length,N=0;N!==I;N++)P[N]=0;for(var _=Math.ceil,h=Math.min,l=Math.max,N=0;N!==n;N++){var F=(it=s[N]).shape;switch(F.type){case z:var V=it.position.x,q=it.position.y,D=it.position.z,O=F.radius;o(V-O,q-O,D-O,V+O,q+O,D+O,it);break;case k:F.worldNormalNeedsUpdate&&F.computeWorldNormal(it.quaternion);var H=F.worldNormal,j=w+.5*C-it.position.x,W=b+.5*A-it.position.y,U=x+.5*R-it.position.z,G=a;G.set(j,W,U);for(var K=0,X=0;K!==c;K++,X+=d,G.y=W,G.x+=C)for(var Y=0,Q=0;Y!==u;Y++,Q+=f,G.z=U,G.y+=A)for(var Z=0,J=0;Z!==p;Z++,J+=v,G.z+=R)if(G.dot(H)1)for(var et=L[N],K=0;K!==tt;K++)for(var it=et[K],Y=0;Y!==K;Y++){var ot=et[Y];this.needBroadphaseCollision(it,ot)&&this.intersectionTest(it,ot,e,i)}}this.makePairsUnique(e,i)}},{"../math/Vec3":52,"../shapes/Shape":65,"./Broadphase":26}],28:[function(t,e,i){function o(){n.apply(this)}e.exports=o;var n=t("./Broadphase"),s=t("./AABB");(o.prototype=new n).constructor=o,o.prototype.collisionPairs=function(t,e,i){var o,n,s,r,a=t.bodies,l=a.length;for(o=0;o!==l;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)>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){}},{}],30:[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(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,l=0;lo[a];)a++;h===o[a]||n(t,h)}a=0;for(l=0;li[a];)a++;i[a]===c||n(e,c)}}},{}],31:[function(t,e,i){function o(t,e){this.from=t?t.clone():new s,this.to=e?e.clone():new s,this._direction=new s,this.precision=1e-4,this.checkCollisionResponse=!0,this.skipBackfaces=!1,this.collisionFilterMask=-1,this.collisionFilterGroup=-1,this.mode=o.ANY,this.result=new l,this.hasHit=!1,this.callback=function(t){}}function n(t,e,i,o){o.vsub(e,F),i.vsub(e,d),t.vsub(e,f);var n,s,r=F.dot(F),a=F.dot(d),l=F.dot(f),h=d.dot(d),c=d.dot(f);return(n=h*l-a*c)>=0&&(s=r*c-a*l)>=0&&n+st.boundingSphereRadius)){var n=this[t.type];n&&n.call(this,t,e,i,o,t)}};new s,new s;var y=new s,g=new s,w=new s,b=new s;new s,new l;o.prototype.intersectBox=function(t,e,i,o,n){return this.intersectConvex(t.convexPolyhedronRepresentation,e,i,o,n)},o.prototype[h.types.BOX]=o.prototype.intersectBox,o.prototype.intersectPlane=function(t,e,i,o,n){var r=this.from,a=this.to,l=this._direction,h=new s(0,0,1);e.vmult(h,h);var c=new s;r.vsub(i,c);var u=c.dot(h);a.vsub(i,c);if(!(u*c.dot(h)>0||r.distanceTo(a)=0&&f<=1&&(s.lerp(r,f,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[h.types.SPHERE]=o.prototype.intersectSphere;var R=new s,M=(new s,new s,new s);o.prototype.intersectConvex=function(t,e,i,o,s,r){for(var a=R,l=M,h=r&&r.faceList||null,c=t.faces,u=t.vertices,p=t.faceNormals,d=this._direction,f=this.from,v=this.to,m=f.distanceTo(v),x=h?h.length:c.length,E=this.result,T=0;!E._shouldStop&&Tm||this.reportIntersection(a,y,s,o,S)}}}}},o.prototype[h.types.CONVEXPOLYHEDRON]=o.prototype.intersectConvex;var B=new s,z=new s,k=new s,L=new s,P=new s,I=new s,N=(new c,[]),_=new a;o.prototype.intersectTrimesh=function(t,e,i,o,s,r){var l=B,h=N,c=_,u=M,p=z,d=k,f=L,v=I,m=P,x=(r&&r.faceList,t.indices),E=(t.vertices,t.faceNormals,this.from),T=this.to,S=this._direction;c.position.copy(i),c.quaternion.copy(e),a.vectorToLocalFrame(i,e,S,p),a.pointToLocalFrame(i,e,E,d),a.pointToLocalFrame(i,e,T,f),f.x*=t.scale.x,f.y*=t.scale.y,f.z*=t.scale.z,d.x*=t.scale.x,d.y*=t.scale.y,d.z*=t.scale.z,f.vsub(d,p),p.normalize();var C=d.distanceSquared(f);t.tree.rayQuery(this,c,h);for(var A=0,R=h.length;!this.result._shouldStop&&A!==R;A++){var F=h[A];t.getNormal(F,l),t.getVertex(x[3*F],g),g.vsub(d,u);var V=p.dot(l),q=l.dot(u)/V;if(!(q<0)){p.scale(q,y),y.vadd(d,y),t.getVertex(x[3*F+1],w),t.getVertex(x[3*F+2],b);var D=y.distanceSquared(d);!n(y,w,g,b)&&!n(y,g,w,b)||D>C||(a.vectorToWorldFrame(e,l,m),a.pointToWorldFrame(i,e,y,v),this.reportIntersection(m,v,s,o,F))}}h.length=0},o.prototype[h.types.TRIMESH]=o.prototype.intersectTrimesh,o.prototype.reportIntersection=function(t,e,i,n,s){var r=this.from,a=this.to,l=r.distanceTo(e),h=this.result;if(!(this.skipBackfaces&&t.dot(this._direction)>0))switch(h.hitFaceIndex=void 0!==s?s:-1,this.mode){case o.ALL:this.hasHit=!0,h.set(r,a,t,e,i,n,l),h.hasHit=!0,this.callback(h);break;case o.CLOSEST:(l=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,l=this.axisIndex;for(this.dirty&&(this.sortList(),this.dirty=!1),n=0;n!==a;n++){var h=r[n];for(s=n+1;sv?f>m?0:2:v>m?1: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,l),o=Math.PI/2,n=0),h<-.499&&(i=-2*Math.atan2(s,l),o=-Math.PI/2,n=0),isNaN(i)){var c=s*s,u=r*r,p=a*a;i=Math.atan2(2*r*l-2*s*a,1-2*u-2*p),o=Math.asin(2*h),n=Math.atan2(2*s*l-2*r*a,1-2*c-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),l=Math.sin(e/2),h=Math.sin(i/2);return"XYZ"===o?(this.x=a*s*r+n*l*h,this.y=n*l*r-a*s*h,this.z=n*s*h+a*l*r,this.w=n*s*r-a*l*h):"YXZ"===o?(this.x=a*s*r+n*l*h,this.y=n*l*r-a*s*h,this.z=n*s*h-a*l*r,this.w=n*s*r+a*l*h):"ZXY"===o?(this.x=a*s*r-n*l*h,this.y=n*l*r+a*s*h,this.z=n*s*h+a*l*r,this.w=n*s*r-a*l*h):"ZYX"===o?(this.x=a*s*r-n*l*h,this.y=n*l*r+a*s*h,this.z=n*s*h-a*l*r,this.w=n*s*r+a*l*h):"YZX"===o?(this.x=a*s*r+n*l*h,this.y=n*l*r+a*s*h,this.z=n*s*h-a*l*r,this.w=n*s*r-a*l*h):"XZY"===o&&(this.x=a*s*r-n*l*h,this.y=n*l*r-a*s*h,this.z=n*s*h+a*l*r,this.w=n*s*r+a*l*h),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,l,h=this.x,c=this.y,u=this.z,p=this.w,d=t.x,f=t.y,v=t.z,m=t.w;return(s=h*d+c*f+u*v+p*m)<0&&(s=-s,d=-d,f=-f,v=-v,m=-m),1-s>1e-6?(n=Math.acos(s),r=Math.sin(n),a=Math.sin((1-e)*n)/r,l=Math.sin(e*n)/r):(a=1-e,l=e),i.x=a*h+l*d,i.y=a*c+l*f,i.z=a*u+l*v,i.w=a*p+l*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,l=this.x,h=this.y,c=this.z,u=this.w,p=.5*e;return n.x+=p*(s*u+r*c-a*h),n.y+=p*(r*u+a*l-s*c),n.z+=p*(a*u+s*h-r*l),n.w+=p*(-s*l-r*h-a*c),n}},{"./Vec3":52}],51:[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){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){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){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){o=o||new n;return e.w*=-1,e.vmult(i,o),e.w*=-1,o}},{"./Quaternion":50,"./Vec3":52}],52:[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,l=this.z;return e=e||new o,e.x=a*s-l*n,e.y=l*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){if(!e)return new o(this.x+t.x,this.y+t.y,this.z+t.z);e.x=t.x+this.x,e.y=t.y+this.y,e.z=t.z+this.z},o.prototype.vsub=function(t,e){if(!e)return new o(this.x-t.x,this.y-t.y,this.z-t.z);e.x=this.x-t.x,e.y=this.y-t.y,e.z=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":49}],53:[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=void 0===t.allowSleep||t.allowSleep,this.sleepState=0,this.sleepSpeedLimit=void 0!==t.sleepSpeedLimit?t.sleepSpeedLimit:.1,this.sleepTimeLimit=void 0!==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=void 0!==t.fixedRotation&&t.fixedRotation,this.angularDamping=void 0!==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 l,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"),l=(t("../material/Material"),t("../collision/AABB")),h=t("../shapes/Box");(o.prototype=new n).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){e=e||new s;return t.vsub(this.position,e),this.quaternion.conjugate().vmult(e,e),e},o.prototype.vectorToLocalFrame=function(t,e){e=e||new s;return this.quaternion.conjugate().vmult(t,e),e},o.prototype.pointToWorldFrame=function(t,e){e=e||new s;return this.quaternion.vmult(t,e),e.vadd(this.position,e),e},o.prototype.vectorToWorldFrame=function(t,e){e=e||new s;return this.quaternion.vmult(t,e),e};var c=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 l;o.prototype.computeAABB=function(){for(var t=this.shapes,e=this.shapeOffsets,i=this.shapeOrientations,o=t.length,n=c,s=u,r=this.quaternion,a=this.aabb,l=p,h=0;h!==o;h++){var d=t[h];r.vmult(e[h],n),n.vadd(this.position,n),i[h].mult(r,s),d.calculateWorldAABB(n,s,l.lowerBound,l.upperBound),0===h?a.copy(l):a.extend(l)}this.aabbNeedsUpdate=!1};var d=new r,f=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=f;i.setRotationFromQuaternion(this.quaternion),i.transpose(o),i.scale(e,i),i.mmult(o,this.invInertiaWorld)}else;};new s;var v=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,y=new s;o.prototype.applyLocalForce=function(t,e){if(this.type===o.DYNAMIC){var i=m,n=y;this.vectorToWorldFrame(t,i),this.vectorToWorldFrame(e,n),this.applyForce(i,n)}};new s;var g=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),h.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,l=this.torque,h=this.quaternion,c=this.invMass,u=this.invInertiaWorld,p=this.linearFactor,d=c*t;n.x+=a.x*d*p.x,n.y+=a.y*d*p.y,n.z+=a.z*d*p.z;var f=u.elements,v=this.angularFactor,m=l.x*v.x,y=l.y*v.y,g=l.z*v.z;s.x+=t*(f[0]*m+f[1]*y+f[2]*g),s.y+=t*(f[3]*m+f[4]*y+f[5]*g),s.z+=t*(f[6]*m+f[7]*y+f[8]*g),r.x+=n.x*t,r.y+=n.y*t,r.z+=n.z*t,h.integrate(this.angularVelocity,t,this.angularFactor,h),e&&(i?h.normalizeFast():h.normalize()),this.aabbNeedsUpdate=!0,this.updateInertiaWorld()}}},{"../collision/AABB":24,"../material/Material":47,"../math/Mat3":49,"../math/Quaternion":50,"../math/Vec3":52,"../shapes/Box":59,"../shapes/Shape":65,"../utils/EventTarget":71}],54:[function(t,e,i){function o(t){this.chassisBody=t.chassisBody,this.wheelInfos=[],this.sliding=!1,this.world=null,this.indexRightAxis=void 0!==t.indexRightAxis?t.indexRightAxis:1,this.indexForwardAxis=void 0!==t.indexForwardAxis?t.indexForwardAxis:0,this.indexUpAxis=void 0!==t.indexUpAxis?t.indexUpAxis:2}function n(t,e,i){var o=x,n=E,s=T,r=S;return e.vsub(t.position,o),o.cross(i,n),t.invInertiaWorld.vmult(n,r),r.cross(o,s),t.invMass+i.dot(s)}t("./Body");var s=t("../math/Vec3"),r=t("../math/Quaternion"),a=(t("../collision/RaycastResult"),t("../collision/Ray")),l=t("../objects/WheelInfo");e.exports=o;new s,new s,new s;var h=new s,c=new s,u=new s;new a;o.prototype.addWheel=function(t){var e=new l(t=t||{}),i=this.wheelInfos.length;return this.wheelInfos.push(e),i},o.prototype.setSteeringValue=function(t,e){this.wheelInfos[e].steering=t};new s;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;nd.maxSuspensionForce&&(h=d.maxSuspensionForce),d.raycastResult.hitNormalWorld.scale(h*t,a),d.raycastResult.hitPointWorld.vsub(o.position,l),o.applyImpulse(a,l)}this.updateFriction(t);var c=new s,u=new s,p=new s;for(n=0;n0?1:-1)*d.customSlidingRotationalSpeed*t),Math.abs(d.brake)>Math.abs(d.engineForce)&&(d.deltaRotation=0),d.rotation+=d.deltaRotation,d.deltaRotation*=.99}},o.prototype.updateSuspension=function(t){for(var e=this.chassisBody.mass,i=this.wheelInfos,o=i.length,n=0;nv&&(t.suspensionLength=v,t.raycastResult.reset());var m=t.raycastResult.hitNormalWorld.dot(t.directionWorld),y=new s;o.getVelocityAtWorldPoint(t.raycastResult.hitPointWorld,y);var g=t.raycastResult.hitNormalWorld.dot(y);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=h,i=c,o=u,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,a=new r;a.setFromAxisAngle(e,s);var l=new r;l.setFromAxisAngle(i,n.rotation);var p=n.worldTransform.quaternion;this.chassisBody.quaternion.mult(a,p),p.mult(l,p),p.normalize();var d=n.worldTransform.position;d.copy(n.directionWorld),d.scale(n.suspensionLength,d),d.vadd(n.chassisConnectionPointWorld,d)};var f=[new s(1,0,0),new s(0,1,0),new s(0,0,1)];o.prototype.getWheelTransformWorld=function(t){return this.wheelInfos[t].worldTransform};var v=new s,m=[],y=[];o.prototype.updateFriction=function(t){for(var e=v,i=this.wheelInfos,o=i.length,r=this.chassisBody,a=y,l=m,h=0;h1.1)return 0;var r=C,a=A,l=R;return t.getVelocityAtWorldPoint(e,r),i.getVelocityAtWorldPoint(o,a),r.vsub(a,l),-.2*n.dot(l)*(1/(t.invMass+i.invMass))}(r,L.raycastResult.hitPointWorld,d,L.raycastResult.hitPointWorld,c),L.sideImpulse*=1}}this.sliding=!1;for(h=0;hS){this.sliding=!0,L.sliding=!0;var k=T/Math.sqrt(z);L.skidInfo*=k}}}if(this.sliding)for(h=0;hthis.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 l=this.particles[a];l.position.vsub(t.position,r),o!==l.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":32,"../math/Transform":51,"../math/Vec3":52,"../utils/Utils":75}],59:[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).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=(new o(0,0,1),new o(0,1,0),new o(1,0,0),new r(n,[[3,2,1,0],[4,5,6,7],[5,4,0,1],[2,3,7,6],[0,4,7,3],[1,2,6,5]]));this.convexPolyhedronRepresentation=a,a.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),h>o.y&&(o.y=h),c>o.z&&(o.z=c),ad&&(d=v,p=f)}for(var m=[],y=i.faces[p],g=y.length,w=0;w=0&&this.clipFaceAgainstHull(r,t,e,m,a,l,h)};var u=new s,p=new s,d=new s,f=new s,v=new s,m=new s;o.prototype.findSeparatingAxis=function(t,e,i,o,n,s,r,a){var l=u,h=p,c=d,y=f,g=v,w=m,b=Number.MAX_VALUE,x=this;if(x.uniqueAxes)for(T=0;T!==x.uniqueAxes.length;T++){i.vmult(x.uniqueAxes[T],l);if(!1===(A=x.testSepAxis(l,t,e,i,o,n)))return!1;A0&&s.negate(s),!0};var y=[],g=[];o.prototype.testSepAxis=function(t,e,i,n,s,r){o.project(this,t,i,n,y),o.project(e,t,s,r,g);var a=y[0],l=y[1],h=g[0],c=g[1];if(ae&&(e=n)}this.maxValue=e},o.prototype.setHeightValueAtIndex=function(t,e,i){this.data[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 l=e;l<=o;l++){var h=s[a][l];h>r&&(r=h)}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 l=[],h=new r,c=new r,u=new r,p=new r;o.prototype.getTriangleAt=function(t,e,i,o,n,s){var r=l;this.getIndexOfPosition(t,e,r,i);var a=r[0],h=r[1],c=this.data;i&&(a=Math.min(c.length-2,Math.max(0,a)),h=Math.min(c[0].length-2,Math.max(0,h)));var u=this.elementSize,p=Math.pow(t/u-a,2)+Math.pow(e/u-h,2)>Math.pow(t/u-(a+1),2)+Math.pow(e/u-(h+1),2);return this.getTriangle(a,h,p,o,n,s),p};var d=new r,f=new r,v=new r,m=new r,y=new r;o.prototype.getNormalAt=function(t,e,i,o){var n=d,s=f,r=v,a=m,l=y;this.getTriangleAt(t,e,i,n,s,r),s.vsub(n,a),r.vsub(n,l),a.cross(l,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,n=c,s=u,r=p,a=l;this.getIndexOfPosition(t,e,a,i);var d=a[0],f=a[1];i&&(d=Math.min(o.length-2,Math.max(0,d)),f=Math.min(o[0].length-2,Math.max(0,f)));var v=this.getTriangleAt(t,e,i,n,s,r);!function(t,e,i,o,n,s,r,a,l){l.x=((s-a)*(t-r)+(r-n)*(e-a))/((s-a)*(i-r)+(r-n)*(o-a)),l.y=((a-o)*(t-r)+(i-r)*(e-a))/((s-a)*(i-r)+(r-n)*(o-a)),l.z=1-l.x-l.y}(t,e,n.x,n.y,s.x,s.y,r.x,r.y,h);var m=h;return v?o[d+1][f+1]*m.x+o[d][f+1]*m.y+o[d+1][f]*m.z:o[d][f]*m.x+o[d+1][f]*m.y+o[d][f+1]*m.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){if(a=this.getCachedConvexTrianglePillar(t,e,i))return this.pillarConvex=a.convex,void(this.pillarOffset=a.offset);o=new s,n=new r,this.pillarConvex=o,this.pillarOffset=n}var a=this.data,l=this.elementSize,h=o.faces;o.vertices.length=6;for(c=0;c<6;c++)o.vertices[c]||(o.vertices[c]=new r);h.length=5;for(var c=0;c<5;c++)h[c]||(h[c]=[]);var u=o.vertices,p=(Math.min(a[t][e],a[t+1][e],a[t][e+1],a[t+1][e+1])-this.minValue)/2+this.minValue;i?(n.set((t+.75)*l,(e+.75)*l,p),u[0].set(.25*l,.25*l,a[t+1][e+1]-p),u[1].set(-.75*l,.25*l,a[t][e+1]-p),u[2].set(.25*l,-.75*l,a[t+1][e]-p),u[3].set(.25*l,.25*l,-p-1),u[4].set(-.75*l,.25*l,-p-1),u[5].set(.25*l,-.75*l,-p-1),h[0][0]=0,h[0][1]=1,h[0][2]=2,h[1][0]=5,h[1][1]=4,h[1][2]=3,h[2][0]=2,h[2][1]=5,h[2][2]=3,h[2][3]=0,h[3][0]=3,h[3][1]=4,h[3][2]=1,h[3][3]=0,h[4][0]=1,h[4][1]=4,h[4][2]=5,h[4][3]=2):(n.set((t+.25)*l,(e+.25)*l,p),u[0].set(-.25*l,-.25*l,a[t][e]-p),u[1].set(.75*l,-.25*l,a[t+1][e]-p),u[2].set(-.25*l,.75*l,a[t][e+1]-p),u[3].set(-.25*l,-.25*l,-p-1),u[4].set(.75*l,-.25*l,-p-1),u[5].set(-.25*l,.75*l,-p-1),h[0][0]=0,h[0][1]=1,h[0][2]=2,h[1][0]=5,h[1][1]=4,h[1][2]=3,h[2][0]=0,h[2][1]=2,h[2][2]=5,h[2][3]=3,h[3][0]=1,h[3][1]=0,h[3][2]=3,h[3][3]=4,h[4][0]=4,h[4][1]=5,h[4][2]=2,h[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 r).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 r(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)};new s;var b=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=[],l=0;l<=i;l++)for(f=0;f<=n;f++){var h=f/n*s,c=l/i*Math.PI*2,u=(t+e*Math.cos(c))*Math.cos(h),p=(t+e*Math.cos(c))*Math.sin(h),d=e*Math.sin(c);r.push(u,p,d)}for(l=1;l<=i;l++)for(var f=1;f<=n;f++){var v=(n+1)*l+f-1,m=(n+1)*(l-1)+f-1,y=(n+1)*(l-1)+f,g=(n+1)*l+f;a.push(v,m,g),a.push(m,y,g)}return new o(r,a)}},{"../collision/AABB":24,"../math/Quaternion":50,"../math/Transform":51,"../math/Vec3":52,"../utils/Octree":72,"./Shape":65}],68:[function(t,e,i){function o(){n.call(this),this.iterations=10,this.tolerance=1e-7}e.exports=o;t("../math/Vec3"),t("../math/Quaternion");var n=t("./Solver"),s=[],r=[],a=[];(o.prototype=new n).solve=function(t,e){var i,o,n,l,h,c=0,u=this.iterations,p=this.tolerance*this.tolerance,d=this.equations,f=d.length,v=e.bodies,m=v.length,y=t;if(0!==f)for(C=0;C!==m;C++)v[C].updateSolveMassProperties();var g=r,w=a,b=s;g.length=f,w.length=f,b.length=f;for(C=0;C!==f;C++){S=d[C];b[C]=0,w[C]=S.computeB(y),g[C]=1/S.computeC()}if(0!==f){for(C=0;C!==m;C++){var x=(A=v[C]).vlambda,E=A.wlambda;x.set(0,0,0),E.set(0,0,0)}for(c=0;c!==u;c++){l=0;for(var T=0;T!==f;T++){var S=d[T];i=w[T],o=g[T],(h=b[T])+(n=o*(i-S.computeGWlambda()-S.eps*h))S.maxForce&&(n=S.maxForce-h),b[T]+=n,l+=n>0?n:-n,S.addToWlambda(n)}if(l*l=0;i--)e.children[i].data.length||e.children.splice(i,1);Array.prototype.push.apply(t,e.children)}}},{"../collision/AABB":24,"../math/Vec3":52}],73:[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;){delete t[e.pop()]}}},{}],75:[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}},{}],76:[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).constructObject=function(){return new n}},{"../math/Vec3":52,"./Pool":73}],77:[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=H;t[(s+1)%n].vsub(r,a);var l=j;a.cross(e,l);var h=W;i.vsub(r,h);var c=l.dot(h);if(!(null===o||c>0&&!0===o||c<=0&&!1===o))return!1;null===o&&(o=c>0)}return!0}e.exports=o;var s=t("../collision/AABB"),r=t("../objects/Body"),a=t("../shapes/Shape"),l=t("../collision/Ray"),h=t("../math/Vec3"),c=t("../math/Transform"),u=(t("../shapes/ConvexPolyhedron"),t("../math/Quaternion")),p=(t("../solver/Solver"),t("../utils/Vec3Pool")),d=t("../equations/ContactEquation"),f=t("../equations/FrictionEquation");o.prototype.createContactEquation=function(t,e,i,o,n,s){var r;this.contactPointPool.length?((r=this.contactPointPool.pop()).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 l=i.material||t.material,h=o.material||e.material;return l&&h&&l.restitution>=0&&h.restitution>=0&&(r.restitution=l.restitution*h.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,l=a.friction,h=n.material||i.material,c=s.material||o.material;if(h&&c&&h.friction>=0&&c.friction>=0&&(l=h.friction*c.friction),l>0){var u=l*r.gravity.length(),p=i.invMass+o.invMass;p>0&&(p=1/p);var d=this.frictionEquationPool,v=d.length?d.pop():new f(i,o,u*p),m=d.length?d.pop():new f(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 h,m=new h,y=new h;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(),y.setZero();for(var n=e.bi,s=(e.bj,0);s!==t;s++)(e=this.result[this.result.length-1-s]).bodyA!==n?(v.vadd(e.ni,v),m.vadd(e.ri,m),y.vadd(e.rj,y)):(v.vsub(e.ni,v),m.vadd(e.rj,m),y.vadd(e.ri,y));var r=1/t;m.scale(r,i.ri),y.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 h,w=new h,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 l=b,h=x,c=g,u=w,p=0,d=t.length;p!==d;p++){var f=t[p],v=e[p],m=null;f.material&&v.material&&(m=i.getContactMaterial(f.material,v.material)||null);for(var y=f.type&r.KINEMATIC&&v.type&r.STATIC||f.type&r.STATIC&&v.type&r.KINEMATIC||f.type&r.KINEMATIC&&v.type&r.KINEMATIC,E=0;ET.boundingSphereRadius+C.boundingSphereRadius)){var A=null;T.material&&C.material&&(A=i.getContactMaterial(T.material,C.material)||null),this.currentContactMaterial=A||m||i.defaultContactMaterial;var R=this[T.type|C.type];if(R){(T.type0&&j<0){y.vsub(d,g),m.copy(v),m.normalize(),W=g.dot(m),m.scale(W,g),g.vadd(d,g);if((Q=g.distanceTo(y))0){var M=K,B=X;M.copy(p[(T+1)%3]),B.copy(p[(T+2)%3]);var z=M.norm(),k=B.norm();M.normalize(),B.normalize();var L=U.dot(M),P=U.dot(B);if(L-z&&P-k){O=Math.abs(R-A-d);if((null===E||O0){for(var k=[],L=0,P=S.length;L!==P;L++){var I=p.get();r.vmult(v[S[L]],I),o.vadd(I,I),k.push(I)}if(n(k,C,i)){if(u)return!0;x=!0;G=this.createContactEquation(a,l,t,e,h,c);C.mult(-m,G.ri),C.negate(G.ni);var N=p.get();C.mult(-B,N);var _=p.get();C.mult(-m,_),i.vsub(o,G.rj),G.rj.vadd(_,G.rj),G.rj.vadd(N,G.rj),G.rj.vadd(o,G.rj),G.rj.vsub(l.position,G.rj),G.ri.vadd(i,G.ri),G.ri.vsub(a.position,G.ri),p.release(N),p.release(_),this.result.push(G),this.createFrictionEquationsFromContact(G,this.frictionResult);for(var L=0,F=k.length;L!==F;L++)p.release(k[L]);return}for(L=0;L!==S.length;L++){var V=p.get(),q=p.get();r.vmult(v[S[(L+1)%S.length]],V),r.vmult(v[S[(L+2)%S.length]],q),o.vadd(V,V),o.vadd(q,q);var D=et;q.vsub(V,D);var O=it;D.unit(O);var H=p.get(),j=p.get();i.vsub(V,j);var W=j.dot(O);O.mult(W,H),H.vadd(V,H);var U=p.get();if(H.vsub(i,U),W>0&&W*Wt.boundingSphereRadius+e.boundingSphereRadius)&&t.findSeparatingAxis(e,i,n,o,s,d,u,p)){var f=[],v=vt;t.clipAgainstHull(i,n,e,o,s,d,-100,100,f);for(var m=0,y=0;y!==f.length;y++){if(c)return!0;var g=this.createContactEquation(r,a,t,e,l,h),w=g.ri,b=g.rj;d.negate(g.ni),f[y].normal.negate(v),v.mult(f[y].depth,v),f[y].point.vadd(v,w),b.copy(f[y].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 h,yt=new h,gt=new h;o.prototype[a.types.PLANE|a.types.PARTICLE]=o.prototype.planeParticle=function(t,e,i,o,n,s,r,a,l,h,c){var u=mt;u.set(0,0,1),r.quaternion.vmult(u,u);var p=yt;o.vsub(r.position,p);if(u.dot(p)<=0){if(c)return!0;var d=this.createContactEquation(a,r,e,t,l,h);d.ni.copy(u),d.ni.negate(d.ni),d.ri.set(0,0,0);var f=gt;u.mult(u.dot(o),f),o.vsub(f,f),d.rj.copy(f),this.result.push(d),this.createFrictionEquationsFromContact(d,this.frictionResult)}};var wt=new h;o.prototype[a.types.PARTICLE|a.types.SPHERE]=o.prototype.sphereParticle=function(t,e,i,o,n,s,r,a,l,h,c){var u=wt;u.set(0,0,1),o.vsub(i,u);if(u.norm2()<=t.radius*t.radius){if(c)return!0;var p=this.createContactEquation(a,r,e,t,l,h);u.normalize(),p.rj.copy(u),p.rj.mult(t.radius,p.rj),p.ni.copy(u),p.ni.negate(p.ni),p.ri.set(0,0,0),this.result.push(p),this.createFrictionEquationsFromContact(p,this.frictionResult)}};var bt=new u,xt=new h,Et=(new h,new h),Tt=new h,St=new h;o.prototype[a.types.PARTICLE|a.types.CONVEXPOLYHEDRON]=o.prototype.convexParticle=function(t,e,i,o,n,s,r,a,l,h,c){var u=-1,p=Et,d=St,f=null,v=xt;if(v.copy(o),v.vsub(i,v),n.conjugate(bt),bt.vmult(v,v),t.pointIsInside(v)){t.worldVerticesNeedsUpdate&&t.computeWorldVertices(i,n),t.worldFaceNormalsNeedsUpdate&&t.computeWorldFaceNormals(n);for(var m=0,y=t.faces.length;m!==y;m++){var g=[t.worldVertices[t.faces[m][0]]],w=t.worldFaceNormals[m];o.vsub(g[0],Tt);var b=-w.dot(Tt);if(null===f||Math.abs(b)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 T=E[0],S=E[1];if(!(y.z-f>S||y.z+fp.length||b>p[0].length)){y<0&&(y=0),g<0&&(g=0),w<0&&(w=0),b<0&&(b=0),y>=p.length&&(y=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(y,w,g,b,x);var E=x[0],T=x[1];if(!(m.z-d>T||m.z+d2)return}}}},{"../collision/AABB":24,"../collision/Ray":31,"../equations/ContactEquation":41,"../equations/FrictionEquation":43,"../math/Quaternion":50,"../math/Transform":51,"../math/Vec3":52,"../objects/Body":53,"../shapes/ConvexPolyhedron":60,"../shapes/Shape":65,"../solver/Solver":69,"../utils/Vec3Pool":76}],78:[function(t,e,i){function o(t){t=t||{},l.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 h,this.collisionMatrixPrevious=new h,this.bodyOverlapKeeper=new c,this.shapeOverlapKeeper=new c,this.materials=[],this.contactmaterials=[],this.contactMaterialTable=new f,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;t("../shapes/Shape");var n=t("../math/Vec3"),s=t("../math/Quaternion"),r=t("../solver/GSSolver"),a=(t("../equations/ContactEquation"),t("../equations/FrictionEquation"),t("./Narrowphase")),l=t("../utils/EventTarget"),h=t("../collision/ArrayCollisionMatrix"),c=t("../collision/OverlapKeeper"),u=t("../material/Material"),p=t("../material/ContactMaterial"),d=t("../objects/Body"),f=t("../utils/TupleDictionary"),v=t("../collision/RaycastResult"),m=t("../collision/AABB"),y=t("../collision/Ray"),g=t("../collision/NaiveBroadphase");o.prototype=new l;new m;var w=new y;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){-1===this.bodies.indexOf(t)&&(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);-1!==e&&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=y.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=y.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=y.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(-1!==o){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;D-=1)(q.bodyA===o[D]&&q.bodyB===n[D]||q.bodyB===o[D]&&q.bodyA===n[D])&&(o.splice(D,1),n.splice(D,1))}this.collisionMatrixTick(),h&&(e=performance.now());var B=S,z=i.length;for(g=0;g!==z;g++)B.push(i[g]);i.length=0;var k=this.frictionEquations.length;for(g=0;g!==k;g++)f.push(this.frictionEquations[g]);this.frictionEquations.length=0,this.narrowphase.getContacts(o,n,this,i,B,this.frictionEquations,f),h&&(c.narrowphase=performance.now()-e),h&&(e=performance.now());for(g=0;g=0&&N.material.friction>=0&&I.material.friction*N.material.friction,I.material.restitution>=0&&N.material.restitution>=0&&(q.restitution=I.material.restitution*N.material.restitution)),a.addEquation(q),I.allowSleep&&I.type===d.DYNAMIC&&I.sleepState===d.SLEEPING&&N.sleepState===d.AWAKE&&N.type!==d.STATIC){N.velocity.norm2()+N.angularVelocity.norm2()>=2*Math.pow(N.sleepSpeedLimit,2)&&(I._wakeUpAfterNarrowphase=!0)}if(N.allowSleep&&N.type===d.DYNAMIC&&N.sleepState===d.SLEEPING&&I.sleepState===d.AWAKE&&I.type!==d.STATIC){I.velocity.norm2()+I.angularVelocity.norm2()>=2*Math.pow(I.sleepSpeedLimit,2)&&(N._wakeUpAfterNarrowphase=!0)}this.collisionMatrix.set(I,N,!0),this.collisionMatrixPrevious.get(I,N)||(T.body=N,T.contact=q,I.dispatchEvent(T),T.body=I,N.dispatchEvent(T)),this.bodyOverlapKeeper.set(I.id,N.id),this.shapeOverlapKeeper.set(_.id,F.id)}for(this.emitContactEvents(),h&&(c.makeContactConstraints=performance.now()-e,e=performance.now()),g=0;g!==s;g++){(I=r[g])._wakeUpAfterNarrowphase&&(I.wakeUp(),I._wakeUpAfterNarrowphase=!1)}var V=p.length;for(g=0;g!==V;g++){var q=p[g];q.update();for(var D=0,O=q.equations.length;D!==O;D++){var H=q.equations[D];a.addEquation(H)}}a.solve(t,this),h&&(c.solve=performance.now()-e),a.removeAllEquations();var j=Math.pow;for(g=0;g!==s;g++){if((I=r[g]).type&u){var W=j(1-I.linearDamping,t),U=I.velocity;U.mult(W,U);var G=I.angularVelocity;if(G){var K=j(1-I.angularDamping,t);G.mult(K,G)}}}for(this.dispatchEvent(E),g=0;g!==s;g++){(I=r[g]).preStep&&I.preStep.call(I)}h&&(e=performance.now());var X=this.stepnumber%(this.quatNormalizeSkip+1)==0,Y=this.quatNormalizeFast;for(g=0;g!==s;g++)r[g].integrate(t,X,Y);for(this.clearForces(),this.broadphase.dirty=!0,h&&(c.integrate=performance.now()-e),this.time+=t,this.stepnumber+=1,this.dispatchEvent(x),g=0;g!==s;g++){var Q=(I=r[g]).postStep;Q&&Q.call(I)}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 l=0,h=t.length;l0;){const e=o.pop();if(e===i){let t=e;const i=[];for(;t.parent;)i.push(t),t=t.parent;return this.cleanUp(i),i.reverse()}e.closed=!0;const n=this.neighbours(t,e);for(let t=0,s=n.length;t0&&(this.content[0]=e,this.bubbleUp(0)),t}remove(t){const e=this.content.indexOf(t),i=this.content.pop();e!==this.content.length-1&&(this.content[e]=i,this.scoreFunction(i)0;){const i=(t+1>>1)-1,o=this.content[i];if(!(this.scoreFunction(e)0)){e.push(n),n=i=n,s=i,a=r=a,l=r,h=r;continue}s=u,l=h}if(o.triarea2(i,n,c)>=0){if(!(o.vequal(i,n)||o.triarea2(i,s,c)<0)){e.push(s),n=i=s,s=i,a=r=l,l=r,h=r;continue}n=c,a=h}}return 0!==e.length&&o.vequal(e[e.length-1],t[t.length-1].left)||e.push(t[t.length-1].left),this.path=e,e}}e.exports=n},{"./utils":83}],82:[function(t,e,i){const o=t("./utils"),n=t("./AStar"),s=t("./Channel");var r=1,a=function(t){console.log("Vertices:",t.vertices.length,"polygons:",t.faces.length);var e=[],i=t.vertices,n=t.faceVertexUvs;t.faces.forEach(t=>{e.push({id:r++,vertexIds:[t.a,t.b,t.c],centroid:t.centroid,normal:t.normal,neighbours:[]})});var s={polygons:e,vertices:i,faceVertexUvs:n};return e.forEach(t=>{!function(t,e){t.neighbours=[];for(var i=0,n=e.polygons.length;i1e4||o.array_intersect(t.vertexIds,e.polygons[i].vertexIds).length>=2&&t.neighbours.push(e.polygons[i])}(t,s)}),s},l=function(t){var e={};t.vertices.forEach(t=>{t.x=o.roundNumber(t.x,2),t.y=o.roundNumber(t.y,2),t.z=o.roundNumber(t.z,2)}),e.vertices=t.vertices;var i=function(t){var e=[],i=0,o=function(t){t.neighbours.forEach(e=>{void 0===e.group&&(e.group=t.group,o(e))})};return t.polygons.forEach(t=>{void 0===t.group&&(t.group=i++,o(t)),e[t.group]||(e[t.group]=[]),e[t.group].push(t)}),console.log("Groups built: ",e.length),e}(t);e.groups=[];var n=function(t,e){for(var i=0;i{var i=[];t.forEach(e=>{var s=[];e.neighbours.forEach(e=>{s.push(n(t,e))});var r=[];e.neighbours.forEach(t=>{r.push(function(t,e){var i=t.vertexIds,o=e.vertexIds,n=[];return i.forEach(t=>{o.includes(t)&&n.push(t)}),n.length<2?[]:(n.includes(i[0])&&n.includes(i[i.length-1])&&i.push(i.shift()),n.includes(o[0])&&n.includes(o[o.length-1])&&o.push(o.shift()),n=[],i.forEach(t=>{o.includes(t)&&n.push(t)}),n)}(e,t))}),e.centroid.x=o.roundNumber(e.centroid.x,2),e.centroid.y=o.roundNumber(e.centroid.y,2),e.centroid.z=o.roundNumber(e.centroid.z,2),i.push({id:n(t,e),neighbours:s,vertexIds:e.vertexIds,centroid:e.centroid,portals:r})}),e.groups.push(i)}),e},h={};e.exports={buildNodes:function(t){var e=function(t){return o.computeCentroids(t),t.mergeVertices(),a(t)}(t);return l(e)},setZoneData:function(t,e){h[t]=e},getGroup:function(t,e){if(!h[t])return null;var i=null,n=Math.pow(50,2);return h[t].groups.forEach((t,s)=>{t.forEach(t=>{var r=o.distanceToSquared(t.centroid,e);r{i&&n?o.distanceToSquared(i,t.centroid){const i=o.distanceToSquared(e.centroid,t);inew THREE.Vector3(t.x,t.y,t.z));return f.shift(),f}}},{"./AStar":79,"./Channel":81,"./utils":83}],83:[function(t,e,i){class o{static computeCentroids(t){var e,i,o;for(e=0,i=t.faces.length;e{e.indexOf(t)>=0&&i.push(t)}),i.length<2)return[];i.includes(t[0])&&i.includes(t[t.length-1])&&t.push(t.shift()),i.includes(e[0])&&i.includes(e[e.length-1])&&e.push(e.shift()),i=[],t.forEach(t=>{e.includes(t)&&i.push(t)});for(var o=i[1],n=i[0],s=t.slice();s[0]!==o;)s.push(s.shift());for(var r=0,a=e.slice();a[0]!==n;)if(a.push(a.shift()),r++>10)throw new Error("Unexpected state");return a.shift(),a.pop(),s=s.concat(a)}static setPolygonCentroid(t,e){var i=new THREE.Vector3,o=e.vertices;t.vertexIds.forEach(t=>{i.add(o[t])}),i.divideScalar(t.vertexIds.length),t.centroid.copy(i)}static cleanPolygon(t,e){for(var i=[],o=e.vertices,n=0;nMath.PI-.01&&p{e.vertexIds.includes(t.vertexIds[n])||d.push(e)}),t.neighbours=d}else i.push(t.vertexIds[n])}t.vertexIds=i,setPolygonCentroid(t,e)}static isConvex(t,e){var i=e.vertices;if(t.vertexIds.length<3)return!1;for(var o=!0,n=[],s=0;s{0===t&&(o=!1)}),n[0]>0?n.forEach(t=>{t<0&&(o=!1)}):n.forEach(t=>{t>0&&(o=!1)}),o}static distanceToSquared(t,e){var i=t.x-e.x,o=t.y-e.y,n=t.z-e.z;return i*i+o*o+n*n}static isPointInPoly(t,e){for(var i=!1,o=-1,n=t.length,s=n-1;++o{o=Math.min(i[t].y,o),n=Math.max(i[t].y,n),s.push(i[t])}),!!(t.yo-.5&&this.isPointInPoly(s,t))}static triarea2(t,e,i){var o=e.x-t.x,n=e.z-t.z;return(i.x-t.x)*n-o*(i.z-t.z)}static vequal(t,e){return this.distanceToSquared(t,e)<1e-5}static array_intersect(){let t,e,i,o,n,s,r=[],a={};for(s=arguments.length-1,i=arguments[0].length,e=0,t=0;t<=s;t++)(o=arguments[t].length)0;)!function(t,o){var n,s=T.length,r=[t],a=o.indexOf(t.visiblePoints.pop());for(;s-- >0;)(n=T[s])!==t&&e(n,o).dot(w.subVectors(o[a],o[n[0]]))>0&&r.push(n);var l,h,c,u,p=s=r.length,d=1===s,f=[],v=0,m=[];r[0][0],r[0][1],r[0][1],r[0][2],r[0][2],r[0][0];if(1===r.length)n=r[0],f=[n[0],n[1],n[1],n[2],n[2],n[0]],S.indexOf(n)>-1&&S.splice(S.indexOf(n),1),n.visiblePoints&&(m=m.concat(n.visiblePoints)),T.splice(T.indexOf(n),1);else for(;s-- >0;){n=r[s],S.indexOf(n)>-1&&S.splice(S.indexOf(n),1),n.visiblePoints&&(m=m.concat(n.visiblePoints)),T.splice(T.indexOf(n),1);var y;for(cEdgeIndex=0;cEdgeIndex<3;){for(y=!1,p=r.length,c=n[cEdgeIndex],u=n[(cEdgeIndex+1)%3];p-- >0&&!y;)if(l=r[p],v=0,l!==n)for(;v<3&&!y;)h=v+1,y=l[v]===c&&l[h%3]===u||l[v]===u&&l[h%3]===c,v++;y&&!d||(f.push(c),f.push(u)),cEdgeIndex++}}s=0;var g,b=f.length/2;for(;s0&&s[i[a].x/3]>0;);a+10&&(t.visiblePoints=i.splice(a+1))}var o,n,s,r,a,l,h,c,u,p,d,f,v,m,y,g,w,b,x,E,T=[],S=[],C=0,A=function(){var t=new THREE.Vector3,e=new THREE.Vector3,i=new THREE.Vector3;return function(o,n,s){return t.subVectors(s,o),e.subVectors(n,o),i.crossVectors(t,e),i.normalize()}}(),R=function(){var t=new THREE.Vector3,e=new THREE.Vector3,i=new THREE.Vector3;return function(o,n,s){t.subVectors(n,o),e.subVectors(s,o),i.subVectors(s,n);var r=e.dot(t);if(r<0)return e.dot(e);var a=t.dot(t);return r>=a?i.dot(i):e.dot(e)-r*r/a}}();return function(e){for(d=new THREE.Vector3,f=new THREE.Vector3,v=new THREE.Vector3,m=new THREE.Vector3,y=new THREE.Vector3,g=new THREE.Vector3,w=new THREE.Vector3,b=new THREE.Vector3,x=new THREE.Vector3,E=new THREE.Vector3,points=e.vertices,T=[],S=[],I=o=points.length,n=points.slice(0,6),C=0;I-- >0;)points[I].xn[1].x&&(n[1]=points[I]),points[I].y0;)for(r=I-1;r-- >0;)C<(s=n[I].distanceToSquared(n[r]))&&(C=s,a=n[I],l=n[r]);for(I=6,C=0;I-- >0;)s=R(a,l,n[I]),C0;)s=Math.abs(points[I].dot(u)-p),C0;)i(L[I],P,points),void 0!==L[I].visiblePoints&&S.push(L[I]),T.push(L[I]);t(points);for(var N=T.length;N-- >0;)e.faces[N]=new THREE.Face3(T[N][2],T[N][1],T[N][0],T[N].normal);return e.normalsNeedUpdate=!0,e}}()},{}],86:[function(t,e,i){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){var e=this.el;this.active&&this.checkpoint!==t&&(this.checkpoint&&e.emit("navigation-end",{checkpoint:this.checkpoint}),this.checkpoint=t,this.sync(),this.position.distanceTo(this.targetPosition)<.1?this.checkpoint=null:(e.emit("navigation-start",{checkpoint:t}),"teleport"===this.data.mode&&(this.el.setAttribute("position",this.targetPosition),this.checkpoint=null,e.emit("navigation-end",{checkpoint:t}))))},isVelocityActive:function(){return!(!this.active||!this.checkpoint)},getVelocity:function(){if(this.active){var t=this.data,e=this.offset,i=this.position,o=this.targetPosition,n=this.checkpoint;return this.sync(),i.distanceTo(o)<.1?(this.checkpoint=null,this.el.emit("navigation-end",{checkpoint:n}),e.set(0,0,0)):(e.setLength(t.animateSpeed),e)}},sync:function(){var t=this.offset,e=this.position,i=this.targetPosition;e.copy(this.el.getAttribute("position")),i.copy(this.checkpoint.object3D.getWorldPosition()),i.add(this.checkpoint.components.checkpoint.getOffset()),t.copy(i).sub(e)}}},{}],87:[function(t,e,i){var o=t("../../lib/GamepadButton"),n=t("../../lib/GamepadButtonEvent");e.exports={GamepadButton:o,schema:{controller:{default:0,oneOf:[0,1,2,3]},enabled:{default:!0},debug:{default:!1}},init:function(){var t=this.el.sceneEl;this.prevTime=window.performance.now(),this.buttons={},t.addBehavior(this)},update:function(){this.tick()},tick:function(){this.updateButtonState()},remove:function(){},isVelocityActive:function(){if(!this.data.enabled||!this.isConnected())return!1;var t=this.getDpad(),e=this.getJoystick(0),i=t.x||e.x,o=t.y||e.y;return Math.abs(i)>.2||Math.abs(o)>.2},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)>.2&&(n.x+=i),Math.abs(o)>.2&&(n.z+=o),n},isRotationActive:function(){if(!this.data.enabled||!this.isConnected())return!1;var t=this.getJoystick(1);return Math.abs(t.x)>.2||Math.abs(t.y)>.2},getRotationDelta:function(){var t=this.getJoystick(1);return Math.abs(t.x)<=.2&&(t.x=0),Math.abs(t.y)<=.2&&(t.y=0),t},updateButtonState:function(){var t=this.getGamepad();if(this.data.enabled&&t)for(var e=0;e.2?(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,s=0,r=n.rotationControls.length;s1?i.setLength(this.data.movementAcceleration*t/1e3):i.multiplyScalar(this.data.movementAcceleration*t/1e3);var a=this.el.getAttribute("rotation");a&&(this.heading.set(n.fly?THREE.Math.degToRad(a.x):0,THREE.Math.degToRad(a.y),0),i.applyEuler(this.heading)),o.add(i)}this.el.setAttribute("velocity",o)}}},{}],94:[function(t,e,i){function o(t){return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")}var n={once:THREE.LoopOnce,repeat:THREE.LoopRepeat,pingpong:THREE.LoopPingPong};e.exports={schema:{clip:{default:"*"},duration:{default:0},crossFadeDuration:{default:0},loop:{default:"repeat",oneOf:Object.keys(n)},repetitions:{default:1/0,min:0}},init:function(){this.model=null,this.mixer=null,this.activeActions=[];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){var e=this.el;this.model=t,this.mixer=new THREE.AnimationMixer(t),this.mixer.addEventListener("loop",function(t){e.emit("animation-loop",{action:t.action,loopDelta:t.loopDelta})}.bind(this)),this.mixer.addEventListener("finished",function(t){e.emit("animation-finished",{action:t.action,direction:t.direction})}.bind(this)),this.data.clip&&this.update({})},remove:function(){this.mixer&&this.mixer.stopAllAction()},update:function(t){t&&(this.stopAction(),this.data.clip&&this.playAction())},stopAction:function(){for(var t=this.data,e=0;e.5&&(r=l.id===u.bi.id?Math.abs(u.rj.y+u.bj.position.y):Math.abs(u.ri.y+u.bi.position.y))>c&&(c=r,o.copy(i),a=l.id===u.bi.id?u.bj:u.bi)}if(e.copy(t).normalize(),a&&e.y<.5?(h.enableSlopes?o.y<1-1e-6&&o.copy(this.raycastToGround(a,o)):o.set(0,1,0),t=t.projectOnPlane(o)):t.add(this.system.world.gravity.scale(4*s/1e3)),a&&a.el&&a.el.components.velocity){var d=a.el.getAttribute("velocity");l.position.copy({x:l.position.x+d.x*s/1e3,y:l.position.y+d.y*s/1e3,z:l.position.z+d.z*s/1e3}),this.el.setAttribute("position",l.position)}l.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))._updateDirection(),i.intersectBody(t),i.hasHit?(n=i.result.hitNormalWorld,Math.abs(n.y)>Math.abs(e.y)?n:e):e}}},{}],107:[function(t,e,i){e.exports={init:function(){this.el.addEventListener("model-loaded",function(t){t.detail.model.traverse(function(t){t.isMesh&&t.geometry.computeVertexNormals()})})}}},{}],108:[function(t,e,i){e.exports={schema:{objects:{default:""},state:{default:"collided"},radius:{default:.05},watch:{default:!0}},init:function(){this.observer=null,this.els=[],this.collisions=[],this.handleHit=this.handleHit.bind(this),this.handleHitEnd=this.handleHitEnd.bind(this)},remove:function(){this.pause()},play:function(){var t=this.el.sceneEl;this.data.watch&&(this.observer=new MutationObserver(this.update.bind(this,null)),this.observer.observe(t,{childList:!0,subtree:!0}))},pause:function(){this.observer&&(this.observer.disconnect(),this.observer=null)},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,i=(new THREE.Vector3,new THREE.Vector3),o=new Map;return function(){var n,s=this.el,r=this.data,a=[];s.getObject3D("mesh")&&(o.clear(),t.copy(s.object3D.getWorldPosition()),s.object3D.getWorldScale(i),n=r.radius*function(t){return Math.max.apply(null,t.toArray())}(i),this.els.forEach(function(i){var s,r,l,h,c,u;i.isEntity&&(r=i.getObject3D("mesh"))&&(u=(h=(new THREE.Box3).setFromObject(r)).getSize(),c=Math.max(u.x,u.y,u.z)/2,s=Math.sqrt(2*c*c),h.getCenter(e),s&&(l=t.distanceTo(e))o.get(e)?1:-1}).forEach(this.handleHit),0===a.length&&s.emit("hit",{el:null}),this.collisions.filter(function(t){return!o.has(t)}).forEach(this.handleHitEnd),this.collisions=a)}}(),handleHit:function(t){t.emit("hit"),t.addState(this.data.state),this.el.emit("hit",{el:t})},handleHitEnd:function(t){t.emit("hitend"),t.removeState(this.data.state),this.el.emit("hitend",{el:t})}}},{}],109:[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]