File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ var World = class World {
5858 blocksDef : this . blocksDef ,
5959 } ,
6060 } ) ;
61+ this . lastPlayerChunk = "" ;
6162 }
6263 /**
6364 * Updates render order of chunk meshes
@@ -158,6 +159,7 @@ var World = class World {
158159 _this . cellMesh [ cellId ] . onAfterRender = function ( ) { } ;
159160 } ;
160161 this . game . scene . add ( this . cellMesh [ cellId ] ) ;
162+ this . updateRenderOrder ( JSON . parse ( this . lastPlayerChunk ) ) ;
161163 } else {
162164 this . cellMesh [ cellId ] . geometry = geometry ;
163165 }
@@ -288,15 +290,18 @@ var World = class World {
288290 Math . floor ( pos . y + 0.5 ) ,
289291 Math . floor ( pos . z + 0.5 )
290292 ) ;
291- this . updateRenderOrder ( cell ) ;
292- if (
293- this . cellUpdateTime !== null &&
294- performance . now ( ) - this . cellUpdateTime > this . renderTime
295- ) {
296- this . chunkWorker . postMessage ( {
297- type : "updateCellsAroundPlayer" ,
298- data : [ cell , radius ] ,
299- } ) ;
293+ if ( this . lastPlayerChunk != JSON . stringify ( cell ) ) {
294+ if (
295+ this . cellUpdateTime !== null &&
296+ performance . now ( ) - this . cellUpdateTime > this . renderTime
297+ ) {
298+ this . updateRenderOrder ( cell ) ;
299+ this . lastPlayerChunk = JSON . stringify ( cell ) ;
300+ this . chunkWorker . postMessage ( {
301+ type : "updateCellsAroundPlayer" ,
302+ data : [ cell , radius ] ,
303+ } ) ;
304+ }
300305 }
301306 }
302307 /**
You can’t perform that action at this time.
0 commit comments