!function e(t,i,s){function n(l,h){if(!i[l]){if(!t[l]){var o="function"==typeof require&&require;if(!h&&o)return o(l,!0);if(r)return r(l,!0);var a=new Error("Cannot find module '"+l+"'");throw a.code="MODULE_NOT_FOUND",a}var c=i[l]={exports:{}};t[l][0].call(c.exports,function(e){var i=t[l][1][e];return n(i||e)},c,c.exports,e,t,i,s)}return i[l].exports}for(var r="function"==typeof require&&require,l=0;lt;t++)i.push(this._createVertex(t));for(this.cellShape=new THREE.Shape,this.cellShape.moveTo(i[0].x,i[0].y),t=1;6>t;t++)this.cellShape.lineTo(i[t].x,i[t].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*s.SQRT3*this._cellWidth,this._hashDelimeter=".",this._directions=[new s.Cell(1,-1,0),new s.Cell(1,0,-1),new s.Cell(0,1,-1),new s.Cell(-1,1,0),new s.Cell(-1,0,1),new s.Cell(0,-1,1)],this._diagonals=[new s.Cell(2,-1,-1),new s.Cell(1,1,-2),new s.Cell(-1,2,-1),new s.Cell(-2,1,1),new s.Cell(-1,-1,2),new s.Cell(1,-2,1)],this._list=[],this._vec3=new THREE.Vector3,this._cel=new s.Cell,this._conversionVec=new THREE.Vector3,this._geoCache=[],this._matCache=[]},s.HexGrid.TWO_THIRDS=2/3,s.HexGrid.prototype={cellToPixel:function(e){return this._vec3.x=e.q*this._cellWidth*.75,this._vec3.y=e.h,this._vec3.z=-(e.s-e.r)*this._cellLength*.5,this._vec3},pixelToCell:function(e){var t=e.x*(s.HexGrid.TWO_THIRDS/this.cellSize),i=(-e.x/3+s.SQRT3/3*e.z)/this.cellSize;return this._cel.set(t,i,-t-i),this._cubeRound(this._cel)},getCellAt:function(e){var t=e.x*(s.HexGrid.TWO_THIRDS/this.cellSize),i=(-e.x/3+s.SQRT3/3*e.z)/this.cellSize;return this._cel.set(t,i,-t-i),this._cubeRound(this._cel),this.cells[this.cellToHash(this._cel)]},getNeighbors:function(e,t,i){var s,n,r=this._directions.length;for(this._list.length=0,s=0;r>s;s++)this._cel.copy(e),this._cel.add(this._directions[s]),!(n=this.cells[this.cellToHash(this._cel)])||i&&!i(e,n)||this._list.push(n);if(t)for(s=0;r>s;s++)this._cel.copy(e),this._cel.add(this._diagonals[s]),!(n=this.cells[this.cellToHash(this._cel)])||i&&!i(e,n)||this._list.push(n);return this._list},getRandomCell:function(){var e,t=0,i=s.Tools.randomInt(0,this.numCells);for(e in this.cells){if(t===i)return this.cells[e];t++}return this.cells[e]},cellToHash:function(e){return e.q+this._hashDelimeter+e.r+this._hashDelimeter+e.s},distance:function(e,t){var i=Math.max(Math.abs(e.q-t.q),Math.abs(e.r-t.r),Math.abs(e.s-t.s));return i+=t.h-e.h},clearPath:function(){var e,t;for(e in this.cells)t=this.cells[e],t._calcCost=0,t._priority=0,t._parent=null,t._visited=!1},traverse:function(e){var t;for(t in this.cells)e(this.cells[t])},generateTile:function(e,t,i){var n=Math.abs(e.h);1>n&&(n=1);var r=this._geoCache[n];r||(this.extrudeSettings.amount=n,r=new THREE.ExtrudeGeometry(this.cellShape,this.extrudeSettings),this._geoCache[n]=r);var l=new s.Tile({size:this.cellSize,scale:t,cell:e,geometry:r,material:i});return e.tile=l,l},generateTiles:function(e){e=e||{};var t=[],i={tileScale:.95,cellSize:this.cellSize,material:null,extrudeSettings:{amount:1,bevelEnabled:!0,bevelSegments:1,steps:1,bevelSize:.5,bevelThickness:.5}};i=s.Tools.merge(i,e),this.cellSize=i.cellSize,this._cellWidth=2*this.cellSize,this._cellLength=.5*s.SQRT3*this._cellWidth,this.autogenerated=!0,this.extrudeSettings=i.extrudeSettings;var n,r,l;for(n in this.cells)l=this.cells[n],(r=this.generateTile(l,i.tileScale,i.material)).position.copy(this.cellToPixel(l)),r.position.y=0,t.push(r);return t},generateTilePoly:function(e){e||(e=new THREE.MeshBasicMaterial({color:2405631}));var t=new THREE.Mesh(this.cellShapeGeo,e);return this._vec3.set(1,0,0),t.rotateOnAxis(this._vec3,s.PI/2),t},generate:function(e){e=e||{},this.size=void 0===e.size?this.size:e.size;var t,i,n,r;for(t=-this.size;tn;n++)for(r=-e;e+1>r;r++)if(l=-n-r,Math.abs(n)<=e&&Math.abs(r)<=e&&Math.abs(l)<=e){this._cel.set(n,r,l);var o=new THREE.Line(h,i);o.position.copy(this.cellToPixel(this._cel)),o.rotation.x=90*s.DEG_TO_RAD,t.add(o)}},add:function(e){var t=this.cellToHash(e);if(!this.cells[t])return this.cells[t]=e,this.numCells++,e},remove:function(e){var t=this.cellToHash(e);this.cells[t]&&(delete this.cells[t],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(e,t,i){var n=this;s.Tools.getJSON({url:e,callback:function(e){n.fromJSON(e),t.call(i||null,e)},cache:!1,scope:n})},fromJSON:function(e){var t,i,n=e.cells;for(this.cells={},this.numCells=0,this.size=e.size,this.cellSize=e.cellSize,this._cellWidth=2*this.cellSize,this._cellLength=.5*s.SQRT3*this._cellWidth,this.extrudeSettings=e.extrudeSettings,this.autogenerated=e.autogenerated,t=0;tr&&n>l?t=-i-s:r>l?i=-t-s:s=-t-i,this._cel.set(t,i,s)}},s.HexGrid.prototype.constructor=s.HexGrid,s.SqrGrid=function(e){e=e||{},this.type=s.SQR,this.size=5,this.cellSize=void 0===e.cellSize?10:e.cellSize,this.cells={},this.numCells=0,this.extrudeSettings=null,this.autogenerated=!1;var t=[];t.push(new THREE.Vector3),t.push(new THREE.Vector3(-this.cellSize,this.cellSize)),t.push(new THREE.Vector3(this.cellSize,this.cellSize)),t.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=t,this.cellGeo.verticesNeedUpdate=!0,this.cellShapeGeo=new THREE.ShapeGeometry(this.cellShape),this._fullCellSize=2*this.cellSize,this._hashDelimeter=".",this._directions=[new s.Cell(1,0,0),new s.Cell(0,-1,0),new s.Cell(-1,0,0),new s.Cell(0,1,0)],this._diagonals=[new s.Cell(-1,-1,0),new s.Cell(-1,1,0),new s.Cell(1,1,0),new s.Cell(1,-1,0)],this._list=[],this._vec3=new THREE.Vector3,this._cel=new s.Cell,this._conversionVec=new THREE.Vector3,this._geoCache=[],this._matCache=[]},s.SqrGrid.prototype={cellToPixel:function(e){return this._vec3.x=e.q*this._fullCellSize,this._vec3.y=e.h,this._vec3.z=e.r*this._fullCellSize,this._vec3},pixelToCell:function(e){var t=Math.round(e.x/this._fullCellSize),i=Math.round(e.z/this._fullCellSize);return this._cel.set(t,i,0)},getCellAt:function(e){var t=Math.round(e.x/this._fullCellSize),i=Math.round(e.z/this._fullCellSize);return this._cel.set(t,i),this.cells[this.cellToHash(this._cel)]},getNeighbors:function(e,t,i){var s,n,r=this._directions.length;for(this._list.length=0,s=0;r>s;s++)this._cel.copy(e),this._cel.add(this._directions[s]),!(n=this.cells[this.cellToHash(this._cel)])||i&&!i(e,n)||this._list.push(n);if(t)for(s=0;r>s;s++)this._cel.copy(e),this._cel.add(this._diagonals[s]),!(n=this.cells[this.cellToHash(this._cel)])||i&&!i(e,n)||this._list.push(n);return this._list},getRandomCell:function(){var e,t=0,i=s.Tools.randomInt(0,this.numCells);for(e in this.cells){if(t===i)return this.cells[e];t++}return this.cells[e]},cellToHash:function(e){return e.q+this._hashDelimeter+e.r},distance:function(e,t){var i=Math.max(Math.abs(e.q-t.q),Math.abs(e.r-t.r));return i+=t.h-e.h},clearPath:function(){var e,t;for(e in this.cells)t=this.cells[e],t._calcCost=0,t._priority=0,t._parent=null,t._visited=!1},traverse:function(e){var t;for(t in this.cells)e(this.cells[t])},generateTile:function(e,t,i){var n=Math.abs(e.h);1>n&&(n=1);var r=this._geoCache[n];r||(this.extrudeSettings.amount=n,r=new THREE.ExtrudeGeometry(this.cellShape,this.extrudeSettings),this._geoCache[n]=r);var l=new s.Tile({size:this.cellSize,scale:t,cell:e,geometry:r,material:i});return e.tile=l,l},generateTiles:function(e){e=e||{};var t=[],i={tileScale:.95,cellSize:this.cellSize,material:null,extrudeSettings:{amount:1,bevelEnabled:!0,bevelSegments:1,steps:1,bevelSize:.5,bevelThickness:.5}};i=s.Tools.merge(i,e),this.cellSize=i.cellSize,this._fullCellSize=2*this.cellSize,this.autogenerated=!0,this.extrudeSettings=i.extrudeSettings;var n,r,l;for(n in this.cells)l=this.cells[n],(r=this.generateTile(l,i.tileScale,i.material)).position.copy(this.cellToPixel(l)),r.position.y=0,t.push(r);return t},generateTilePoly:function(e){e||(e=new THREE.MeshBasicMaterial({color:2405631}));var t=new THREE.Mesh(this.cellShapeGeo,e);return this._vec3.set(1,0,0),t.rotateOnAxis(this._vec3,s.PI/2),t},generate:function(e){e=e||{},this.size=void 0===e.size?this.size:e.size;var t,i,n,r=Math.ceil(this.size/2);for(t=-r;r>t;t++)for(i=-r;r>i;i++)n=new s.Cell(t,i+1),this.add(n)},generateOverlay:function(e,t,i){var n,r,l=Math.ceil(e/2);for(n=-l;l>n;n++)for(r=-l;l>r;r++){this._cel.set(n,r);var h=new THREE.Line(this.cellGeo,i);h.position.copy(this.cellToPixel(this._cel)),h.rotation.x=90*s.DEG_TO_RAD,t.add(h)}},add:function(e){var t=this.cellToHash(e);if(!this.cells[t])return this.cells[t]=e,this.numCells++,e},remove:function(e){var t=this.cellToHash(e);this.cells[t]&&(delete this.cells[t],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(e,t,i){s.Tools.getJSON({url:e,callback:function(e){this.fromJSON(e),t.call(i||null,e)},cache:!1,scope:this})},fromJSON:function(e){var t,i,n=e.cells;for(this.cells={},this.numCells=0,this.size=e.size,this.cellSize=e.cellSize,this._fullCellSize=2*this.cellSize,this.extrudeSettings=e.extrudeSettings,this.autogenerated=e.autogenerated,t=0;tt;t++)this.add(s[t])},remove:function(e){var t=this.getNode(e);return!(!t||t.free)&&(t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t.prev||(this.first=t.next),t.next||(this.last=t.prev),t.free=!0,t.prev=null,t.next=null,this.length--,!0)},shift:function(){var e=this.first;return 0===this.length?null:(e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),this.first=e.next,e.next||(this.last=null),e.free=!0,e.prev=null,e.next=null,this.length--,e.obj)},pop:function(){var e=this.last;return 0===this.length?null:(e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),this.last=e.prev,e.prev||(this.first=null),e.free=!0,e.prev=null,e.next=null,this.length--,e.obj)},concat:function(e){for(var t=e.first;t;)this.add(t.obj),t=t.next},clear:function(){for(var e=this.first;e;)e.free=!0,e=e.next;this.first=null,this.length=0},dispose:function(){for(var e=this.first;e;)e.obj=null,e=e.next;this.first=null,this.objToNodeMap=null},dump:function(e){console.log("===================="+e+"=====================");for(var t=this.first;t;)console.log("{"+t.obj.toString()+"} previous="+(t.prev?t.prev.obj:"NULL")),t=t.next();console.log("==================================="),console.log("Last: {"+(this.last?this.last.obj:"NULL")+"} First: {"+(this.first?this.first.obj:"NULL")+"}")}}).constructor=e,s.LinkedList=e}(),function(){var e=function(e,t,i,s,n){this._listener=t,this.isOnce=i,this.context=s,this.signal=e,this._priority=n||0};(e.prototype={active:!0,params:null,execute:function(e){var t,i;return this.active&&this._listener&&(i=this.params?this.params.concat(e):e,t=this._listener.apply(this.context,i),this.isOnce&&this.detach()),t},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=e;var t=function(){this._bindings=[],this._prevParams=null;var e=this;this.dispatch=function(){t.prototype.dispatch.apply(e,arguments)}};t.prototype={memorize:!1,_shouldPropagate:!0,active:!0,validateListener:function(e,t){if("function"!=typeof e)throw new Error("Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}",t))},_registerListener:function(t,i,s,n){var r,l=this._indexOfListener(t,s);if(-1!==l){if((r=this._bindings[l]).isOnce!==i)throw new Error("You cannot add"+(i?"":"Once")+"() then add"+(i?"Once":"")+"() the same listener without removing the relationship first.")}else r=new e(this,t,i,s,n),this._addBinding(r);return this.memorize&&this._prevParams&&r.execute(this._prevParams),r},_addBinding:function(e){var t=this._bindings.length;do{t--}while(this._bindings[t]&&e._priority<=this._bindings[t]._priority);this._bindings.splice(t+1,0,e)},_indexOfListener:function(e,t){for(var i,s=this._bindings.length;s--;)if((i=this._bindings[s])._listener===e&&i.context===t)return s;return-1},has:function(e,t){return-1!==this._indexOfListener(e,t)},add:function(e,t,i){return this.validateListener(e,"add"),this._registerListener(e,!1,t,i)},addOnce:function(e,t,i){return this.validateListener(e,"addOnce"),this._registerListener(e,!0,t,i)},remove:function(e,t){this.validateListener(e,"remove");var i=this._indexOfListener(e,t);return-1!==i&&(this._bindings[i]._destroy(),this._bindings.splice(i,1)),e},removeAll:function(e){void 0===e&&(e=null);for(var t=this._bindings.length;t--;)e?this._bindings[t].context===e&&(this._bindings[t]._destroy(),this._bindings.splice(t,1)):this._bindings[t]._destroy();e||(this._bindings.length=0)},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(){if(this.active){var e,t=Array.prototype.slice.call(arguments),i=this._bindings.length;if(this.memorize&&(this._prevParams=t),i){e=this._bindings.slice(),this._shouldPropagate=!0;do{i--}while(e[i]&&this._shouldPropagate&&!1!==e[i].execute(t))}}},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()+"]"}},t.prototype.constructor=t,s.Signal=t}(),s.AStarFinder=function(e){e=e||{};var t={allowDiagonal:!1,heuristicFilter:null};t=s.Tools.merge(t,e),this.allowDiagonal=t.allowDiagonal,this.heuristicFilter=t.heuristicFilter,this.list=new s.LinkedList},s.AStarFinder.prototype={findPath:function(e,t,i,n){var r,l,h,o,a,c;for(i=i||this.heuristicFilter,n.clearPath(),this.list.clear(),this.list.add(e);this.list.length>0;){if(this.list.sort(this.compare),r=this.list.shift(),r._visited=!0,r===t)return s.PathUtil.backtrace(t);for(a=0,c=(h=n.getNeighbors(r,this.allowDiagonal,i)).length;c>a;a++)if((o=h[a]).walkable&&(l=r._calcCost+n.distance(r,o),!o._visited||le?1:-1,r=s>t?1:-1,o=l-h;e!==i||t!==s;)u.push([e,t]),(a=2*o)>-h&&(o-=h,e+=n),l>a&&(o+=l,t+=r);return u},expandPath:function(e){var t,i,s,n,r,l,h=[],o=e.length;if(2>o)return h;for(r=0;o-1>r;++r)for(t=e[r],i=e[r+1],s=this.interpolate(t[0],t[1],i[0],i[1]),n=s.length,l=0;n-1>l;++l)h.push(s[l]);return h.push(e[o-1]),h},smoothenPath:function(e,t){var i,s,n,r,l,h,o,a,c,u,d,p,f=t.length,g=t[0][0],m=t[0][1],v=t[f-1][0],_=t[f-1][1];for(l=[[i=g,s=m]],o=2;f>o;++o){for(n=(c=t[o])[0],r=c[1],u=this.interpolate(i,s,n,r),p=!1,a=1;a0?(e=i[0],t=e.object.userData.structure,this.pickedObject!=t&&(this.pickedObject&&this.signal.dispatch(s.MouseCaster.OUT,this.pickedObject),this.pickedObject=t,this.selectedObject=null,this.signal.dispatch(s.MouseCaster.OVER,this.pickedObject)),this.position.copy(e.point),this.screenPosition.z=e.distance):(this.pickedObject&&this.signal.dispatch(s.MouseCaster.OUT,this.pickedObject),this.pickedObject=null,this.selectedObject=null),this.allHits=i}},preventDefault:function(){this._preventDefault=!0},_onDocumentMouseDown:function(e){return(e=e||window.event).preventDefault(),this._preventDefault?(this._preventDefault=!1,!1):(this.pickedObject&&(this.selectedObject=this.pickedObject),this.shift=e.shiftKey,this.ctrl=e.ctrlKey,this.down=1===e.which,this.rightDown=3===e.which,void this.signal.dispatch(s.MouseCaster.DOWN,this.pickedObject))},_onDocumentMouseUp:function(e){return e.preventDefault(),this._preventDefault?(this._preventDefault=!1,!1):(this.shift=e.shiftKey,this.ctrl=e.ctrlKey,this.signal.dispatch(s.MouseCaster.UP,this.pickedObject),this.selectedObject&&this.pickedObject&&this.selectedObject.uniqueID===this.pickedObject.uniqueID&&this.signal.dispatch(s.MouseCaster.CLICK,this.pickedObject),this.down=1!==e.which&&this.down,void(this.rightDown=3!==e.which&&this.rightDown))},_onDocumentMouseMove:function(e){e.preventDefault(),this.screenPosition.x=e.clientX/window.innerWidth*2-1,this.screenPosition.y=-e.clientY/window.innerHeight*2+1},_onMouseWheel:function(e){if(this.active){e.preventDefault(),e.stopPropagation();var t=0;void 0!==e.wheelDelta?t=e.wheelDelta:void 0!==e.detail&&(t=-e.detail),t>0?this.wheel++:this.wheel--,this.signal.dispatch(s.MouseCaster.WHEEL,this.wheel)}}},s.MouseCaster.prototype.constructor=s.MouseCaster,s.Scene=function(e,t){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=s.Tools.merge(i,e),"boolean"!=typeof t&&(n=s.Tools.merge(n,t)),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 r=window.innerWidth/this.orthoZoom,l=window.innerHeight/this.orthoZoom;this.camera=new THREE.OrthographicCamera(r/-2,r/2,l/2,l/-2,1,5e3)}else this.camera=new THREE.PerspectiveCamera(50,this.width/this.height,1,5e3);this.contolled=!!t,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 e=this.width/this.orthoZoom,t=this.height/this.orthoZoom;this.camera.left=e/-2,this.camera.right=e/2,this.camera.top=t/2,this.camera.bottom=t/-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)},s.Scene.prototype={attachTo:function(e){e.style.width=this.width+"px",e.style.height=this.height+"px",this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),e.appendChild(this.renderer.domElement)},add:function(e){this.container.add(e)},remove:function(e){this.container.remove(e)},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 e=this.width/this.orthoZoom,t=this.height/this.orthoZoom;this.camera.left=e/-2,this.camera.right=e/2,this.camera.top=t/2,this.camera.bottom=t/-2,this.camera.updateProjectionMatrix()}},focusOn:function(e){this.camera.lookAt(e.position)}},s.Scene.prototype.constructor=s.Scene,s.SelectionManager=function(e){this.mouse=e,this.onSelect=new s.Signal,this.onDeselect=new s.Signal,this.selected=null,this.toggleSelection=!1,this.mouse.signal.add(this.onMouse,this)},s.SelectionManager.prototype={select:function(e,t){e&&(t=t||!0,this.selected!==e&&this.clearSelection(t),e.selected?this.toggleSelection&&(t&&this.onDeselect.dispatch(e),e.deselect()):e.select(),this.selected=e,t&&this.onSelect.dispatch(e))},clearSelection:function(e){e=e||!0,this.selected&&(e&&this.onDeselect.dispatch(this.selected),this.selected.deselect()),this.selected=null},onMouse:function(e,t){switch(e){case s.MouseCaster.DOWN:t||this.clearSelection();break;case s.MouseCaster.CLICK:this.select(t)}}},s.SelectionManager.prototype.constructor=s.SelectionManager,s.Tools={clamp:function(e,t,i){return Math.max(t,Math.min(i,e))},sign:function(e){return e&&e/Math.abs(e)},random:function(e,t){return 1===arguments.length?Math.random()*e-.5*e:Math.random()*(t-e)+e},randomInt:function(e,t){return 1===arguments.length?Math.random()*e-.5*e|0:Math.random()*(t-e+1)+e|0},normalize:function(e,t,i){return(e-t)/(i-t)},getShortRotation:function(e){return(e%=this.TAU)>this.PI?e-=this.TAU:e<-this.PI&&(e+=this.TAU),e},generateID:function(){return Math.random().toString(36).slice(2)+Date.now()},isPlainObject:function(e){if("object"!=typeof e||e.nodeType||e===e.window)return!1;try{if(e.constructor&&!Object.prototype.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(e){return!1}return!0},merge:function(e,t){var i=this,s=Array.isArray(t),n=s&&[]||{};return s?(e=e||[],n=n.concat(e),t.forEach(function(t,s){void 0===n[s]?n[s]=t:i.isPlainObject(t)?n[s]=i.merge(e[s],t):-1===e.indexOf(t)&&n.push(t)}),n):(e&&i.isPlainObject(e)&&Object.keys(e).forEach(function(t){n[t]=e[t]}),Object.keys(t).forEach(function(s){t[s]&&i.isPlainObject(t[s])&&e[s]?n[s]=i.merge(e[s],t[s]):n[s]=t[s]}),n)},now:function(){return window.nwf?window.nwf.system.Performance.elapsedTime:window.performance.now()},empty:function(e){for(;e.lastChild;)e.removeChild(e.lastChild)},radixSort:function(e,t,i,s){if(t=t||0,i=i||e.length,s=s||31,!(t>=i-1||0>s)){for(var n=t,r=i,l=1<n;)if(e[n]&l){--r;var h=e[n];e[n]=e[r],e[r]=h}else++n;this.radixSort(e,t,r,s-1),this.radixSort(e,r,i,s-1)}},randomizeRGB:function(e,t){var i,s,n=e.split(","),r="rgb(";for(t=this.randomInt(t),i=0;3>i;i++)0>(s=parseInt(n[i])+t)?s=0:s>255&&(s=255),r+=s+",";return r=r.substring(0,r.length-1),r+=")"},getJSON:function(e){var t=new XMLHttpRequest,i=void 0!==e.cache&&e.cache?e.url:e.url+"?t="+Math.floor(1e4*Math.random())+Date.now();t.onreadystatechange=function(){if(200!==this.status)0!==this.status&&console.warn("[Tools.getJSON] Error: "+this.status+" ("+this.statusText+") :: "+e.url);else{var t=null;try{t=JSON.parse(this.responseText)}catch(e){return}e.callback.call(e.scope||null,t)}},t.open("GET",i,!0),t.setRequestHeader("Accept","application/json"),t.setRequestHeader("Content-Type","application/json"),t.send("")}}},{}],4:[function(e,t,i){var s=t.exports={defaultComponents:{geometry:{primitive:"plane",width:75,height:75},rotation:{x:-90,y:0,z:0},material:{src:"url(https://cdn.rawgit.com/donmccurdy/aframe-extras/v1.16.3/assets/grid.png)",repeat:"75 75"}},mappings:{width:"geometry.width",height:"geometry.height",src:"material.src"}};t.exports.registerAll=function(){var e=!1;return function(t){e||((t=t||window.AFRAME).registerPrimitive("a-grid",s),e=!0)}}()},{}],5:[function(e,t,i){var s=e("../../lib/hex-grid.min.js"),n=e("../../lib/default-hex-grid.json"),r=t.exports.Primitive={defaultComponents:{hexgrid:{}},mappings:{src:"hexgrid.src"}},l=t.exports.Component={dependencies:["material"],schema:{src:{type:"asset"}},init:function(){var e=this.data;e.src?fetch(e.src).then(function(e){e.json()}).then(function(e){this.addMesh(e)}):this.addMesh(n)},addMesh:function(e){var t=new s.HexGrid;t.fromJSON(e);var i=new s.Board(t);i.generateTilemap(),this.el.setObject3D("mesh",i.group),this.addMaterial()},addMaterial:function(){var e=(this.el.components.material||{}).material;e&&this.el.object3D.traverse(function(t){t.isMesh&&(t.material=e)})},remove:function(){this.el.removeObject3D("mesh")}};t.exports.registerAll=function(){var e=!1;return function(t){e||((t=t||window.AFRAME).registerComponent("hexgrid",l),t.registerPrimitive("a-hexgrid",r),e=!0)}}()},{"../../lib/default-hex-grid.json":2,"../../lib/hex-grid.min.js":3}],6:[function(e,t,i){var s=t.exports.Primitive={defaultComponents:{ocean:{},rotation:{x:-90,y:0,z:0}},mappings:{width:"ocean.width",depth:"ocean.depth",density:"ocean.density",color:"ocean.color",opacity:"ocean.opacity"}},n=t.exports.Component={schema:{width:{default:10,min:0},depth:{default:10,min:0},density:{default:10},amplitude:{default:.1},amplitudeVariance:{default:.3},speed:{default:1},speedVariance:{default:2},color:{default:"#7AD2F7",type:"color"},opacity:{default:.8}},play:function(){var e=this.el,t=this.data,i=e.components.material,s=new THREE.PlaneGeometry(t.width,t.depth,t.density,t.density);s.mergeVertices(),this.waves=[];for(var n,r=0,l=s.vertices.length;r