@@ -57,13 +57,14 @@ import SKY_VERTEX_SHADER from './shaders/SkyVertexShader.js';
5757import SKY_FRAGMENT_SHADER from './shaders/SkyFragmentShader.js' ;
5858
5959import { stringToImage , pathFromCoords } from './utils.js' ;
60- import { getCookie , setCookie } from "./utils" ;
60+ import { cachePreventionNr , getCookie , setCookie } from "./utils" ;
6161
6262export default class BlueMap {
6363 constructor ( element , dataRoot ) {
6464 this . element = $ ( '<div class="bluemap-container"></div>' ) . appendTo ( element ) [ 0 ] ;
6565 this . dataRoot = dataRoot ;
6666 this . locationHash = '' ;
67+ this . cacheSuffix = '' ;
6768
6869 this . hiresViewDistance = 160 ;
6970 this . lowresViewDistance = 3200 ;
@@ -112,6 +113,17 @@ export default class BlueMap {
112113 } ) ;
113114 }
114115
116+ reloadMap ( ) {
117+ if ( this . hiresTileManager !== undefined ) {
118+ this . hiresTileManager . removeAllTiles ( ) ;
119+ this . hiresTileManager . update ( ) ;
120+ }
121+ if ( this . lowresTileManager !== undefined ) {
122+ this . lowresTileManager . removeAllTiles ( ) ;
123+ this . lowresTileManager . update ( ) ;
124+ }
125+ }
126+
115127 changeMap ( map , loadTiles = true ) {
116128 if ( this . debugInfo ) console . debug ( "changing map: " , map ) ;
117129
@@ -310,7 +322,7 @@ export default class BlueMap {
310322
311323 async loadSettings ( ) {
312324 return new Promise ( resolve => {
313- this . fileLoader . load ( this . dataRoot + 'settings.json' , settings => {
325+ this . fileLoader . load ( this . dataRoot + 'settings.json?' + cachePreventionNr ( ) , settings => {
314326 try {
315327 this . settings = JSON . parse ( settings ) ;
316328 this . maps = [ ] ;
@@ -379,6 +391,7 @@ export default class BlueMap {
379391 this . hiresViewDistance = this . loadUserSetting ( "hiresViewDistance" , this . hiresViewDistance ) ;
380392 this . lowresViewDistance = this . loadUserSetting ( "lowresViewDistance" , this . lowresViewDistance ) ;
381393 this . controls . settings . zoom . max = this . loadUserSetting ( "maxZoomDistance" , this . controls . settings . zoom . max ) ;
394+ this . cacheSuffix = this . loadUserSetting ( "cacheSuffix" , this . cacheSuffix ) ;
382395 this . debugInfo = this . loadUserSetting ( "debugInfo" , this . debugInfo ) ;
383396 }
384397
@@ -393,6 +406,7 @@ export default class BlueMap {
393406 this . saveUserSetting ( "hiresViewDistance" , this . hiresViewDistance ) ;
394407 this . saveUserSetting ( "lowresViewDistance" , this . lowresViewDistance ) ;
395408 this . saveUserSetting ( "maxZoomDistance" , this . controls . settings . zoom . max ) ;
409+ this . saveUserSetting ( "cacheSuffix" , this . cacheSuffix ) ;
396410 this . saveUserSetting ( "debugInfo" , this . debugInfo ) ;
397411 }
398412
@@ -427,7 +441,7 @@ export default class BlueMap {
427441
428442 async loadHiresMaterial ( ) {
429443 return new Promise ( resolve => {
430- this . fileLoader . load ( this . dataRoot + 'textures.json' , textures => {
444+ this . fileLoader . load ( this . dataRoot + 'textures.json?' + cachePreventionNr ( ) , textures => {
431445 textures = JSON . parse ( textures ) ;
432446 let materials = [ ] ;
433447 for ( let i = 0 ; i < textures [ 'textures' ] . length ; i ++ ) {
@@ -501,7 +515,7 @@ export default class BlueMap {
501515 async loadHiresTile ( tileX , tileZ ) {
502516 let path = this . dataRoot + this . map + '/hires/' ;
503517 path += pathFromCoords ( tileX , tileZ ) ;
504- path += '.json' ;
518+ path += '.json?' + this . cacheSuffix ;
505519
506520 return new Promise ( ( resolve , reject ) => {
507521 this . bufferGeometryLoader . load ( path , geometry => {
@@ -522,7 +536,7 @@ export default class BlueMap {
522536 async loadLowresTile ( tileX , tileZ ) {
523537 let path = this . dataRoot + this . map + '/lowres/' ;
524538 path += pathFromCoords ( tileX , tileZ ) ;
525- path += '.json' ;
539+ path += '.json?' + this . cacheSuffix ;
526540
527541 return new Promise ( ( reslove , reject ) => {
528542 this . bufferGeometryLoader . load ( path , geometry => {
0 commit comments