├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── index.html ├── resources ├── img │ └── HexGrid.png └── js │ └── source.js └── vendors ├── bootsrap ├── bootstrap.min.css └── bootstrap.min.js ├── honeycomb.min.js ├── jquery-3.3.1.js ├── jquery-3.3.1.slim.min.js ├── pixi.min.js ├── popper.min.js ├── reimg.js ├── simplex-noise.js └── viewport.js /.gitattributes: -------------------------------------------------------------------------------- 1 | * linguist-vendored 2 | *.js linguist-vendored=false -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | 63 | .idea -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 José Manuel Pérez Sevilla 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HTML5 Procedural Hexagon Terrain Generator 2 | 3 | [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/JoseManuelPerezSevilla/ProceduralHexTerrainGenerator/blob/master/LICENSE) 4 | 5 | A basic and customizable procedural hexagon terrain generator made in Javascript. 6 | 7 | ### Demo 8 | 9 | You can see the generator working at the [Demo Page](https://hextoryworld.github.io/ProceduralHexTerrainGenerator/). 10 | 11 | Also, you can play with a more visual appealing [Tiled version](https://hextoryworld.github.io/TiledProceduralHexTerrainGenerator/) of this terrain generator. 12 | 13 | ![HTML5 Procedural Hexagon Terrain Generator](https://hextoryworld.github.io/ProceduralHexTerrainGenerator/resources/img/HexGrid.png) 14 | 15 | ### HexGrid Settings 16 | 17 | - Edge size 18 | - Orientation (flat, pointy) 19 | - Number of hexes (columns,rows) 20 | - Show / hide coordinates 21 | - Show / hide grid border 22 | - Line Thickness 23 | - Contour Interval 24 | - Terrain Archetype 25 | - Deep Water 26 | - Shallow Water 27 | - Flat 28 | - Hill 29 | - Mountain 30 | - Mountain Impassable 31 | 32 | ### Elevation Noise 33 | - Seed 34 | - Frequency 35 | - Redistribution 36 | - Octaves 37 | - Islands 38 | 39 | ### Moisture Noise 40 | - Seed 41 | - Frequency 42 | - Redistribution 43 | - Octaves 44 | - No draw moisture 45 | 46 | ### Biomes 47 | - Water 48 | - Flat 49 | - Desert 50 | - Grassland 51 | - Forest 52 | - Hill 53 | - Desert 54 | - Grassland 55 | - Mixed Forest 56 | - Needleleaf Forest 57 | - Mountain 58 | - Desert 59 | - Shrubland 60 | - Alpine Forest 61 | - Mountain Impassable 62 | - Snow 63 | 64 | ### Map Seed 65 | Copy to save the map setings and restore. 66 | 67 | ### Viewport 68 | 69 | - Drag 70 | - Wheel Zoom 71 | - Bounce 72 | - Hex Info on click: Coordinates, elevation, moisture, terrain and biome. 73 | 74 | ### Export as PNG 75 | Actually you can export the terrain generated to png. 76 | 77 | ### Libraries 78 | 79 | - [Honeycomb](https://github.com/flauwekeul/honeycomb) v3.1.0 80 | - [PixiJS](http://www.pixijs.com/) v5.1.5 81 | - [pixi-viewport](https://github.com/davidfig/pixi-viewport) v4.3.3 82 | - [reimg](https://github.com/gillyb/reimg) 83 | - [Bootstrap](https://getbootstrap.com/) v4.3.1 84 | - [jQuery](https://jquery.com/) v3.3.1 85 | - [Popper.js](https://popper.js.org/) v1.14.7 86 | - [simplex-noise.js](https://github.com/jwagner/simplex-noise.js) v2.4.0 87 | 88 | ### Reference 89 | 90 | - [Tutorial de generación de mapas aleatorios con Python y OpenSimplex](https://robologs.net/2018/04/09/tutorial-de-generacion-de-mapas-aleatorios-con-python-y-opensimplex/) 91 | - [Making maps with noise functions](https://www.redblobgames.com/maps/terrain-from-noise/) 92 | - [Here Dragon Abound](https://heredragonsabound.blogspot.com/) 93 | - [mewo2.com Generating fantasy maps](http://mewo2.com/notes/terrain/) 94 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Basic Procedural Hexagon Terrain Generator 20 | 21 | 22 | 23 |
24 |
25 | 28 | 31 | 34 | 37 | 40 | 43 | 46 |
47 |
48 | 49 |
50 | 51 |
52 | 53 | 54 | 138 | 139 | 140 | 211 | 212 | 281 | 282 | 316 | 380 | 381 | -------------------------------------------------------------------------------- /resources/img/HexGrid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HextoryWorld/ProceduralHexTerrainGenerator/9d44d8028025b81b33502d7f6a61d6d47b0ee9d8/resources/img/HexGrid.png -------------------------------------------------------------------------------- /resources/js/source.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | window.onload = function() { 4 | 5 | let settings = getDefaultSettings(); 6 | updateSettingsModal(settings); 7 | 8 | let canvas = document.getElementById("canvas"); 9 | let app = new PIXI.Application({ width: settings.screenW, height: settings.screenH, transparent: true, preserveDrawingBuffer:true, view: canvas }); 10 | 11 | const viewport = initializeViewport(app, settings); 12 | 13 | loadGrid(app, viewport, settings); 14 | 15 | $("#gridSettingsModal").submit(function() { 16 | viewport.destroy({children: true}); 17 | for (let i = app.stage.children.length - 1; i >= 0; i--) { 18 | app.stage.removeChild(app.stage.children[i]); 19 | } 20 | applySettings(app); 21 | return false; 22 | }); 23 | 24 | $("#elevationModal").submit(function() { 25 | viewport.destroy({children: true}); 26 | for (let i = app.stage.children.length - 1; i >= 0; i--) { 27 | app.stage.removeChild(app.stage.children[i]); 28 | } 29 | applySettings(app); 30 | return false; 31 | }); 32 | 33 | $("#moistureModal").submit(function() { 34 | viewport.destroy({children: true}); 35 | for (let i = app.stage.children.length - 1; i >= 0; i--) { 36 | app.stage.removeChild(app.stage.children[i]); 37 | } 38 | applySettings(app); 39 | return false; 40 | }); 41 | 42 | $("#mapHashModal").submit(function() { 43 | viewport.destroy({children: true}); 44 | for (let i = app.stage.children.length - 1; i >= 0; i--) { 45 | app.stage.removeChild(app.stage.children[i]); 46 | } 47 | applySettings(app); 48 | return false; 49 | }); 50 | 51 | $("#redraw").click(function() { 52 | viewport.destroy({children: true}); 53 | for (let i = app.stage.children.length - 1; i >= 0; i--) { 54 | app.stage.removeChild(app.stage.children[i]); 55 | } 56 | applySettings(app); 57 | return false; 58 | }); 59 | 60 | $("#reset").click(function() { 61 | 62 | settings = getDefaultSettings(); 63 | updateSettingsModal(settings); 64 | 65 | viewport.destroy({children: true}); 66 | for (let i = app.stage.children.length - 1; i >= 0; i--) { 67 | app.stage.removeChild(app.stage.children[i]); 68 | } 69 | applySettings(app); 70 | return false; 71 | }); 72 | 73 | window.onresize = function() { 74 | let width = ( window.innerWidth - 100 > 1140 ) ? 1140 : window.innerWidth - 100; 75 | let height = window.innerHeight - 100; 76 | app.renderer.resize(width, height); 77 | }; 78 | }; 79 | 80 | function getDefaultSettings() { 81 | 82 | let width = ( window.innerWidth - 100 > 1140 ) ? 1140 : window.innerWidth - 100; 83 | let height = window.innerHeight - 100; 84 | let colums = ( Math.ceil( width / 15 ) > 75) ? 75 : Math.ceil( width / 15 ); 85 | let rows = ( Math.ceil( height / ( 10 * 1.731 ) ) > 30) ? 30 : Math.ceil( height / ( 10 * 1.731 ) ); 86 | 87 | return { 88 | screenW: width, 89 | screenH: height, 90 | hexSize: 10, 91 | hexOrientation: 'flat', 92 | hexColums: colums, // x 93 | hexRows: rows, // y 94 | lineThickness: 1, 95 | lineColor: 0x999999, 96 | hideCoords: true, 97 | hideGrid: false, 98 | contourInterval_0: 0.2, 99 | contourInterval_1: 0.3, 100 | contourInterval_2: 0.5, 101 | contourInterval_3: 0.7, 102 | contourInterval_4: 0.9, 103 | // Elevation Noise 104 | elevationSeed: 'fdc9a9ca516c78d1f830948badf1875d88424406', 105 | setElevationSeed: false, 106 | frequencyElevation: 0.8, 107 | redistributionElevation: 1.0, 108 | elevationOctaves_0: 1, 109 | elevationOctaves_1: 0.5, 110 | elevationOctaves_2: 0.25, 111 | elevationOctaves_3: 0.12, 112 | createIsland: false, 113 | // Moisture Noise 114 | moistureSeed: 'd049b358d128cb265740a90fce37904ce07cd653', 115 | setMoistureSeed: false, 116 | drawMoisture: true, 117 | frequencyMoisture: 0.8, 118 | redistributionMoisture: 1.0, 119 | moistureOctaves_0: 1, 120 | moistureOctaves_1: 0.5, 121 | moistureOctaves_2: 0.25, 122 | moistureOctaves_3: 0.12 123 | } 124 | } 125 | 126 | function updateSettingsModal(settings) { 127 | // Grid 128 | $('#hexSize').val(settings.hexSize); 129 | $('#hexOrientation').val(settings.hexOrientation); 130 | $('#hexColums').val(settings.hexColums); 131 | $('#hexRows').val(settings.hexRows); 132 | $('#lineThickness').val(settings.lineThickness); 133 | $('#hideCoords').prop('checked', settings.hideCoords); 134 | $('#hideGrid').prop('checked', settings.hideGrid); 135 | $('#contourInterval_0').val(settings.contourInterval_0); 136 | $('#contourInterval_1').val(settings.contourInterval_1); 137 | $('#contourInterval_2').val(settings.contourInterval_2); 138 | $('#contourInterval_3').val(settings.contourInterval_3); 139 | $('#contourInterval_4').val(settings.contourInterval_4); 140 | // Elevation Noise 141 | $('#elevationSeed').val(settings.elevationSeed); 142 | $('#setElevationSeed').prop('checked', settings.setElevationSeed); 143 | $('#frequencyElevation').val(settings.frequencyElevation); 144 | $('#redistributionElevation').val(settings.redistributionElevation); 145 | $('#elevationOctaves_0').val(settings.elevationOctaves_0); 146 | $('#elevationOctaves_1').val(settings.elevationOctaves_1); 147 | $('#elevationOctaves_2').val(settings.elevationOctaves_2); 148 | $('#elevationOctaves_3').val(settings.elevationOctaves_3); 149 | $('#createIsland').prop('checked', settings.createIsland); 150 | // Moisture Noise 151 | $('#moistureSeed').val(settings.moistureSeed); 152 | $('#setMoistureSeed').prop('checked', settings.setMoistureSeed); 153 | $('#drawMoisture').prop('checked', settings.drawMoisture); 154 | $('#frequencyMoisture').val(settings.frequencyMoisture); 155 | $('#redistributionMoisture').val(settings.redistributionMoisture); 156 | $('#moistureOctaves_0').val(settings.moistureOctaves_0); 157 | $('#moistureOctaves_1').val(settings.moistureOctaves_1); 158 | $('#moistureOctaves_2').val(settings.moistureOctaves_2); 159 | $('#moistureOctaves_3').val(settings.moistureOctaves_3); 160 | // Map Hash 161 | $('#setMapHash').prop('checked', false); 162 | $('#mapHash').val(btoa(JSON.stringify(settings))); 163 | } 164 | 165 | function initializeViewport(app, settings) { 166 | 167 | let worldWidth = settings.hexColums * (settings.hexSize + (settings.hexSize / 2)) + (settings.hexSize / 2); 168 | let worldHeight = settings.hexRows * (settings.hexSize * 1.731) + (settings.hexSize * 1.731 / 2); 169 | if (settings.hexOrientation === 'pointy') { 170 | worldWidth = settings.hexColums * (settings.hexSize * 1.731) + (settings.hexSize * 1.731 / 2); 171 | worldHeight = settings.hexRows * (settings.hexSize + (settings.hexSize / 2)) + (settings.hexSize / 2); 172 | } 173 | 174 | const viewport = new Viewport.Viewport({ 175 | screenWidth: app.view.offsetWidth, 176 | screenHeight: app.view.offsetHeight, 177 | worldWidth: worldWidth, 178 | worldHeight: worldHeight, 179 | 180 | interaction: app.renderer.plugins.interaction // the interaction module is important for wheel to work properly when renderer.view is placed or scaled 181 | }); 182 | 183 | app.stage.addChild(viewport); 184 | 185 | viewport 186 | .drag() 187 | .wheel() 188 | .bounce(); 189 | 190 | return viewport; 191 | } 192 | 193 | function loadGrid(app, viewport, settings) { 194 | if (!$('#setMapHash').is(":checked")) $('#mapHash').val(btoa(JSON.stringify(settings))); 195 | let Hex = Honeycomb.extendHex({ size: settings.hexSize, orientation: settings.hexOrientation }); 196 | let Grid = Honeycomb.defineGrid(Hex); 197 | let elevation = heightMap(settings); 198 | let moisture = moistureMap(settings); 199 | let gridColor = 0x000000; 200 | 201 | // render hex grid 202 | let gr = Grid.rectangle({ width: settings.hexColums, height: settings.hexRows }); 203 | gr.forEach(hex => { 204 | let graphics = new PIXI.Graphics(); 205 | let coords = hex.cartesian(); 206 | hex.elevation = elevation[coords.x][coords.y]; 207 | hex.moisture = moisture[coords.x][coords.y]; 208 | if (hex.elevation < settings.contourInterval_0) { 209 | hex.archetype = "Deep Water"; 210 | hex.terrainColor = "#2E3359"; 211 | hex.biome = "Water"; 212 | hex.biomeColor = "#2E3359"; 213 | if (settings.hideGrid) gridColor = 0x2E3359; 214 | graphics.lineStyle(settings.lineThickness, gridColor); 215 | graphics.beginFill(0x2E3359); 216 | } 217 | else if (hex.elevation < settings.contourInterval_1) { 218 | hex.archetype = "Shallow Water"; 219 | hex.terrainColor = "#29557A"; 220 | hex.biome = "Water"; 221 | hex.biomeColor = "#29557A"; 222 | if (settings.hideGrid) gridColor = 0x29557A; 223 | graphics.lineStyle(settings.lineThickness, gridColor); 224 | graphics.beginFill(0x29557A); 225 | } 226 | else if (hex.elevation < settings.contourInterval_2) { 227 | hex.archetype = "Flat"; 228 | let mapColor = 0x9A9C2F; // value for elevation only map 229 | hex.terrainColor = "#9A9C2F"; // https://mycolor.space/?hex=%239A9C2F&sub=1 230 | 231 | if (settings.drawMoisture) { 232 | if (hex.moisture < 0.16) { 233 | hex.biome = "Desert"; 234 | mapColor = 0xF6F2CB; 235 | hex.biomeColor = "#F6F2CB"; 236 | } 237 | else if (hex.moisture < 0.6) { 238 | hex.biome = "Grass"; 239 | mapColor = 0x8bba31; 240 | hex.biomeColor = "#8bba31"; 241 | } 242 | else { 243 | hex.biome = "Forest"; 244 | mapColor = 0x00aa26; 245 | hex.biomeColor = "#00aa26"; 246 | } 247 | } 248 | 249 | if (settings.hideGrid) gridColor = mapColor; 250 | graphics.lineStyle(settings.lineThickness, gridColor); 251 | graphics.beginFill(mapColor); 252 | } 253 | else if (hex.elevation < settings.contourInterval_3) { 254 | hex.archetype = "Hill"; 255 | let mapColor = 0x895543; // value for elevation only map 256 | hex.terrainColor = "#895543"; // https://mycolor.space/?hex=%23895543&sub=1 257 | 258 | if (settings.drawMoisture) { 259 | if (hex.moisture < 0.16) { 260 | hex.biome = "Desert"; 261 | mapColor = 0xffd687; 262 | hex.biomeColor = "#ffd687"; 263 | } 264 | else if (hex.moisture < 0.50) { 265 | hex.biome = "Grass"; 266 | mapColor = 0x859051; 267 | hex.biomeColor = "#859051"; 268 | } 269 | else if (hex.moisture < 0.80) { 270 | hex.biome = "Mixed Forest"; 271 | mapColor = 0x377657; 272 | hex.biomeColor = "#377657"; 273 | } 274 | else { 275 | hex.biome = "Needleleaf Forest"; 276 | mapColor = 0x4c6a41; 277 | hex.biomeColor = "#4c6a41"; 278 | } 279 | } 280 | 281 | if (settings.hideGrid) gridColor = mapColor; 282 | graphics.lineStyle(settings.lineThickness, gridColor); 283 | graphics.beginFill(mapColor); 284 | } 285 | else if (hex.elevation < settings.contourInterval_4) { 286 | // Mountain / Montaña 287 | hex.archetype = "Mountain"; 288 | // desertica, verde o matorral, bosque alpino 289 | let mapColor = 0x654321; // value without moisture 290 | hex.terrainColor = "#654321"; 291 | 292 | if (settings.drawMoisture) { 293 | if (hex.moisture < 0.33) { 294 | hex.biome = "Desert"; 295 | mapColor = 0xc49f53; 296 | hex.biomeColor = "#c49f53"; 297 | } 298 | else if (hex.moisture < 0.66) { 299 | hex.biome = "Shrubland"; 300 | mapColor = 0x8c6c28; 301 | hex.biomeColor = "#8c6c28"; 302 | } 303 | else { 304 | hex.biome = "Alpine forest"; 305 | mapColor = 0x634800; 306 | hex.biomeColor = "#634800"; 307 | } 308 | } 309 | 310 | if (settings.hideGrid) gridColor = mapColor; 311 | graphics.lineStyle(settings.lineThickness, gridColor); 312 | graphics.beginFill(mapColor); 313 | } 314 | else { 315 | // Mountain impassable 316 | hex.archetype = "Mountain impassable"; 317 | hex.terrainColor = "#DCDCDC"; 318 | hex.biome = "Snow"; 319 | hex.biomeColor = "#DCDCDC"; 320 | if (settings.hideGrid) gridColor = 0xDCDCDC; 321 | graphics.lineStyle(settings.lineThickness, gridColor); 322 | graphics.beginFill(0xDCDCDC); 323 | } 324 | 325 | const point = hex.toPoint(); 326 | // add the hex's position to each of its corner points 327 | const corners = hex.corners().map(corner => corner.add(point)); 328 | // separate the first from the other corners 329 | const [firstCorner, ...otherCorners] = corners; 330 | 331 | // move the "pen" to the first corner 332 | graphics.moveTo(firstCorner.x, firstCorner.y); 333 | // draw lines to the other corners 334 | otherCorners.forEach(({ x, y }) => graphics.lineTo(x, y)); 335 | // finish at the first corner 336 | graphics.lineTo(firstCorner.x, firstCorner.y); 337 | 338 | graphics.endFill(); 339 | 340 | viewport.addChild(graphics); 341 | }); 342 | 343 | function onClick (event) { 344 | const hexCoordinates = Grid.pointToHex(event.world.x, event.world.y); 345 | if (!gr.get(hexCoordinates)) return; 346 | 347 | $('#hColumn').val(hexCoordinates.x); 348 | $('#hRow').val(hexCoordinates.y); 349 | $('#xCoord').val(event.world.x.toFixed(2)); 350 | $('#yCoord').val(event.world.y.toFixed(2)); 351 | 352 | let hex = gr.get(hexCoordinates); 353 | $('#hElevation').val(hex.elevation.toFixed(3)); 354 | $('#hMoisture').val(hex.moisture.toFixed(3)); 355 | $('#hTerrain').val(hex.archetype); 356 | $('#hBiome').val(hex.biome); 357 | $("#terrainColor").text(hex.terrainColor); 358 | $("#terrainColor").css('color', 'white'); 359 | $("#terrainColorRow").css('background-color', hex.terrainColor); 360 | if ($('#drawMoisture').is(":checked")) { 361 | $("#biomeColor").text(hex.biomeColor); 362 | $("#biomeColor").css('color', 'white'); 363 | $("#biomeColorRow").css('background-color', hex.biomeColor); 364 | } 365 | 366 | $('#hexInfoModal').modal('show'); 367 | } 368 | 369 | viewport.on('clicked', onClick); 370 | 371 | 372 | if (settings.hideCoords === true) return; 373 | 374 | gr.forEach(hex => { 375 | const point = hex.toPoint(); 376 | const centerPosition = hex.center().add(point); 377 | const coordinates = hex.coordinates(); 378 | 379 | let fontSize = 12; 380 | if (settings.hexSize < 15) fontSize = settings.hexSize / 1.5; 381 | 382 | let text = new PIXI.Text(coordinates.x + ','+ coordinates.y,{fontFamily : 'Arial', fontSize: fontSize, fill : 0x000000, align : 'center'}); 383 | 384 | text.x = centerPosition.x; 385 | text.y = centerPosition.y; 386 | text.anchor.set(0.5); 387 | 388 | viewport.addChild(text); 389 | }); 390 | 391 | } 392 | 393 | function applySettings(app, viewport) { 394 | 395 | let width = ( window.innerWidth - 100 > 1140 ) ? 1140 : window.innerWidth - 100; 396 | let height = window.innerHeight - 100; 397 | 398 | let settings = {}; 399 | if ($('#setMapHash').is(":checked")) { 400 | settings = JSON.parse(atob($('#mapHash').val())); 401 | } else { 402 | // Grid 403 | settings.screenW = width; 404 | settings.screenH = height - 100; 405 | settings.hexSize = parseInt($('#hexSize').val()) || 36; 406 | settings.hexOrientation = $('#hexOrientation').val() || 'flat'; 407 | settings.hexColums = parseInt($('#hexColums').val()) || (width - 100) / 54; 408 | settings.hexRows = parseInt($('#hexRows').val()) || (height - 100) / 72; 409 | settings.lineThickness = parseInt($('#lineThickness').val()) || 2; 410 | settings.lineColor = 0x999999; 411 | settings.hideCoords = $('#hideCoords').is(":checked"); 412 | settings.hideGrid = $('#hideGrid').is(":checked"); 413 | settings.contourInterval_0 = parseFloat($('#contourInterval_0').val()) || 0.2; 414 | settings.contourInterval_1 = parseFloat($('#contourInterval_1').val()) || 0.3; 415 | settings.contourInterval_2 = parseFloat($('#contourInterval_2').val()) || 0.5; 416 | settings.contourInterval_3 = parseFloat($('#contourInterval_3').val()) || 0.7; 417 | settings.contourInterval_4 = parseFloat($('#contourInterval_4').val()) || 0.9; 418 | //Elevation Noise 419 | settings.setElevationSeed = $('#setElevationSeed').is(":checked"); 420 | if (settings.setElevationSeed) { 421 | settings.elevationSeed = $('#elevationSeed').val(); 422 | } else { 423 | settings.elevationSeed = generateId(); 424 | $('#elevationSeed').val(settings.elevationSeed); 425 | } 426 | settings.frequencyElevation = parseFloat($('#frequencyElevation').val()) || 0.8; 427 | settings.redistributionElevation = parseFloat($('#redistributionElevation').val()) || 1.0; 428 | settings.elevationOctaves_0 = parseFloat($('#elevationOctaves_0').val()) || 1; 429 | settings.elevationOctaves_1 = parseFloat($('#elevationOctaves_1').val()) || 0.5; 430 | settings.elevationOctaves_2 = parseFloat($('#elevationOctaves_2').val()) || 0.25; 431 | settings.elevationOctaves_3 = parseFloat($('#elevationOctaves_3').val()) || 0.12; 432 | settings.createIsland = $('#createIsland').is(":checked"); 433 | // Moisture Noise 434 | settings.setMoistureSeed = $('#setMoistureSeed').is(":checked"); 435 | if (settings.setMoistureSeed) { 436 | settings.moistureSeed = $('#moistureSeed').val(); 437 | } else { 438 | settings.moistureSeed = generateId(); 439 | $('#moistureSeed').val(settings.moistureSeed); 440 | } 441 | settings.drawMoisture = $('#drawMoisture').is(":checked"); 442 | settings.frequencyMoisture = parseFloat($('#frequencyMoisture').val()) || 0.8; 443 | settings.redistributionMoisture = parseFloat($('#redistributionMoisture').val()) || 1.0; 444 | settings.moistureOctaves_0 = parseFloat($('#moistureOctaves_0').val()) || 1; 445 | settings.moistureOctaves_1 = parseFloat($('#moistureOctaves_1').val()) || 0.5; 446 | settings.moistureOctaves_2 = parseFloat($('#moistureOctaves_2').val()) || 0.25; 447 | settings.moistureOctaves_3 = parseFloat($('#moistureOctaves_3').val()) || 0.12; 448 | } 449 | 450 | viewport = initializeViewport(app, settings); 451 | 452 | loadGrid(app, viewport, settings); 453 | 454 | $("#gridSettingsModal").modal("hide"); 455 | $("#elevationModal").modal("hide"); 456 | $("#moistureModal").modal("hide"); 457 | $("#mapHashModal").modal("hide"); 458 | } 459 | 460 | function downloadCanvasAsPng() { 461 | ReImg.fromCanvas(document.querySelector('canvas')).downloadPng('hexGrid.png'); 462 | } 463 | 464 | function heightMap(settings) { 465 | const simplex = new SimplexNoise(settings.elevationSeed); 466 | let elevation = [[]]; 467 | let freq = settings.frequencyElevation; // increase has a zoom out effect, decrease for zoom in 468 | for (let x = 0; x < settings.hexColums; x++) { 469 | elevation[x] = []; 470 | for (let y = 0; y < settings.hexRows; y++) { 471 | let nx = (x / settings.hexColums) * freq; 472 | let ny = (y / settings.hexRows) * freq; 473 | 474 | let e = settings.elevationOctaves_0 * simplex.noise2D(nx, ny) 475 | + settings.elevationOctaves_1 * simplex.noise2D(4*nx, 4*ny) 476 | + settings.elevationOctaves_2 * simplex.noise2D(8*nx, 8*ny) 477 | + settings.elevationOctaves_3 * simplex.noise2D(16*nx, 16*ny); 478 | e = (e + 1) / 2; // from -1 to 1 --> from 0 to 1 479 | 480 | if (settings.createIsland) { 481 | let xp = (x / settings.hexColums); 482 | let yp = (y / settings.hexRows); 483 | let d = Math.hypot(0.5-xp, 0.5-yp); 484 | e = (1 + e - (d * 3.5)) / 2; 485 | } 486 | 487 | if (e < 0) e = 0; 488 | if (e > 1) e = 1; 489 | 490 | elevation[x][y] = Math.pow(e, settings.redistributionElevation); 491 | } 492 | } 493 | 494 | return elevation; 495 | } 496 | 497 | function moistureMap(settings) { 498 | const simplex = new SimplexNoise(settings.moistureSeed); 499 | let moisture = [[]]; 500 | let freq = settings.frequencyMoisture; // increase has a zoom out effect, decrease for zoom in 501 | for (let x = 0; x < settings.hexColums; x++) { 502 | moisture[x] = []; 503 | for (let y = 0; y < settings.hexRows; y++) { 504 | let nx = (x / settings.hexColums) * freq; 505 | let ny = (y / settings.hexRows) * freq; 506 | 507 | let m = settings.moistureOctaves_0 * simplex.noise2D(nx, ny) 508 | + settings.moistureOctaves_1 * simplex.noise2D(4*nx, 4*ny) 509 | + settings.moistureOctaves_2 * simplex.noise2D(8*nx, 8*ny) 510 | + settings.moistureOctaves_3 * simplex.noise2D(16*nx, 16*ny); 511 | m = (m + 1) / 2; // from -1 to 1 --> from 0 to 1 512 | if (m < 0) m = 0; 513 | if (m > 1) m = 1; 514 | moisture[x][y] = Math.pow(m, settings.redistributionMoisture); 515 | } 516 | } 517 | 518 | return moisture; 519 | } 520 | 521 | function dec2hex (dec) { 522 | return ('0' + dec.toString(16)).substr(-2) 523 | } 524 | 525 | // generateId :: Integer -> String 526 | function generateId (len) { 527 | let arr = new Uint8Array((len || 40) / 2); 528 | window.crypto.getRandomValues(arr); 529 | return Array.from(arr, dec2hex).join('') 530 | } -------------------------------------------------------------------------------- /vendors/bootsrap/bootstrap.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap v4.3.1 (https://getbootstrap.com/) 3 | * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) 4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 5 | */ 6 | !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("jquery"),require("popper.js")):"function"==typeof define&&define.amd?define(["exports","jquery","popper.js"],e):e((t=t||self).bootstrap={},t.jQuery,t.Popper)}(this,function(t,g,u){"use strict";function i(t,e){for(var n=0;nthis._items.length-1||t<0))if(this._isSliding)g(this._element).one(Q.SLID,function(){return e.to(t)});else{if(n===t)return this.pause(),void this.cycle();var i=ndocument.documentElement.clientHeight;!this._isBodyOverflowing&&t&&(this._element.style.paddingLeft=this._scrollbarWidth+"px"),this._isBodyOverflowing&&!t&&(this._element.style.paddingRight=this._scrollbarWidth+"px")},t._resetAdjustments=function(){this._element.style.paddingLeft="",this._element.style.paddingRight=""},t._checkScrollbar=function(){var t=document.body.getBoundingClientRect();this._isBodyOverflowing=t.left+t.right
',trigger:"hover focus",title:"",delay:0,html:!1,selector:!1,placement:"top",offset:0,container:!1,fallbackPlacement:"flip",boundary:"scrollParent",sanitize:!0,sanitizeFn:null,whiteList:Ee},je="show",He="out",Re={HIDE:"hide"+De,HIDDEN:"hidden"+De,SHOW:"show"+De,SHOWN:"shown"+De,INSERTED:"inserted"+De,CLICK:"click"+De,FOCUSIN:"focusin"+De,FOCUSOUT:"focusout"+De,MOUSEENTER:"mouseenter"+De,MOUSELEAVE:"mouseleave"+De},xe="fade",Fe="show",Ue=".tooltip-inner",We=".arrow",qe="hover",Me="focus",Ke="click",Qe="manual",Be=function(){function i(t,e){if("undefined"==typeof u)throw new TypeError("Bootstrap's tooltips require Popper.js (https://popper.js.org/)");this._isEnabled=!0,this._timeout=0,this._hoverState="",this._activeTrigger={},this._popper=null,this.element=t,this.config=this._getConfig(e),this.tip=null,this._setListeners()}var t=i.prototype;return t.enable=function(){this._isEnabled=!0},t.disable=function(){this._isEnabled=!1},t.toggleEnabled=function(){this._isEnabled=!this._isEnabled},t.toggle=function(t){if(this._isEnabled)if(t){var e=this.constructor.DATA_KEY,n=g(t.currentTarget).data(e);n||(n=new this.constructor(t.currentTarget,this._getDelegateConfig()),g(t.currentTarget).data(e,n)),n._activeTrigger.click=!n._activeTrigger.click,n._isWithActiveTrigger()?n._enter(null,n):n._leave(null,n)}else{if(g(this.getTipElement()).hasClass(Fe))return void this._leave(null,this);this._enter(null,this)}},t.dispose=function(){clearTimeout(this._timeout),g.removeData(this.element,this.constructor.DATA_KEY),g(this.element).off(this.constructor.EVENT_KEY),g(this.element).closest(".modal").off("hide.bs.modal"),this.tip&&g(this.tip).remove(),this._isEnabled=null,this._timeout=null,this._hoverState=null,(this._activeTrigger=null)!==this._popper&&this._popper.destroy(),this._popper=null,this.element=null,this.config=null,this.tip=null},t.show=function(){var e=this;if("none"===g(this.element).css("display"))throw new Error("Please use show on visible elements");var t=g.Event(this.constructor.Event.SHOW);if(this.isWithContent()&&this._isEnabled){g(this.element).trigger(t);var n=_.findShadowRoot(this.element),i=g.contains(null!==n?n:this.element.ownerDocument.documentElement,this.element);if(t.isDefaultPrevented()||!i)return;var o=this.getTipElement(),r=_.getUID(this.constructor.NAME);o.setAttribute("id",r),this.element.setAttribute("aria-describedby",r),this.setContent(),this.config.animation&&g(o).addClass(xe);var s="function"==typeof this.config.placement?this.config.placement.call(this,o,this.element):this.config.placement,a=this._getAttachment(s);this.addAttachmentClass(a);var l=this._getContainer();g(o).data(this.constructor.DATA_KEY,this),g.contains(this.element.ownerDocument.documentElement,this.tip)||g(o).appendTo(l),g(this.element).trigger(this.constructor.Event.INSERTED),this._popper=new u(this.element,o,{placement:a,modifiers:{offset:this._getOffset(),flip:{behavior:this.config.fallbackPlacement},arrow:{element:We},preventOverflow:{boundariesElement:this.config.boundary}},onCreate:function(t){t.originalPlacement!==t.placement&&e._handlePopperPlacementChange(t)},onUpdate:function(t){return e._handlePopperPlacementChange(t)}}),g(o).addClass(Fe),"ontouchstart"in document.documentElement&&g(document.body).children().on("mouseover",null,g.noop);var c=function(){e.config.animation&&e._fixTransition();var t=e._hoverState;e._hoverState=null,g(e.element).trigger(e.constructor.Event.SHOWN),t===He&&e._leave(null,e)};if(g(this.tip).hasClass(xe)){var h=_.getTransitionDurationFromElement(this.tip);g(this.tip).one(_.TRANSITION_END,c).emulateTransitionEnd(h)}else c()}},t.hide=function(t){var e=this,n=this.getTipElement(),i=g.Event(this.constructor.Event.HIDE),o=function(){e._hoverState!==je&&n.parentNode&&n.parentNode.removeChild(n),e._cleanTipClass(),e.element.removeAttribute("aria-describedby"),g(e.element).trigger(e.constructor.Event.HIDDEN),null!==e._popper&&e._popper.destroy(),t&&t()};if(g(this.element).trigger(i),!i.isDefaultPrevented()){if(g(n).removeClass(Fe),"ontouchstart"in document.documentElement&&g(document.body).children().off("mouseover",null,g.noop),this._activeTrigger[Ke]=!1,this._activeTrigger[Me]=!1,this._activeTrigger[qe]=!1,g(this.tip).hasClass(xe)){var r=_.getTransitionDurationFromElement(n);g(n).one(_.TRANSITION_END,o).emulateTransitionEnd(r)}else o();this._hoverState=""}},t.update=function(){null!==this._popper&&this._popper.scheduleUpdate()},t.isWithContent=function(){return Boolean(this.getTitle())},t.addAttachmentClass=function(t){g(this.getTipElement()).addClass(Ae+"-"+t)},t.getTipElement=function(){return this.tip=this.tip||g(this.config.template)[0],this.tip},t.setContent=function(){var t=this.getTipElement();this.setElementContent(g(t.querySelectorAll(Ue)),this.getTitle()),g(t).removeClass(xe+" "+Fe)},t.setElementContent=function(t,e){"object"!=typeof e||!e.nodeType&&!e.jquery?this.config.html?(this.config.sanitize&&(e=Se(e,this.config.whiteList,this.config.sanitizeFn)),t.html(e)):t.text(e):this.config.html?g(e).parent().is(t)||t.empty().append(e):t.text(g(e).text())},t.getTitle=function(){var t=this.element.getAttribute("data-original-title");return t||(t="function"==typeof this.config.title?this.config.title.call(this.element):this.config.title),t},t._getOffset=function(){var e=this,t={};return"function"==typeof this.config.offset?t.fn=function(t){return t.offsets=l({},t.offsets,e.config.offset(t.offsets,e.element)||{}),t}:t.offset=this.config.offset,t},t._getContainer=function(){return!1===this.config.container?document.body:_.isElement(this.config.container)?g(this.config.container):g(document).find(this.config.container)},t._getAttachment=function(t){return Pe[t.toUpperCase()]},t._setListeners=function(){var i=this;this.config.trigger.split(" ").forEach(function(t){if("click"===t)g(i.element).on(i.constructor.Event.CLICK,i.config.selector,function(t){return i.toggle(t)});else if(t!==Qe){var e=t===qe?i.constructor.Event.MOUSEENTER:i.constructor.Event.FOCUSIN,n=t===qe?i.constructor.Event.MOUSELEAVE:i.constructor.Event.FOCUSOUT;g(i.element).on(e,i.config.selector,function(t){return i._enter(t)}).on(n,i.config.selector,function(t){return i._leave(t)})}}),g(this.element).closest(".modal").on("hide.bs.modal",function(){i.element&&i.hide()}),this.config.selector?this.config=l({},this.config,{trigger:"manual",selector:""}):this._fixTitle()},t._fixTitle=function(){var t=typeof this.element.getAttribute("data-original-title");(this.element.getAttribute("title")||"string"!==t)&&(this.element.setAttribute("data-original-title",this.element.getAttribute("title")||""),this.element.setAttribute("title",""))},t._enter=function(t,e){var n=this.constructor.DATA_KEY;(e=e||g(t.currentTarget).data(n))||(e=new this.constructor(t.currentTarget,this._getDelegateConfig()),g(t.currentTarget).data(n,e)),t&&(e._activeTrigger["focusin"===t.type?Me:qe]=!0),g(e.getTipElement()).hasClass(Fe)||e._hoverState===je?e._hoverState=je:(clearTimeout(e._timeout),e._hoverState=je,e.config.delay&&e.config.delay.show?e._timeout=setTimeout(function(){e._hoverState===je&&e.show()},e.config.delay.show):e.show())},t._leave=function(t,e){var n=this.constructor.DATA_KEY;(e=e||g(t.currentTarget).data(n))||(e=new this.constructor(t.currentTarget,this._getDelegateConfig()),g(t.currentTarget).data(n,e)),t&&(e._activeTrigger["focusout"===t.type?Me:qe]=!1),e._isWithActiveTrigger()||(clearTimeout(e._timeout),e._hoverState=He,e.config.delay&&e.config.delay.hide?e._timeout=setTimeout(function(){e._hoverState===He&&e.hide()},e.config.delay.hide):e.hide())},t._isWithActiveTrigger=function(){for(var t in this._activeTrigger)if(this._activeTrigger[t])return!0;return!1},t._getConfig=function(t){var e=g(this.element).data();return Object.keys(e).forEach(function(t){-1!==Oe.indexOf(t)&&delete e[t]}),"number"==typeof(t=l({},this.constructor.Default,e,"object"==typeof t&&t?t:{})).delay&&(t.delay={show:t.delay,hide:t.delay}),"number"==typeof t.title&&(t.title=t.title.toString()),"number"==typeof t.content&&(t.content=t.content.toString()),_.typeCheckConfig(be,t,this.constructor.DefaultType),t.sanitize&&(t.template=Se(t.template,t.whiteList,t.sanitizeFn)),t},t._getDelegateConfig=function(){var t={};if(this.config)for(var e in this.config)this.constructor.Default[e]!==this.config[e]&&(t[e]=this.config[e]);return t},t._cleanTipClass=function(){var t=g(this.getTipElement()),e=t.attr("class").match(Ne);null!==e&&e.length&&t.removeClass(e.join(""))},t._handlePopperPlacementChange=function(t){var e=t.instance;this.tip=e.popper,this._cleanTipClass(),this.addAttachmentClass(this._getAttachment(t.placement))},t._fixTransition=function(){var t=this.getTipElement(),e=this.config.animation;null===t.getAttribute("x-placement")&&(g(t).removeClass(xe),this.config.animation=!1,this.hide(),this.show(),this.config.animation=e)},i._jQueryInterface=function(n){return this.each(function(){var t=g(this).data(Ie),e="object"==typeof n&&n;if((t||!/dispose|hide/.test(n))&&(t||(t=new i(this,e),g(this).data(Ie,t)),"string"==typeof n)){if("undefined"==typeof t[n])throw new TypeError('No method named "'+n+'"');t[n]()}})},s(i,null,[{key:"VERSION",get:function(){return"4.3.1"}},{key:"Default",get:function(){return Le}},{key:"NAME",get:function(){return be}},{key:"DATA_KEY",get:function(){return Ie}},{key:"Event",get:function(){return Re}},{key:"EVENT_KEY",get:function(){return De}},{key:"DefaultType",get:function(){return ke}}]),i}();g.fn[be]=Be._jQueryInterface,g.fn[be].Constructor=Be,g.fn[be].noConflict=function(){return g.fn[be]=we,Be._jQueryInterface};var Ve="popover",Ye="bs.popover",ze="."+Ye,Xe=g.fn[Ve],$e="bs-popover",Ge=new RegExp("(^|\\s)"+$e+"\\S+","g"),Je=l({},Be.Default,{placement:"right",trigger:"click",content:"",template:''}),Ze=l({},Be.DefaultType,{content:"(string|element|function)"}),tn="fade",en="show",nn=".popover-header",on=".popover-body",rn={HIDE:"hide"+ze,HIDDEN:"hidden"+ze,SHOW:"show"+ze,SHOWN:"shown"+ze,INSERTED:"inserted"+ze,CLICK:"click"+ze,FOCUSIN:"focusin"+ze,FOCUSOUT:"focusout"+ze,MOUSEENTER:"mouseenter"+ze,MOUSELEAVE:"mouseleave"+ze},sn=function(t){var e,n;function i(){return t.apply(this,arguments)||this}n=t,(e=i).prototype=Object.create(n.prototype),(e.prototype.constructor=e).__proto__=n;var o=i.prototype;return o.isWithContent=function(){return this.getTitle()||this._getContent()},o.addAttachmentClass=function(t){g(this.getTipElement()).addClass($e+"-"+t)},o.getTipElement=function(){return this.tip=this.tip||g(this.config.template)[0],this.tip},o.setContent=function(){var t=g(this.getTipElement());this.setElementContent(t.find(nn),this.getTitle());var e=this._getContent();"function"==typeof e&&(e=e.call(this.element)),this.setElementContent(t.find(on),e),t.removeClass(tn+" "+en)},o._getContent=function(){return this.element.getAttribute("data-content")||this.config.content},o._cleanTipClass=function(){var t=g(this.getTipElement()),e=t.attr("class").match(Ge);null!==e&&0=this._offsets[o]&&("undefined"==typeof this._offsets[o+1]||t>1}function u(t,n){return(t%n+n)%n}function c(t,n){if(!/^(N|S)?(E|W)?$/i.test(t))throw new Error("Invalid compass direction: ".concat(t,". Choose from E, SE, S, SW, W, NW, N or NE."));if(n=n.toLowerCase(),t=t.toUpperCase(),"pointy"===n&&["N","S"].includes(t))throw new Error("Direction ".concat(t," is ambiguous for pointy hexes. Did you mean ").concat(t,"E or ").concat(t,"W?"));if("flat"===n&&["E","W"].includes(t))throw new Error("Direction ".concat(t," is ambiguous for flat hexes. Did you mean N").concat(t," or S").concat(t,"?"));return{pointy:{E:0,SE:1,SW:2,W:3,NW:4,NE:5},flat:{SE:0,S:1,SW:2,NW:3,N:4,NE:5}}[n][t]}function a(t,n){return r(t)||r(n)?r(t)?r(n)||(n=t):t=n:t=n=0,{x:t,y:n}}const h=[{q:1,r:0,s:-1},{q:0,r:1,s:-1},{q:-1,r:1,s:0},{q:-1,r:0,s:1},{q:0,r:-1,s:1},{q:1,r:-1,s:0}],l=[{q:2,r:-1,s:-1},{q:1,r:1,s:-2},{q:-1,r:2,s:-1},{q:-2,r:1,s:1},{q:-1,r:-1,s:2},{q:1,r:-2,s:1}],f={x:1e-6,y:1e-6};function d(t){return r(t)?this[t]:this[this.indexOf(t)]}function x(t){let{isValidHex:n}=t;return function(t,e){if(!n(e))return this;const i=r(t)?t:this.indexOf(t);return i<0?this.push(e):this[i]=e,this}}function y(t,n){const e=t.distance(n),r=1/Math.max(e,1);let i=[];for(let o=0;o<=e;o++){const e=t.nudge().lerp(n.nudge(),r*o).round();i.push(this.get(e))}return i}function g(t){let{isValidHex:n}=t;return function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!n(t))throw new Error("Invalid center hex: ".concat(t,"."));if(!this.get(t))throw new Error("Center hex with coordinates ".concat(t," not present in grid."));let i=[];for(let n=-e;n<=e;n++)for(let o=Math.max(-e,-n-e);o<=Math.min(e,-n+e);o++){const e=this.get(t.cubeToCartesian({q:t.q+n,r:t.r+o}));t.equals(e)&&!r||i.push(e)}return i.filter(Boolean)}}function p(t){let{isValidHex:n,signedModulo:e,compassToNumberDirection:r}=t;return function(t){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all",s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!n(t))throw new Error("Invalid hex: ".concat(t,"."));const u=s?l:h;return"all"===i&&(i=[0,1,2,3,4,5]),[].concat(i).map(n=>{o(n)&&(n=r(n,t.orientation)),(n<0||n>5)&&(n=e(n,6));const{q:i,r:s}=u[n];return this.get(t.cubeToCartesian({q:t.q+i,r:t.r+s}))})}}function b(){if(0===this.length)return 0;const{0:t,length:n,[n-1]:e}=this[0].isPointy()?[...this].sort((t,n)=>n.s-t.s||t.q-n.q):[...this].sort((t,n)=>t.q-n.q);return e.toPoint().x-t.toPoint().x+this[0].width()}function q(){if(0===this.length)return 0;const{0:t,length:n,[n-1]:e}=this[0].isPointy()?[...this].sort((t,n)=>t.r-n.r):[...this].sort((t,n)=>n.s-t.s||t.r-n.r);return e.toPoint().y-t.toPoint().y+this[0].height()}function P(t){let{Hex:n}=t;return function(t,e){return n().fromPoint(t,e)}}function w(t){let{Grid:n,Hex:e}=t;return function(t){let{width:r,height:i,start:o,direction:s=1,onCreate:u=(()=>{})}=t;o=e(o);const[c,a,h]={1:["q","r","s"],3:["r","s","q"],5:["s","q","r"]}[s],l=new n;l.width=r,l.height=i,l.start=o,l.direction=s;for(let t=0;t{})}=t;i=e(i);const u={1:{rStart:()=>0,rEnd:t=>r-t},5:{rStart:t=>r-t,rEnd:()=>r+1}},{rStart:c,rEnd:a}=u[o],h=new n;h.size=r,h.start=i,h.direction=o;for(let t=0;t{})}=t;i=e(i);const s=new n;s.radius=r,s.center=i;for(let t=-r;t<=r;t++){const n=Math.max(-r,-t-r),u=Math.min(r,-t+r);for(let r=n;r<=u;r++){const n=e({q:t+i.q,r:r+i.r,s:-t-r+i.s});o(n,s),s.push(n)}}return s}}function O(t){let{Grid:n,Hex:e,compassToNumberDirection:r,signedModulo:i}=t;return function(t){let{width:u,height:c,start:a,direction:h=(e().isPointy()?0:1),onCreate:l=(()=>{})}=t;a=e(a),o(h)&&(h=r(h,a.orientation)),(h<0||h>5)&&(h=i(h,6));const[f,d,x]=[["q","r","s"],["r","q","s"],["r","s","q"],["s","r","q"],["s","q","r"],["q","s","r"]][h],[y,g]=a.isPointy()?[u,c]:[c,u],p=new n;p.width=u,p.height=c,p.start=a,p.direction=h;for(let t=0;t{})}=t;i=e(i);const s=new n;s.radius=r,s.center=i;const{q:u,r:c,s:a}=i;let l=e({q:u,r:c-r,s:a+r});for(let t=0;t<6;t++)for(let n=0;n{})}=t;i=e(i);let s=new n;o(i,s),s.push(i);for(let t=1;t<=r;t++)s=s.concat(this.ring({radius:t,center:i,onCreate:o}));return s.radius=r,s.center=i,s}}function M(t){let{Point:n}=t;return function(t,e){let r;return({x:r,y:e}=n(t,e)),n(this.x+r,this.y+e)}}function E(t){let{Point:n}=t;return function(t,e){let r;return({x:r,y:e}=n(t,e)),n(this.x-r,this.y-e)}}function C(t){let{Point:n}=t;return function(t,e){let r;return({x:r,y:e}=n(t,e)),n(this.x*r,this.y*e)}}function S(t){let{Point:n}=t;return function(t,e){let r;return({x:r,y:e}=n(t,e)),n(this.x/r,this.y/e)}}function N(t){let{ensureXY:n}=t;const o={add:M({Point:s}),subtract:E({Point:s}),multiply:C({Point:s}),divide:S({Point:s})};function s(t,s){let u;return u=r(t)?n(t,s):i(t)?n(...t):e(t)?n(t.x,t.y):n(0),Object.assign(Object.create(o),u)}return s}const R=N({ensureXY:a});class G extends Array{static isValidHex(t){return!0===(t||{}).__isHoneycombHex}fill(){throw new TypeError("Grid.prototype.fill is not implemented")}includes(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return!!(this.indexOf(t,n)+1)}indexOf(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const{length:e}=this;let r=Number(n);for(t=R(t),r=Math.max(r>=0?r:e+r,0);r1&&void 0!==arguments[1]?arguments[1]:this.length-1;const{length:e}=this;let r=Number(n);for(t=R(t),r=r>=0?Math.min(r,e-1):e+r;r>=0;r--)if(this[r].equals(t))return r;return-1}push(){for(var t=arguments.length,n=new Array(t),e=0;e2?e-2:0),i=2;i=0||(i[e]=t[e]);return i}(t,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(t,e)&&(i[e]=t[e])}return i}function W(t){let{Hex:n}=t;return function(){return Object.assign(this,n(...arguments))}}function A(){return{x:this.x,y:this.y}}function I(){return{q:this.q,r:this.r,s:this.s}}function _(t){let n,e,{q:r,r:i}=t;return this.isPointy()?(n=r+s(this.offset,i),e=i):(n=r,e=i+s(this.offset,r)),{x:n,y:e}}function X(t){let{Point:n}=t;return function(t,e){let r,i,o;return({x:r,y:e}=n(t,e)),this.isPointy()?(i=r-s(this.offset,e),o=e):(i=r,o=e-s(this.offset,r)),{q:i,r:o,s:-i-o}}}function Y(){return"pointy"===this.orientation.toLowerCase()}function B(){return"flat"===this.orientation.toLowerCase()}function L(){const{xRadius:t}=this.size;return this.isPointy()?t*Math.sqrt(3):2*t}function k(){const{yRadius:t}=this.size;return this.isPointy()?2*t:t*Math.sqrt(3)}function F(t){let{Point:n}=t;return function(){const t=this.width(),e=this.height(),{x:r,y:i}=this.origin;return this.isPointy()?[n(t-r,.25*e-i),n(t-r,.75*e-i),n(.5*t-r,e-i),n(0-r,.75*e-i),n(0-r,.25*e-i),n(.5*t-r,0-i)]:[n(t-r,.5*e-i),n(.75*t-r,e-i),n(.25*t-r,e-i),n(0-r,.5*e-i),n(.25*t-r,0-i),n(.75*t-r,0-i)]}}function U(t){let{Point:n}=t;return function(){const{x:t,y:e}=this.origin;return n(this.width()/2-t,this.height()/2-e)}}function J(t){let{Point:n}=t;return function(){const{q:t,r:e,size:r}=this,{xRadius:i,yRadius:o}=r;let s,u;return this.isPointy()?(s=i*Math.sqrt(3)*(t+e/2),u=3*o/2*e):(s=3*i/2*t,u=o*Math.sqrt(3)*(e+t/2)),n(s,u)}}function $(t){let{Point:n,Hex:e}=t;return function(t,r){const{xRadius:i,yRadius:o}=this.size;let s,u,c;return({x:s,y:r}=n(t,r).subtract(this.center())),this.isPointy()?(u=Math.sqrt(3)*s/(3*i)-r/(3*o),c=2/3*(r/o)):(u=2/3*(s/i),c=Math.sqrt(3)*r/(3*o)-s/(3*i)),e({q:u,r:c,s:-u-c}).round()}}function K(t){let{Hex:n,Point:e}=t;return function(t){const{x:r,y:i}=e(t);return n(this.x+r,this.y+i,z({},this))}}function Q(t){let{Hex:n,Point:e}=t;return function(t){const{x:r,y:i}=e(t);return n(this.x-r,this.y-i,z({},this))}}function Z(t){let{Point:n}=t;return function(t){if(null!=t&&(i(t)||r(t.x)&&r(t.y))){const{x:e,y:r}=n(t);return this.x===e&&this.y===r}return!1}}function tt(t){return Math.max(Math.abs(this.q-t.q),Math.abs(this.r-t.r),Math.abs(this.s-t.s))}function nt(t){let{Hex:n}=t;return function(){let{q:t,r:e,s:r}=this,i=Math.round(t),o=Math.round(e),s=Math.round(r);const u=Math.abs(t-i),c=Math.abs(e-o),a=Math.abs(r-s);return u>c&&u>a?i=-o-s:c>a?o=-i-s:s=-i-o,n(z({},this,{q:i,r:o,s:s}))}}function et(t){let{Hex:n}=t;return function(t,e){const r=this.q*(1-e)+t.q*e,i=this.r*(1-e)+t.r*e;return n(z({},this,{q:r,r:i,s:-r-i}))}}function rt(){return this.add(f)}function it(){return"".concat(this.x,",").concat(this.y)}const ot={thirdCoordinate:function(t,n){return-t-n}};const st=N({ensureXY:a}),ut=function(t){let{ensureXY:n,normalizeRadiuses:o,Point:s}=t;return function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const u=X({Point:s}),c={__isHoneycombHex:!0,orientation:"pointy",origin:0,size:{xRadius:1,yRadius:1},offset:-1,get q(){return this.cartesianToCube(this).q},get r(){return this.cartesianToCube(this).r},get s(){return this.cartesianToCube(this).s},add:K({Hex:h,Point:s}),cartesian:A,cartesianToCube:u,center:U({Point:s}),coordinates:A,corners:F({Point:s}),cube:I,cubeToCartesian:_,distance:tt,equals:Z({Point:s}),fromPoint:$({Point:s,Hex:h}),height:k,isFlat:B,isPointy:Y,lerp:et({Hex:h}),nudge:rt,round:nt({Hex:h}),set:W({Hex:h}),subtract:Q({Hex:h,Point:s}),toCartesian:_,toCube:u,toPoint:J({Point:s}),toString:it,width:L},a=Object.assign(c,t);function h(t,o){let s,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e(t)){let{q:n,r:e,s:i}=t,c=V(t,["q","r","s"]);if(r(n)||r(e)||r(i)){if(n+e+i!==0)throw new Error("Cube coordinates must have a sum of 0. q: ".concat(n,", r: ").concat(e,", s: ").concat(i,", sum: ").concat(n+e+i,"."));({x:s,y:o}=a.cubeToCartesian({q:n,r:e,s:i}))}else({x:s,y:o}=t);u=c}else i(t)?([s,o]=t,u={}):s=t;return Object.assign(Object.create(a),Object.assign(u,n(s,o)))}return a.size=o(a.size,a.isPointy()),a.origin=s(a.origin),Object.assign(h,ot,{toJSON:()=>t}),h}}({ensureXY:a,normalizeRadiuses:function(t,n){if(e(t)){if(r(t.xRadius)&&r(t.yRadius))return t;const{width:e,height:i}=t;if(r(e)&&r(i))return n?{xRadius:e/Math.sqrt(3),yRadius:i/2}:{xRadius:e/2,yRadius:i/Math.sqrt(3)}}if(r(t))return{xRadius:t,yRadius:t};throw new Error("Invalid size: ".concat(t,". Set it as a number or as an object containing width and height."))},Point:st}),ct=function(t){let{extendHex:n,Grid:e,Point:o}=t;const{isValidHex:s}=e;return function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:n();function a(){for(var n=arguments.length,o=new Array(n),s=0;s!r(t)))&&(o=o[0]),new e(...o.map(n=>t(n)))}return Object.assign(a,{Hex:t,isValidHex:s,pointToHex:P({Point:o,Hex:t}),parallelogram:w({Grid:e,Hex:t}),triangle:m({Grid:e,Hex:t}),hexagon:H({Grid:e,Hex:t}),rectangle:O({Grid:e,Hex:t,compassToNumberDirection:c,signedModulo:u}),ring:v({Grid:e,Hex:t}),spiral:j({Grid:e,Hex:t})}),Object.assign(e.prototype,{get:d,hexesBetween:y,hexesInRange:g({isValidHex:s}),neighborsOf:p({isValidHex:s,signedModulo:u,compassToNumberDirection:c}),pointHeight:q,pointWidth:b,set:x({isValidHex:s})}),a}}({extendHex:ut,Grid:G,Point:st});t.Point=st,t.defineGrid=ct,t.extendHex=ut,Object.defineProperty(t,"__esModule",{value:!0})})); 2 | -------------------------------------------------------------------------------- /vendors/popper.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) Federico Zivolo 2019 3 | Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT). 4 | */(function(e,t){'object'==typeof exports&&'undefined'!=typeof module?module.exports=t():'function'==typeof define&&define.amd?define(t):e.Popper=t()})(this,function(){'use strict';function e(e){return e&&'[object Function]'==={}.toString.call(e)}function t(e,t){if(1!==e.nodeType)return[];var o=e.ownerDocument.defaultView,n=o.getComputedStyle(e,null);return t?n[t]:n}function o(e){return'HTML'===e.nodeName?e:e.parentNode||e.host}function n(e){if(!e)return document.body;switch(e.nodeName){case'HTML':case'BODY':return e.ownerDocument.body;case'#document':return e.body;}var i=t(e),r=i.overflow,p=i.overflowX,s=i.overflowY;return /(auto|scroll|overlay)/.test(r+s+p)?e:n(o(e))}function r(e){return 11===e?pe:10===e?se:pe||se}function p(e){if(!e)return document.documentElement;for(var o=r(10)?document.body:null,n=e.offsetParent||null;n===o&&e.nextElementSibling;)n=(e=e.nextElementSibling).offsetParent;var i=n&&n.nodeName;return i&&'BODY'!==i&&'HTML'!==i?-1!==['TH','TD','TABLE'].indexOf(n.nodeName)&&'static'===t(n,'position')?p(n):n:e?e.ownerDocument.documentElement:document.documentElement}function s(e){var t=e.nodeName;return'BODY'!==t&&('HTML'===t||p(e.firstElementChild)===e)}function d(e){return null===e.parentNode?e:d(e.parentNode)}function a(e,t){if(!e||!e.nodeType||!t||!t.nodeType)return document.documentElement;var o=e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING,n=o?e:t,i=o?t:e,r=document.createRange();r.setStart(n,0),r.setEnd(i,0);var l=r.commonAncestorContainer;if(e!==l&&t!==l||n.contains(i))return s(l)?l:p(l);var f=d(e);return f.host?a(f.host,t):a(e,d(t).host)}function l(e){var t=1=o.clientWidth&&n>=o.clientHeight}),l=0a[e]&&!t.escapeWithReference&&(n=Q(f[o],a[e]-('right'===e?f.width:f.height))),le({},o,n)}};return l.forEach(function(e){var t=-1===['left','top'].indexOf(e)?'secondary':'primary';f=fe({},f,m[t](e))}),e.offsets.popper=f,e},priority:['left','right','top','bottom'],padding:5,boundariesElement:'scrollParent'},keepTogether:{order:400,enabled:!0,fn:function(e){var t=e.offsets,o=t.popper,n=t.reference,i=e.placement.split('-')[0],r=Z,p=-1!==['top','bottom'].indexOf(i),s=p?'right':'bottom',d=p?'left':'top',a=p?'width':'height';return o[s]r(n[s])&&(e.offsets.popper[d]=r(n[s])),e}},arrow:{order:500,enabled:!0,fn:function(e,o){var n;if(!K(e.instance.modifiers,'arrow','keepTogether'))return e;var i=o.element;if('string'==typeof i){if(i=e.instance.popper.querySelector(i),!i)return e;}else if(!e.instance.popper.contains(i))return console.warn('WARNING: `arrow.element` must be child of its popper element!'),e;var r=e.placement.split('-')[0],p=e.offsets,s=p.popper,d=p.reference,a=-1!==['left','right'].indexOf(r),l=a?'height':'width',f=a?'Top':'Left',m=f.toLowerCase(),h=a?'left':'top',c=a?'bottom':'right',u=S(i)[l];d[c]-us[c]&&(e.offsets.popper[m]+=d[m]+u-s[c]),e.offsets.popper=g(e.offsets.popper);var b=d[m]+d[l]/2-u/2,w=t(e.instance.popper),y=parseFloat(w['margin'+f],10),E=parseFloat(w['border'+f+'Width'],10),v=b-e.offsets.popper[m]-y-E;return v=ee(Q(s[l]-u,v),0),e.arrowElement=i,e.offsets.arrow=(n={},le(n,m,$(v)),le(n,h,''),n),e},element:'[x-arrow]'},flip:{order:600,enabled:!0,fn:function(e,t){if(W(e.instance.modifiers,'inner'))return e;if(e.flipped&&e.placement===e.originalPlacement)return e;var o=v(e.instance.popper,e.instance.reference,t.padding,t.boundariesElement,e.positionFixed),n=e.placement.split('-')[0],i=T(n),r=e.placement.split('-')[1]||'',p=[];switch(t.behavior){case ge.FLIP:p=[n,i];break;case ge.CLOCKWISE:p=G(n);break;case ge.COUNTERCLOCKWISE:p=G(n,!0);break;default:p=t.behavior;}return p.forEach(function(s,d){if(n!==s||p.length===d+1)return e;n=e.placement.split('-')[0],i=T(n);var a=e.offsets.popper,l=e.offsets.reference,f=Z,m='left'===n&&f(a.right)>f(l.left)||'right'===n&&f(a.left)f(l.top)||'bottom'===n&&f(a.top)f(o.right),g=f(a.top)f(o.bottom),b='left'===n&&h||'right'===n&&c||'top'===n&&g||'bottom'===n&&u,w=-1!==['top','bottom'].indexOf(n),y=!!t.flipVariations&&(w&&'start'===r&&h||w&&'end'===r&&c||!w&&'start'===r&&g||!w&&'end'===r&&u);(m||b||y)&&(e.flipped=!0,(m||b)&&(n=p[d+1]),y&&(r=z(r)),e.placement=n+(r?'-'+r:''),e.offsets.popper=fe({},e.offsets.popper,D(e.instance.popper,e.offsets.reference,e.placement)),e=P(e.instance.modifiers,e,'flip'))}),e},behavior:'flip',padding:5,boundariesElement:'viewport'},inner:{order:700,enabled:!1,fn:function(e){var t=e.placement,o=t.split('-')[0],n=e.offsets,i=n.popper,r=n.reference,p=-1!==['left','right'].indexOf(o),s=-1===['top','left'].indexOf(o);return i[p?'left':'top']=r[o]-(s?i[p?'width':'height']:0),e.placement=T(t),e.offsets.popper=g(i),e}},hide:{order:800,enabled:!0,fn:function(e){if(!K(e.instance.modifiers,'hide','preventOverflow'))return e;var t=e.offsets.reference,o=C(e.instance.modifiers,function(e){return'preventOverflow'===e.name}).boundaries;if(t.bottomo.right||t.top>o.bottom||t.rightwindow.devicePixelRatio||!me),c='bottom'===o?'top':'bottom',g='right'===n?'left':'right',b=H('transform');if(d='bottom'==c?'HTML'===l.nodeName?-l.clientHeight+h.bottom:-f.height+h.bottom:h.top,s='right'==g?'HTML'===l.nodeName?-l.clientWidth+h.right:-f.width+h.right:h.left,a&&b)m[b]='translate3d('+s+'px, '+d+'px, 0)',m[c]=0,m[g]=0,m.willChange='transform';else{var w='bottom'==c?-1:1,y='right'==g?-1:1;m[c]=d*w,m[g]=s*y,m.willChange=c+', '+g}var E={"x-placement":e.placement};return e.attributes=fe({},E,e.attributes),e.styles=fe({},m,e.styles),e.arrowStyles=fe({},e.offsets.arrow,e.arrowStyles),e},gpuAcceleration:!0,x:'bottom',y:'right'},applyStyle:{order:900,enabled:!0,fn:function(e){return j(e.instance.popper,e.styles),V(e.instance.popper,e.attributes),e.arrowElement&&Object.keys(e.arrowStyles).length&&j(e.arrowElement,e.arrowStyles),e},onLoad:function(e,t,o,n,i){var r=L(i,t,e,o.positionFixed),p=O(o.placement,r,t,e,o.modifiers.flip.boundariesElement,o.modifiers.flip.padding);return t.setAttribute('x-placement',p),j(t,{position:o.positionFixed?'fixed':'absolute'}),o},gpuAcceleration:void 0}}},ue}); 5 | //# sourceMappingURL=popper.min.js.map 6 | -------------------------------------------------------------------------------- /vendors/reimg.js: -------------------------------------------------------------------------------- 1 | ReImg = { 2 | 3 | OutputProcessor: function(encodedData, svgElement) { 4 | 5 | var isPng = function() { 6 | return encodedData.indexOf('data:image/png') === 0; 7 | }; 8 | 9 | var downloadImage = function(data, filename) { 10 | var a = document.createElement('a'); 11 | a.href = data; 12 | a.download = filename; 13 | document.body.appendChild(a); 14 | a.click(); 15 | }; 16 | 17 | return { 18 | toBase64: function() { 19 | return encodedData; 20 | }, 21 | toImg: function() { 22 | var imgElement = document.createElement('img'); 23 | imgElement.src = encodedData; 24 | return imgElement; 25 | }, 26 | toCanvas: function(callback) { 27 | var canvas = document.createElement('canvas'); 28 | var boundedRect = svgElement.getBoundingClientRect(); 29 | canvas.width = boundedRect.width; 30 | canvas.height = boundedRect.height; 31 | var canvasCtx = canvas.getContext('2d'); 32 | 33 | var img = this.toImg(); 34 | img.onload = function() { 35 | canvasCtx.drawImage(img, 0, 0); 36 | callback(canvas); 37 | }; 38 | }, 39 | toPng: function() { 40 | if (isPng()) { 41 | var img = document.createElement('img'); 42 | img.src = encodedData; 43 | return img; 44 | } 45 | 46 | this.toCanvas(function(canvas) { 47 | var img = document.createElement('img'); 48 | img.src = canvas.toDataURL(); 49 | return img; 50 | }); 51 | }, 52 | toJpeg: function(quality) { // quality should be between 0-1 53 | quality = quality || 1.0; 54 | (function(q) { 55 | this.toCanvas(function(canvas) { 56 | var img = document.createElement('img'); 57 | img.src = canvas.toDataURL('image/jpeg', q); 58 | return img; 59 | }); 60 | })(quality); 61 | }, 62 | downloadPng: function(filename) { 63 | filename = filename || 'image.png'; 64 | if (isPng()) { 65 | // it's a canvas already 66 | downloadImage(encodedData, filename); 67 | return; 68 | } 69 | 70 | // convert to canvas first 71 | this.toCanvas(function(canvas) { 72 | downloadImage(canvas.toDataURL(), filename); 73 | }); 74 | } 75 | }; 76 | }, 77 | 78 | fromSvg: function(svgElement) { 79 | var svgString = new XMLSerializer().serializeToString(svgElement); 80 | return new this.OutputProcessor('data:image/svg+xml;base64,' + window.btoa(svgString), svgElement); 81 | }, 82 | 83 | fromCanvas: function(canvasElement) { 84 | var dataUrl = canvasElement.toDataURL(); 85 | return new this.OutputProcessor(dataUrl); 86 | } 87 | 88 | }; 89 | 90 | if(typeof exports === 'object' && typeof module !== void 0) { 91 | module.exports = { 92 | ReImg:ReImg 93 | }; 94 | } 95 | 96 | else { 97 | window.ReImg = ReImg; 98 | } -------------------------------------------------------------------------------- /vendors/simplex-noise.js: -------------------------------------------------------------------------------- 1 | /* 2 | * A fast javascript implementation of simplex noise by Jonas Wagner 3 | 4 | Based on a speed-improved simplex noise algorithm for 2D, 3D and 4D in Java. 5 | Which is based on example code by Stefan Gustavson (stegu@itn.liu.se). 6 | With Optimisations by Peter Eastman (peastman@drizzle.stanford.edu). 7 | Better rank ordering method by Stefan Gustavson in 2012. 8 | 9 | Copyright (c) 2018 Jonas Wagner 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | copies of the Software, and to permit persons to whom the Software is 16 | furnished to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | SOFTWARE. 28 | */ 29 | (function() { 30 | 'use strict'; 31 | 32 | var F2 = 0.5 * (Math.sqrt(3.0) - 1.0); 33 | var G2 = (3.0 - Math.sqrt(3.0)) / 6.0; 34 | var F3 = 1.0 / 3.0; 35 | var G3 = 1.0 / 6.0; 36 | var F4 = (Math.sqrt(5.0) - 1.0) / 4.0; 37 | var G4 = (5.0 - Math.sqrt(5.0)) / 20.0; 38 | 39 | function SimplexNoise(randomOrSeed) { 40 | var random; 41 | if (typeof randomOrSeed == 'function') { 42 | random = randomOrSeed; 43 | } 44 | else if (randomOrSeed) { 45 | random = alea(randomOrSeed); 46 | } else { 47 | random = Math.random; 48 | } 49 | this.p = buildPermutationTable(random); 50 | this.perm = new Uint8Array(512); 51 | this.permMod12 = new Uint8Array(512); 52 | for (var i = 0; i < 512; i++) { 53 | this.perm[i] = this.p[i & 255]; 54 | this.permMod12[i] = this.perm[i] % 12; 55 | } 56 | 57 | } 58 | SimplexNoise.prototype = { 59 | grad3: new Float32Array([1, 1, 0, 60 | -1, 1, 0, 61 | 1, -1, 0, 62 | 63 | -1, -1, 0, 64 | 1, 0, 1, 65 | -1, 0, 1, 66 | 67 | 1, 0, -1, 68 | -1, 0, -1, 69 | 0, 1, 1, 70 | 71 | 0, -1, 1, 72 | 0, 1, -1, 73 | 0, -1, -1]), 74 | grad4: new Float32Array([0, 1, 1, 1, 0, 1, 1, -1, 0, 1, -1, 1, 0, 1, -1, -1, 75 | 0, -1, 1, 1, 0, -1, 1, -1, 0, -1, -1, 1, 0, -1, -1, -1, 76 | 1, 0, 1, 1, 1, 0, 1, -1, 1, 0, -1, 1, 1, 0, -1, -1, 77 | -1, 0, 1, 1, -1, 0, 1, -1, -1, 0, -1, 1, -1, 0, -1, -1, 78 | 1, 1, 0, 1, 1, 1, 0, -1, 1, -1, 0, 1, 1, -1, 0, -1, 79 | -1, 1, 0, 1, -1, 1, 0, -1, -1, -1, 0, 1, -1, -1, 0, -1, 80 | 1, 1, 1, 0, 1, 1, -1, 0, 1, -1, 1, 0, 1, -1, -1, 0, 81 | -1, 1, 1, 0, -1, 1, -1, 0, -1, -1, 1, 0, -1, -1, -1, 0]), 82 | noise2D: function(xin, yin) { 83 | var permMod12 = this.permMod12; 84 | var perm = this.perm; 85 | var grad3 = this.grad3; 86 | var n0 = 0; // Noise contributions from the three corners 87 | var n1 = 0; 88 | var n2 = 0; 89 | // Skew the input space to determine which simplex cell we're in 90 | var s = (xin + yin) * F2; // Hairy factor for 2D 91 | var i = Math.floor(xin + s); 92 | var j = Math.floor(yin + s); 93 | var t = (i + j) * G2; 94 | var X0 = i - t; // Unskew the cell origin back to (x,y) space 95 | var Y0 = j - t; 96 | var x0 = xin - X0; // The x,y distances from the cell origin 97 | var y0 = yin - Y0; 98 | // For the 2D case, the simplex shape is an equilateral triangle. 99 | // Determine which simplex we are in. 100 | var i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords 101 | if (x0 > y0) { 102 | i1 = 1; 103 | j1 = 0; 104 | } // lower triangle, XY order: (0,0)->(1,0)->(1,1) 105 | else { 106 | i1 = 0; 107 | j1 = 1; 108 | } // upper triangle, YX order: (0,0)->(0,1)->(1,1) 109 | // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and 110 | // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where 111 | // c = (3-sqrt(3))/6 112 | var x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords 113 | var y1 = y0 - j1 + G2; 114 | var x2 = x0 - 1.0 + 2.0 * G2; // Offsets for last corner in (x,y) unskewed coords 115 | var y2 = y0 - 1.0 + 2.0 * G2; 116 | // Work out the hashed gradient indices of the three simplex corners 117 | var ii = i & 255; 118 | var jj = j & 255; 119 | // Calculate the contribution from the three corners 120 | var t0 = 0.5 - x0 * x0 - y0 * y0; 121 | if (t0 >= 0) { 122 | var gi0 = permMod12[ii + perm[jj]] * 3; 123 | t0 *= t0; 124 | n0 = t0 * t0 * (grad3[gi0] * x0 + grad3[gi0 + 1] * y0); // (x,y) of grad3 used for 2D gradient 125 | } 126 | var t1 = 0.5 - x1 * x1 - y1 * y1; 127 | if (t1 >= 0) { 128 | var gi1 = permMod12[ii + i1 + perm[jj + j1]] * 3; 129 | t1 *= t1; 130 | n1 = t1 * t1 * (grad3[gi1] * x1 + grad3[gi1 + 1] * y1); 131 | } 132 | var t2 = 0.5 - x2 * x2 - y2 * y2; 133 | if (t2 >= 0) { 134 | var gi2 = permMod12[ii + 1 + perm[jj + 1]] * 3; 135 | t2 *= t2; 136 | n2 = t2 * t2 * (grad3[gi2] * x2 + grad3[gi2 + 1] * y2); 137 | } 138 | // Add contributions from each corner to get the final noise value. 139 | // The result is scaled to return values in the interval [-1,1]. 140 | return 70.0 * (n0 + n1 + n2); 141 | }, 142 | // 3D simplex noise 143 | noise3D: function(xin, yin, zin) { 144 | var permMod12 = this.permMod12; 145 | var perm = this.perm; 146 | var grad3 = this.grad3; 147 | var n0, n1, n2, n3; // Noise contributions from the four corners 148 | // Skew the input space to determine which simplex cell we're in 149 | var s = (xin + yin + zin) * F3; // Very nice and simple skew factor for 3D 150 | var i = Math.floor(xin + s); 151 | var j = Math.floor(yin + s); 152 | var k = Math.floor(zin + s); 153 | var t = (i + j + k) * G3; 154 | var X0 = i - t; // Unskew the cell origin back to (x,y,z) space 155 | var Y0 = j - t; 156 | var Z0 = k - t; 157 | var x0 = xin - X0; // The x,y,z distances from the cell origin 158 | var y0 = yin - Y0; 159 | var z0 = zin - Z0; 160 | // For the 3D case, the simplex shape is a slightly irregular tetrahedron. 161 | // Determine which simplex we are in. 162 | var i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords 163 | var i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords 164 | if (x0 >= y0) { 165 | if (y0 >= z0) { 166 | i1 = 1; 167 | j1 = 0; 168 | k1 = 0; 169 | i2 = 1; 170 | j2 = 1; 171 | k2 = 0; 172 | } // X Y Z order 173 | else if (x0 >= z0) { 174 | i1 = 1; 175 | j1 = 0; 176 | k1 = 0; 177 | i2 = 1; 178 | j2 = 0; 179 | k2 = 1; 180 | } // X Z Y order 181 | else { 182 | i1 = 0; 183 | j1 = 0; 184 | k1 = 1; 185 | i2 = 1; 186 | j2 = 0; 187 | k2 = 1; 188 | } // Z X Y order 189 | } 190 | else { // x0 y0) rankx++; 297 | else ranky++; 298 | if (x0 > z0) rankx++; 299 | else rankz++; 300 | if (x0 > w0) rankx++; 301 | else rankw++; 302 | if (y0 > z0) ranky++; 303 | else rankz++; 304 | if (y0 > w0) ranky++; 305 | else rankw++; 306 | if (z0 > w0) rankz++; 307 | else rankw++; 308 | var i1, j1, k1, l1; // The integer offsets for the second simplex corner 309 | var i2, j2, k2, l2; // The integer offsets for the third simplex corner 310 | var i3, j3, k3, l3; // The integer offsets for the fourth simplex corner 311 | // simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order. 312 | // Many values of c will never occur, since e.g. x>y>z>w makes x= 3 ? 1 : 0; 317 | j1 = ranky >= 3 ? 1 : 0; 318 | k1 = rankz >= 3 ? 1 : 0; 319 | l1 = rankw >= 3 ? 1 : 0; 320 | // Rank 2 denotes the second largest coordinate. 321 | i2 = rankx >= 2 ? 1 : 0; 322 | j2 = ranky >= 2 ? 1 : 0; 323 | k2 = rankz >= 2 ? 1 : 0; 324 | l2 = rankw >= 2 ? 1 : 0; 325 | // Rank 1 denotes the second smallest coordinate. 326 | i3 = rankx >= 1 ? 1 : 0; 327 | j3 = ranky >= 1 ? 1 : 0; 328 | k3 = rankz >= 1 ? 1 : 0; 329 | l3 = rankw >= 1 ? 1 : 0; 330 | // The fifth corner has all coordinate offsets = 1, so no need to compute that. 331 | var x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords 332 | var y1 = y0 - j1 + G4; 333 | var z1 = z0 - k1 + G4; 334 | var w1 = w0 - l1 + G4; 335 | var x2 = x0 - i2 + 2.0 * G4; // Offsets for third corner in (x,y,z,w) coords 336 | var y2 = y0 - j2 + 2.0 * G4; 337 | var z2 = z0 - k2 + 2.0 * G4; 338 | var w2 = w0 - l2 + 2.0 * G4; 339 | var x3 = x0 - i3 + 3.0 * G4; // Offsets for fourth corner in (x,y,z,w) coords 340 | var y3 = y0 - j3 + 3.0 * G4; 341 | var z3 = z0 - k3 + 3.0 * G4; 342 | var w3 = w0 - l3 + 3.0 * G4; 343 | var x4 = x0 - 1.0 + 4.0 * G4; // Offsets for last corner in (x,y,z,w) coords 344 | var y4 = y0 - 1.0 + 4.0 * G4; 345 | var z4 = z0 - 1.0 + 4.0 * G4; 346 | var w4 = w0 - 1.0 + 4.0 * G4; 347 | // Work out the hashed gradient indices of the five simplex corners 348 | var ii = i & 255; 349 | var jj = j & 255; 350 | var kk = k & 255; 351 | var ll = l & 255; 352 | // Calculate the contribution from the five corners 353 | var t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0; 354 | if (t0 < 0) n0 = 0.0; 355 | else { 356 | var gi0 = (perm[ii + perm[jj + perm[kk + perm[ll]]]] % 32) * 4; 357 | t0 *= t0; 358 | n0 = t0 * t0 * (grad4[gi0] * x0 + grad4[gi0 + 1] * y0 + grad4[gi0 + 2] * z0 + grad4[gi0 + 3] * w0); 359 | } 360 | var t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1; 361 | if (t1 < 0) n1 = 0.0; 362 | else { 363 | var gi1 = (perm[ii + i1 + perm[jj + j1 + perm[kk + k1 + perm[ll + l1]]]] % 32) * 4; 364 | t1 *= t1; 365 | n1 = t1 * t1 * (grad4[gi1] * x1 + grad4[gi1 + 1] * y1 + grad4[gi1 + 2] * z1 + grad4[gi1 + 3] * w1); 366 | } 367 | var t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2; 368 | if (t2 < 0) n2 = 0.0; 369 | else { 370 | var gi2 = (perm[ii + i2 + perm[jj + j2 + perm[kk + k2 + perm[ll + l2]]]] % 32) * 4; 371 | t2 *= t2; 372 | n2 = t2 * t2 * (grad4[gi2] * x2 + grad4[gi2 + 1] * y2 + grad4[gi2 + 2] * z2 + grad4[gi2 + 3] * w2); 373 | } 374 | var t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3; 375 | if (t3 < 0) n3 = 0.0; 376 | else { 377 | var gi3 = (perm[ii + i3 + perm[jj + j3 + perm[kk + k3 + perm[ll + l3]]]] % 32) * 4; 378 | t3 *= t3; 379 | n3 = t3 * t3 * (grad4[gi3] * x3 + grad4[gi3 + 1] * y3 + grad4[gi3 + 2] * z3 + grad4[gi3 + 3] * w3); 380 | } 381 | var t4 = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4; 382 | if (t4 < 0) n4 = 0.0; 383 | else { 384 | var gi4 = (perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] % 32) * 4; 385 | t4 *= t4; 386 | n4 = t4 * t4 * (grad4[gi4] * x4 + grad4[gi4 + 1] * y4 + grad4[gi4 + 2] * z4 + grad4[gi4 + 3] * w4); 387 | } 388 | // Sum up and scale the result to cover the range [-1,1] 389 | return 27.0 * (n0 + n1 + n2 + n3 + n4); 390 | } 391 | }; 392 | 393 | function buildPermutationTable(random) { 394 | var i; 395 | var p = new Uint8Array(256); 396 | for (i = 0; i < 256; i++) { 397 | p[i] = i; 398 | } 399 | for (i = 0; i < 255; i++) { 400 | var r = i + ~~(random() * (256 - i)); 401 | var aux = p[i]; 402 | p[i] = p[r]; 403 | p[r] = aux; 404 | } 405 | return p; 406 | } 407 | SimplexNoise._buildPermutationTable = buildPermutationTable; 408 | 409 | /* 410 | The ALEA PRNG and masher code used by simplex-noise.js 411 | is based on code by Johannes Baagøe, modified by Jonas Wagner. 412 | See alea.md for the full license. 413 | */ 414 | function alea() { 415 | var s0 = 0; 416 | var s1 = 0; 417 | var s2 = 0; 418 | var c = 1; 419 | 420 | var mash = masher(); 421 | s0 = mash(' '); 422 | s1 = mash(' '); 423 | s2 = mash(' '); 424 | 425 | for (var i = 0; i < arguments.length; i++) { 426 | s0 -= mash(arguments[i]); 427 | if (s0 < 0) { 428 | s0 += 1; 429 | } 430 | s1 -= mash(arguments[i]); 431 | if (s1 < 0) { 432 | s1 += 1; 433 | } 434 | s2 -= mash(arguments[i]); 435 | if (s2 < 0) { 436 | s2 += 1; 437 | } 438 | } 439 | mash = null; 440 | return function() { 441 | var t = 2091639 * s0 + c * 2.3283064365386963e-10; // 2^-32 442 | s0 = s1; 443 | s1 = s2; 444 | return s2 = t - (c = t | 0); 445 | }; 446 | } 447 | function masher() { 448 | var n = 0xefc8249d; 449 | return function(data) { 450 | data = data.toString(); 451 | for (var i = 0; i < data.length; i++) { 452 | n += data.charCodeAt(i); 453 | var h = 0.02519603282416938 * n; 454 | n = h >>> 0; 455 | h -= n; 456 | h *= n; 457 | n = h >>> 0; 458 | h -= n; 459 | n += h * 0x100000000; // 2^32 460 | } 461 | return (n >>> 0) * 2.3283064365386963e-10; // 2^-32 462 | }; 463 | } 464 | 465 | // amd 466 | if (typeof define !== 'undefined' && define.amd) define(function() {return SimplexNoise;}); 467 | // common js 468 | if (typeof exports !== 'undefined') exports.SimplexNoise = SimplexNoise; 469 | // browser 470 | else if (typeof window !== 'undefined') window.SimplexNoise = SimplexNoise; 471 | // nodejs 472 | if (typeof module !== 'undefined') { 473 | module.exports = SimplexNoise; 474 | } 475 | 476 | })(); -------------------------------------------------------------------------------- /vendors/viewport.js: -------------------------------------------------------------------------------- 1 | !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","pixi.js"],e):e((t=t||self).Viewport={},t.PIXI)}(this,function(t,e){"use strict";class i{constructor(t){this.viewport=t,this.touches=[],this.addListeners()}addListeners(){this.viewport.interactive=!0,this.viewport.forceHitArea||(this.viewport.hitArea=new e.Rectangle(0,0,this.viewport.worldWidth,this.viewport.worldHeight)),this.viewport.on("pointerdown",this.down,this),this.viewport.on("pointermove",this.move,this),this.viewport.on("pointerup",this.up,this),this.viewport.on("pointerupoutside",this.up,this),this.viewport.on("pointercancel",this.up,this),this.viewport.on("pointerout",this.up,this),this.wheelFunction=t=>this.handleWheel(t),this.viewport.options.divWheel.addEventListener("wheel",this.wheelFunction,{passive:this.viewport.options.passiveWheel}),this.isMouseDown=!1}destroy(){this.viewport.options.divWheel.removeEventListener("wheel",this.wheelFunction)}down(t){if(this.viewport.pause||!this.viewport.worldVisible)return;if("mouse"===t.data.pointerType?this.isMouseDown=!0:this.get(t.data.pointerId)||this.touches.push({id:t.data.pointerId,last:null}),1===this.count()){this.last=t.data.global.clone();const e=this.viewport.plugins.get("decelerate"),i=this.viewport.plugins.get("bounce");e&&e.isActive()||i&&i.isActive()?this.clickedAvailable=!1:this.clickedAvailable=!0}else this.clickedAvailable=!1;this.viewport.plugins.down(t)&&this.viewport.options.stopPropagation&&t.stopPropagation()}checkThreshold(t){return Math.abs(t)>=this.viewport.threshold}move(t){if(this.viewport.pause||!this.viewport.worldVisible)return;const e=this.viewport.plugins.move(t);if(this.clickedAvailable){const e=t.data.global.x-this.last.x,i=t.data.global.y-this.last.y;(this.checkThreshold(e)||this.checkThreshold(i))&&(this.clickedAvailable=!1)}e&&this.viewport.options.stopPropagation&&t.stopPropagation()}up(t){if(this.viewport.pause||!this.viewport.worldVisible)return;"mouse"===t.data.pointerType&&(this.isMouseDown=!1),"mouse"!==t.data.pointerType&&this.remove(t.data.pointerId);const e=this.viewport.plugins.up(t);this.clickedAvailable&&0===this.count()&&(this.viewport.emit("clicked",{screen:this.last,world:this.viewport.toWorld(this.last),viewport:this}),this.clickedAvailable=!1),e&&this.viewport.options.stopPropagation&&t.stopPropagation()}getPointerPosition(t){let i=new e.Point;return this.viewport.options.interaction?this.viewport.options.interaction.mapPositionToPoint(i,t.clientX,t.clientY):(i.x=t.clientX,i.y=t.clientY),i}handleWheel(t){if(this.viewport.pause||!this.viewport.worldVisible)return;const e=this.viewport.toLocal(this.getPointerPosition(t));if(this.viewport.left<=e.x&&e.x<=this.viewport.right&&this.viewport.top<=e.y&&e.y<=this.viewport.bottom){this.viewport.plugins.wheel(t)&&t.preventDefault()}}pause(){this.touches=[],this.isMouseDown=!1}get(t){for(let e of this.touches)if(e.id===t)return e;return null}remove(t){for(let e=0;e{t.includes(e.code)&&(this.keyIsPressed=!0)}),parent.addEventListener("keyup",e=>{t.includes(e.code)&&(this.keyIsPressed=!1)})}mouseButtons(t){this.mouse=t&&"all"!==t?[-1!==t.indexOf("left"),-1!==t.indexOf("middle"),-1!==t.indexOf("right")]:[!0,!0,!0]}parseUnderflow(){const t=this.options.underflow.toLowerCase();"center"===t?(this.underflowX=0,this.underflowY=0):(this.underflowX=-1!==t.indexOf("left")?-1:-1!==t.indexOf("right")?1:0,this.underflowY=-1!==t.indexOf("top")?-1:-1!==t.indexOf("bottom")?1:0)}checkButtons(t){const e="mouse"===t.data.pointerType,i=this.parent.input.count();return!(!(1===i||i>1&&!this.parent.plugins.get("pinch"))||e&&!this.mouse[t.data.button])}checkKeyPress(t){return!!(!this.options.keyToPress||this.keyIsPressed||this.options.ignoreKeyToPressOnTouch&&"touch"===t.data.pointerType)}down(t){if(!this.paused)return this.checkButtons(t)&&this.checkKeyPress(t)?(this.last={x:t.data.global.x,y:t.data.global.y},this.current=t.data.pointerId,!0):void(this.last=null)}get active(){return this.moved}move(t){if(!this.paused&&this.last&&this.current===t.data.pointerId){const i=t.data.global.x,s=t.data.global.y,n=this.parent.input.count();if(1===n||n>1&&!this.parent.plugins.get("pinch")){const t=i-this.last.x,n=s-this.last.y;if(this.moved||this.xDirection&&this.parent.input.checkThreshold(t)||this.yDirection&&this.parent.input.checkThreshold(n)){const t={x:i,y:s};return this.xDirection&&(this.parent.x+=(t.x-this.last.x)*this.options.factor),this.yDirection&&(this.parent.y+=(t.y-this.last.y)*this.options.factor),this.last=t,this.moved||this.parent.emit("drag-start",{screen:new e.Point(this.last.x,this.last.y),world:this.parent.toWorld(new e.Point(this.last.x,this.last.y)),viewport:this.parent}),this.moved=!0,this.parent.emit("moved",{viewport:this.parent,type:"drag"}),!0}}else this.moved=!1}}up(){const t=this.parent.input.touches;if(1===t.length){const e=t[0];return e.last&&(this.last={x:e.last.x,y:e.last.y},this.current=e.id),this.moved=!1,!0}if(this.last&&this.moved){const t=new e.Point(this.last.x,this.last.y);return this.parent.emit("drag-end",{screen:t,world:this.parent.toWorld(t),viewport:this.parent}),this.last=null,this.moved=!1,!0}}wheel(t){if(!this.paused&&this.options.wheel){if(!this.parent.plugins.get("wheel"))return this.xDirection&&(this.parent.x+=t.deltaX*this.options.wheelScroll*this.reverse),this.yDirection&&(this.parent.y+=t.deltaY*this.options.wheelScroll*this.reverse),this.options.clampWheel&&this.clamp(),this.parent.emit("wheel-scroll",this.parent),this.parent.emit("moved",this.parent),this.parent.options.passiveWheel||t.preventDefault(),!0}}resume(){this.last=null,this.paused=!1}clamp(){const t=this.parent.plugins.get("decelerate")||{};if("y"!==this.options.clampWheel)if(this.parent.screenWorldWidththis.parent.worldWidth&&(this.parent.x=-this.parent.worldWidth*this.parent.scale.x+this.parent.screenWidth,t.x=0);if("x"!==this.options.clampWheel)if(this.parent.screenWorldHeightthis.parent.worldHeight&&(this.parent.y=-this.parent.worldHeight*this.parent.scale.y+this.parent.screenHeight,t.y=0)}}const a={noDrag:!1,percent:1,center:null};class p extends h{constructor(t,e={}){super(t),this.options=Object.assign({},a,e)}down(){if(this.parent.input.count()>=2)return this.active=!0,!0}move(t){if(this.paused||!this.active)return;const e=t.data.global.x,i=t.data.global.y,s=this.parent.input.touches;if(s.length>=2){const n=s[0],h=s[1],o=n.last&&h.last?Math.sqrt(Math.pow(h.last.x-n.last.x,2)+Math.pow(h.last.y-n.last.y,2)):null;if(n.id===t.data.pointerId?n.last={x:e,y:i,data:t.data}:h.id===t.data.pointerId&&(h.last={x:e,y:i,data:t.data}),o){let t;const e={x:n.last.x+(h.last.x-n.last.x)/2,y:n.last.y+(h.last.y-n.last.y)/2};this.options.center||(t=this.parent.toLocal(e));const i=(Math.sqrt(Math.pow(h.last.x-n.last.x,2)+Math.pow(h.last.y-n.last.y,2))-o)/this.parent.screenWidth*this.parent.scale.x*this.options.percent;this.parent.scale.x+=i,this.parent.scale.y+=i,this.parent.emit("zoomed",{viewport:this.parent,type:"pinch"});const s=this.parent.plugins.get("clamp-zoom");if(s&&s.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const i=this.parent.toGlobal(t);this.parent.x+=e.x-i.x,this.parent.y+=e.y-i.y,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})}!this.options.noDrag&&this.lastCenter&&(this.parent.x+=e.x-this.lastCenter.x,this.parent.y+=e.y-this.lastCenter.y,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})),this.lastCenter=e,this.moved=!0}else this.pinching||(this.parent.emit("pinch-start",this.parent),this.pinching=!0);return!0}}up(){if(this.pinching&&this.parent.input.touches.length<=1)return this.active=!1,this.lastCenter=null,this.pinching=!1,this.moved=!1,this.parent.emit("pinch-end",this.parent),!0}}const l={left:!1,right:!1,top:!1,bottom:!1,direction:null,underflow:"center"};class c extends h{constructor(t,e={}){super(t),this.options=Object.assign({},l,e),this.options.direction&&(this.options.left="x"===this.options.direction||"all"===this.options.direction||null,this.options.right="x"===this.options.direction||"all"===this.options.direction||null,this.options.top="y"===this.options.direction||"all"===this.options.direction||null,this.options.bottom="y"===this.options.direction||"all"===this.options.direction||null),this.parseUnderflow(),this.update()}parseUnderflow(){const t=this.options.underflow.toLowerCase();"none"===t?this.noUnderflow=!0:"center"===t?(this.underflowX=this.underflowY=0,this.noUnderflow=!1):(this.underflowX=-1!==t.indexOf("left")?-1:-1!==t.indexOf("right")?1:0,this.underflowY=-1!==t.indexOf("top")?-1:-1!==t.indexOf("bottom")?1:0,this.noUnderflow=!1)}move(){return this.update(),!1}update(){if(this.paused)return;const t={x:this.parent.x,y:this.parent.y},e=this.parent.plugins.decelerate||{};if(null!==this.options.left||null!==this.options.right){let i=!1;if(this.parent.screenWorldWidth(!0===this.options.right?this.parent.worldWidth:this.options.right)&&(this.parent.x=-(!0===this.options.right?this.parent.worldWidth:this.options.right)*this.parent.scale.x+this.parent.screenWidth,e.x=0,i=!0);i&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-x"})}if(null!==this.options.top||null!==this.options.bottom){let i=!1;if(this.parent.screenWorldHeight(!0===this.options.bottom?this.parent.worldHeight:this.options.bottom)&&(this.parent.y=-(!0===this.options.bottom?this.parent.worldHeight:this.options.bottom)*this.parent.scale.y+this.parent.screenHeight,e.y=0,i=!0);i&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-y"})}}}const d={minWidth:null,minHeight:null,maxWidth:null,maxHeight:null};class u extends h{constructor(t,e={}){super(t),this.options=Object.assign({},d,e),this.clamp()}resize(){this.clamp()}clamp(){if(this.paused)return;let t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight;if(null!==this.options.minWidth&&tthis.options.maxWidth){const i=this.parent.scale.x;this.parent.fitWidth(this.options.maxWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/i,t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(null!==this.options.minHeight&&ethis.options.maxHeight){const t=this.parent.scale.y;this.parent.fitHeight(this.options.maxHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/t,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}}}const g={friction:.95,bounce:.8,minSpeed:.01};class m extends h{constructor(t,e={}){super(t),this.options=Object.assign({},g,e),this.saved=[],this.reset(),this.parent.on("moved",t=>this.moved(t))}destroy(){this.parent}down(){this.saved=[],this.x=this.y=!1}isActive(){return this.x||this.y}move(){if(this.paused)return;const t=this.parent.input.count();(1===t||t>1&&!this.parent.plugins.get("pinch"))&&(this.saved.push({x:this.parent.x,y:this.parent.y,time:performance.now()}),this.saved.length>60&&this.saved.splice(0,30))}moved(t){if(this.saved.length){const e=this.saved[this.saved.length-1];"clamp-x"===t.type?e.x===t.original.x&&(e.x=this.parent.x):"clamp-y"===t.type&&e.y===t.original.y&&(e.y=this.parent.y)}}up(){if(0===this.parent.input.count()&&this.saved.length){const t=performance.now();for(let e of this.saved)if(e.time>=t-100){const i=t-e.time;this.x=(this.parent.x-e.x)/i,this.y=(this.parent.y-e.y)/i,this.percentChangeX=this.percentChangeY=this.options.friction;break}}}activate(t){void 0!==(t=t||{}).x&&(this.x=t.x,this.percentChangeX=this.options.friction),void 0!==t.y&&(this.y=t.y,this.percentChangeY=this.options.friction)}update(t){if(this.paused)return;let e;this.x&&(this.parent.x+=this.x*t,this.x*=this.percentChangeX,Math.abs(this.x)=this.options.time?(this.parent.x=e.end,this.toX=null,this.parent.emit("bounce-x-end",this.parent)):this.parent.x=this.ease(e.time,e.start,e.delta,this.options.time)}if(this.toY){const e=this.toY;e.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-y"}),e.time>=this.options.time?(this.parent.y=e.end,this.toY=null,this.parent.emit("bounce-y-end",this.parent)):this.parent.y=this.ease(e.time,e.start,e.delta,this.options.time)}}}calcUnderflowX(){let t;switch(this.underflowX){case-1:t=0;break;case 1:t=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:t=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}return t}calcUnderflowY(){let t;switch(this.underflowY){case-1:t=0;break;case 1:t=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:t=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}return t}bounce(){if(this.paused)return;let t,e=this.parent.plugins.get("decelerate");e&&(e.x||e.y)&&(e.x&&e.percentChangeX===e.options.friction||e.y&&e.percentChangeY===e.options.friction)&&(((t=this.parent.OOB()).left&&this.left||t.right&&this.right)&&(e.percentChangeX=this.options.friction),(t.top&&this.top||t.bottom&&this.bottom)&&(e.percentChangeY=this.options.friction));const i=this.parent.plugins.get("drag")||{},s=this.parent.plugins.get("pinch")||{};if(e=e||{},!(i.active||s.active||this.toX&&this.toY||e.x&&e.y)){const i=(t=t||this.parent.OOB()).cornerPoint;if(!this.toX&&!e.x){let e=null;t.left&&this.left?e=this.parent.screenWorldWidththis.options.time)i=!0,s=this.startX+this.deltaX,n=this.startY+this.deltaY;else{const t=this.ease(e.time,0,1,this.options.time);s=this.startX+this.deltaX*t,n=this.startY+this.deltaY*t}this.options.topLeft?this.parent.moveCorner(s,n):this.parent.moveCenter(s,n),this.parent.emit("moved",{viewport:this.parent,type:"snap"}),i&&(this.options.removeOnComplete&&this.parent.plugins.remove("snap"),this.parent.emit("snap-end",this.parent),this.snapping=null)}else{const t=this.options.topLeft?this.parent.corner:this.parent.center;t.x===this.x&&t.y===this.y||this.snapStart()}}}const H={width:0,height:0,time:1e3,ease:"easeInOutSine",center:null,interrupt:!0,removeOnComplete:!1,removeOnInterrupts:!1,forceStart:!1,noMove:!1};class M extends h{constructor(t,e={}){super(t),this.options=Object.assign({},H,e),this.ease=y(this.options.ease),this.options.width>0&&(this.xScale=t.screenWidth/this.options.width),this.options.height>0&&(this.yScale=t.screenHeight/this.options.height),this.xIndependent=!!this.xScale,this.yIndependent=!!this.yScale,this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale,0===this.options.time?(t.container.scale.x=this.xScale,t.container.scale.y=this.yScale,this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom")):e.forceStart&&this.createSnapping()}createSnapping(){const t=this.parent.scale;this.snapping={time:0,startX:t.x,startY:t.y,deltaX:this.xScale-t.x,deltaY:this.yScale-t.y},this.parent.emit("snap-zoom-start",this.parent)}resize(){this.snapping=null,this.options.width>0&&(this.xScale=this.parent.screenWidth/this.options.width),this.options.height>0&&(this.yScale=this.parent.screenHeight/this.options.height),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale}reset(){this.snapping=null}wheel(){this.options.removeOnInterrupt&&this.parent.plugins.remove("snap-zoom")}down(){this.options.removeOnInterrupt?this.parent.plugins.remove("snap-zoom"):this.options.interrupt&&(this.snapping=null)}update(t){if(this.paused)return;if(this.options.interrupt&&0!==this.parent.input.count())return;let e;if(this.options.center||this.options.noMove||(e=this.parent.center),this.snapping){if(this.snapping){const i=this.snapping;if(i.time+=t,i.time>=this.options.time)this.parent.scale.set(this.xScale,this.yScale),this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom"),this.parent.emit("snap-zoom-end",this.parent),this.snapping=null;else{const t=this.snapping;this.parent.scale.x=this.ease(t.time,t.startX,t.deltaX,this.options.time),this.parent.scale.y=this.ease(t.time,t.startY,t.deltaY,this.options.time)}const s=this.parent.plugins.get("clamp-zoom");s&&s.clamp(),this.options.noMove||(this.options.center?this.parent.moveCenter(this.options.center):this.parent.moveCenter(e))}}else this.parent.scale.x===this.xScale&&this.parent.scale.y===this.yScale||this.createSnapping()}resume(){this.snapping=null,super.resume()}}const O={speed:0,acceleration:null,radius:null};class S extends h{constructor(t,e,i={}){super(t),this.target=e,this.options=Object.assign({},O,i),this.velocity={x:0,y:0}}update(t){if(this.paused)return;const e=this.parent.center;let i=this.target.x,s=this.target.y;if(this.options.radius){if(!(Math.sqrt(Math.pow(this.target.y-e.y,2)+Math.pow(this.target.x-e.x,2))>this.options.radius))return;{const t=Math.atan2(this.target.y-e.y,this.target.x-e.x);i=this.target.x-Math.cos(t)*this.options.radius,s=this.target.y-Math.sin(t)*this.options.radius}}const n=i-e.x,h=s-e.y;if(n||h)if(this.options.speed)if(this.options.acceleration){const o=Math.atan2(s-e.y,i-e.x),r=Math.sqrt(Math.pow(n,2)+Math.pow(h,2));if(r){const a=(Math.pow(this.velocity.x,2)+Math.pow(this.velocity.y,2))/(2*this.options.acceleration);this.velocity=r>a?{x:Math.min(this.velocity.x+this.options.acceleration*t,this.options.speed),y:Math.min(this.velocity.y+this.options.acceleration*t,this.options.speed)}:{x:Math.max(this.velocity.x-this.options.acceleration*this.options.speed,0),y:Math.max(this.velocity.y-this.options.acceleration*this.options.speed,0)};const p=Math.cos(o)*this.velocity.x,l=Math.sin(o)*this.velocity.y,c=Math.abs(p)>Math.abs(n)?i:e.x+p,d=Math.abs(l)>Math.abs(h)?s:e.y+l;this.parent.moveCenter(c,d),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}else{const t=Math.atan2(s-e.y,i-e.x),o=Math.cos(t)*this.options.speed,r=Math.sin(t)*this.options.speed,a=Math.abs(o)>Math.abs(n)?i:e.x+o,p=Math.abs(r)>Math.abs(h)?s:e.y+r;this.parent.moveCenter(a,p),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}else this.parent.moveCenter(i,s),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}const z={percent:.1,smooth:!1,interrupt:!0,reverse:!1,center:null};class I extends h{constructor(t,e={}){super(t),this.options=Object.assign({},z,e)}down(){this.options.interrupt&&(this.smoothing=null)}update(){if(this.smoothing){const t=this.smoothingCenter,e=this.smoothing;let i;this.options.center||(i=this.parent.toLocal(t)),this.parent.scale.x+=e.x,this.parent.scale.y+=e.y,this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const s=this.parent.plugins.get("clamp-zoom");if(s&&s.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const e=this.parent.toGlobal(i);this.parent.x+=t.x-e.x,this.parent.y+=t.y-e.y}this.smoothingCount++,this.smoothingCount>=this.options.smooth&&(this.smoothing=null)}}wheel(t){if(this.paused)return;let e=this.parent.input.getPointerPosition(t);const i=(this.options.reverse?-1:1)*-t.deltaY*(t.deltaMode?120:1)/500,s=Math.pow(2,(1+this.options.percent)*i);if(this.options.smooth){const t={x:this.smoothing?this.smoothing.x*(this.options.smooth-this.smoothingCount):0,y:this.smoothing?this.smoothing.y*(this.options.smooth-this.smoothingCount):0};this.smoothing={x:((this.parent.scale.x+t.x)*s-this.parent.scale.x)/this.options.smooth,y:((this.parent.scale.y+t.y)*s-this.parent.scale.y)/this.options.smooth},this.smoothingCount=0,this.smoothingCenter=e}else{let t;this.options.center||(t=this.parent.toLocal(e)),this.parent.scale.x*=s,this.parent.scale.y*=s,this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const i=this.parent.plugins.get("clamp-zoom");if(i&&i.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const i=this.parent.toGlobal(t);this.parent.x+=e.x-i.x,this.parent.y+=e.y-i.y}}return this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel",{wheel:{dx:t.deltaX,dy:t.deltaY,dz:t.deltaZ},event:t,viewport:this.parent}),!this.parent.options.passiveWheel||void 0}}const C={radius:null,distance:null,top:null,bottom:null,left:null,right:null,speed:8,reverse:!1,noDecelerate:!1,linear:!1,allowButtons:!1};class k extends h{constructor(t,e={}){super(t),this.options=Object.assign({},C,e),this.reverse=this.options.reverse?1:-1,this.radiusSquared=Math.pow(this.options.radius,2),this.resize()}resize(){const t=this.options.distance;null!==t?(this.left=t,this.top=t,this.right=this.parent.worldScreenWidth-t,this.bottom=this.parent.worldScreenHeight-t):this.radius||(this.left=this.options.left,this.top=this.options.top,this.right=null===this.options.right?null:this.parent.worldScreenWidth-this.options.right,this.bottom=null===this.options.bottom?null:this.parent.worldScreenHeight-this.options.bottom)}down(){this.options.allowButtons||(this.horizontal=this.vertical=null)}move(t){if("mouse"!==t.data.pointerType&&1!==t.data.identifier||!this.options.allowButtons&&0!==t.data.buttons)return;const e=t.data.global.x,i=t.data.global.y;if(this.radiusSquared){const t=this.parent.toScreen(this.parent.center);if(Math.pow(t.x-e,2)+Math.pow(t.y-i,2)>=this.radiusSquared){const s=Math.atan2(t.y-i,t.x-e);this.options.linear?(this.horizontal=Math.round(Math.cos(s))*this.options.speed*this.reverse*.06,this.vertical=Math.round(Math.sin(s))*this.options.speed*this.reverse*.06):(this.horizontal=Math.cos(s)*this.options.speed*this.reverse*.06,this.vertical=Math.sin(s)*this.options.speed*this.reverse*.06)}else this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=0}else null!==this.left&&ethis.right?this.horizontal=-1*this.reverse*this.options.speed*.06:(this.decelerateHorizontal(),this.horizontal=0),null!==this.top&&ithis.bottom?this.vertical=-1*this.reverse*this.options.speed*.06:(this.decelerateVertical(),this.vertical=0)}decelerateHorizontal(){const t=this.parent.plugins.get("decelerate");this.horizontal&&t&&!this.options.noDecelerate&&t.activate({x:this.horizontal*this.options.speed*this.reverse/(1e3/60)})}decelerateVertical(){const t=this.parent.plugins.get("decelerate");this.vertical&&t&&!this.options.noDecelerate&&t.activate({y:this.vertical*this.options.speed*this.reverse/(1e3/60)})}up(){this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=null}update(){if(!this.paused&&(this.horizontal||this.vertical)){const t=this.parent.center;this.horizontal&&(t.x+=this.horizontal*this.options.speed),this.vertical&&(t.y+=this.vertical*this.options.speed),this.parent.moveCenter(t),this.parent.emit("moved",{viewport:this.parent,type:"mouse-edges"})}}}const P={screenWidth:window.innerWidth,screenHeight:window.innerHeight,worldWidth:null,worldHeight:null,threshold:5,passiveWheel:!0,stopPropagation:!1,forceHitArea:null,noTicker:!1,interaction:null,disableOnContextMenu:!1};t.Plugin=h,t.Viewport=class extends e.Container{constructor(t={}){if(super(),this.options=Object.assign({},P,t),t.ticker)this.options.ticker=t.ticker;else{let i;const s=e;i=parseInt(/^(\d+)\./.exec(e.VERSION)[1])<5?s.ticker.shared:s.Ticker.shared,this.options.ticker=t.ticker||i}this.screenWidth=this.options.screenWidth,this.screenHeight=this.options.screenHeight,this._worldWidth=this.options.worldWidth,this._worldHeight=this.options.worldHeight,this.forceHitArea=this.options.forceHitArea,this.threshold=this.options.threshold,this.options.divWheel=this.options.divWheel||document.body,this.options.disableOnContextMenu&&(this.options.divWheel.oncontextmenu=t=>t.preventDefault()),this.options.noTicker||(this.tickerFunction=()=>this.update(this.options.ticker.elapsedMS),this.options.ticker.add(this.tickerFunction)),this.input=new i(this),this.plugins=new n(this)}destroy(t){this.options.noTicker||this.options.ticker.remove(this.tickerFunction),this.input.destroy(),super.destroy(t)}update(t){this.pause||(this.plugins.update(t),this.lastViewport&&(this.lastViewport.x!==this.x||this.lastViewport.y!==this.y?this.moving=!0:this.moving&&(this.emit("moved-end",this),this.moving=!1),this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y?this.zooming=!0:this.zooming&&(this.emit("zoomed-end",this),this.zooming=!1)),this.forceHitArea||(this._hitAreaDefault=new e.Rectangle(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight),this.hitArea=this._hitAreaDefault),this._dirty=this._dirty||!this.lastViewport||this.lastViewport.x!==this.x||this.lastViewport.y!==this.y||this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y,this.lastViewport={x:this.x,y:this.y,scaleX:this.scale.x,scaleY:this.scale.y},this.emit("frame-end",this))}resize(t=window.innerWidth,e=window.innerHeight,i,s){this.screenWidth=t,this.screenHeight=e,void 0!==i&&(this._worldWidth=i),void 0!==s&&(this._worldHeight=s),this.plugins.resize()}get worldWidth(){return this._worldWidth?this._worldWidth:this.width/this.scale.x}set worldWidth(t){this._worldWidth=t,this.plugins.resize()}get worldHeight(){return this._worldHeight?this._worldHeight:this.height/this.scale.y}set worldHeight(t){this._worldHeight=t,this.plugins.resize()}getVisibleBounds(){return new e.Rectangle(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight)}toWorld(t,i){return 2===arguments.length?this.toLocal(new e.Point(t,i)):this.toLocal(t)}toScreen(t,i){return 2===arguments.length?this.toGlobal(new e.Point(t,i)):this.toGlobal(t)}get worldScreenWidth(){return this.screenWidth/this.scale.x}get worldScreenHeight(){return this.screenHeight/this.scale.y}get screenWorldWidth(){return this.worldWidth*this.scale.x}get screenWorldHeight(){return this.worldHeight*this.scale.y}get center(){return new e.Point(this.worldScreenWidth/2-this.x/this.scale.x,this.worldScreenHeight/2-this.y/this.scale.y)}set center(t){this.moveCenter(t)}moveCenter(){let t,e;return isNaN(arguments[0])?(t=arguments[0].x,e=arguments[0].y):(t=arguments[0],e=arguments[1]),this.position.set((this.worldScreenWidth/2-t)*this.scale.x,(this.worldScreenHeight/2-e)*this.scale.y),this.plugins.reset(),this.dirty=!0,this}get corner(){return new e.Point(-this.x/this.scale.x,-this.y/this.scale.y)}set corner(t){this.moveCorner(t)}moveCorner(t,e){return 1===arguments.length?this.position.set(-t.x*this.scale.x,-t.y*this.scale.y):this.position.set(-t*this.scale.x,-e*this.scale.y),this.plugins.reset(),this}fitWidth(t,e,i=!0,s){let n;e&&(n=this.center),this.scale.x=this.screenWidth/t,i&&(this.scale.y=this.scale.x);const h=this.plugins.get("clamp-zoom");return!s&&h&&h.clamp(),e&&this.moveCenter(n),this}fitHeight(t,e,i=!0,s){let n;e&&(n=this.center),this.scale.y=this.screenHeight/t,i&&(this.scale.x=this.scale.y);const h=this.plugins.get("clamp-zoom");return!s&&h&&h.clamp(),e&&this.moveCenter(n),this}fitWorld(t){let e;t&&(e=this.center),this.scale.x=this.screenWidth/this.worldWidth,this.scale.y=this.screenHeight/this.worldHeight,this.scale.xthis._worldWidth,top:this.top<0,bottom:this.bottom>this._worldHeight,cornerPoint:new e.Point(this._worldWidth*this.scale.x-this.screenWidth,this._worldHeight*this.scale.y-this.screenHeight)}}get right(){return-this.x/this.scale.x+this.worldScreenWidth}set right(t){this.x=-t*this.scale.x+this.screenWidth,this.plugins.reset()}get left(){return-this.x/this.scale.x}set left(t){this.x=-t*this.scale.x,this.plugins.reset()}get top(){return-this.y/this.scale.y}set top(t){this.y=-t*this.scale.y,this.plugins.reset()}get bottom(){return-this.y/this.scale.y+this.worldScreenHeight}set bottom(t){this.y=-t*this.scale.y+this.screenHeight,this.plugins.reset()}get dirty(){return this._dirty}set dirty(t){this._dirty=t}get forceHitArea(){return this._forceHitArea}set forceHitArea(t){t?(this._forceHitArea=t,this.hitArea=t):(this._forceHitArea=null,this.hitArea=new e.Rectangle(0,0,this.worldWidth,this.worldHeight))}drag(t){return this.plugins.add("drag",new r(this,t)),this}clamp(t){return this.plugins.add("clamp",new c(this,t)),this}decelerate(t){return this.plugins.add("decelerate",new m(this,t)),this}bounce(t){return this.plugins.add("bounce",new v(this,t)),this}pinch(t){return this.plugins.add("pinch",new p(this,t)),this}snap(t,e,i){return this.plugins.add("snap",new W(this,t,e,i)),this}follow(t,e){return this.plugins.add("follow",new S(this,t,e)),this}wheel(t){return this.plugins.add("wheel",new I(this,t)),this}clampZoom(t){return this.plugins.add("clamp-zoom",new u(this,t)),this}mouseEdges(t){return this.plugins.add("mouse-edges",new k(this,t)),this}get pause(){return this._pause}set pause(t){this._pause=t,this.lastViewport=null,this.moving=!1,this.zooming=!1,t&&this.input.pause()}ensureVisible(t,e,i,s){tthis.right&&(this.right=t+i),ethis.bottom&&(this.bottom=e+s)}},Object.defineProperty(t,"__esModule",{value:!0})}); 2 | --------------------------------------------------------------------------------