Skip to content

Commit 5a8d7ed

Browse files
tritaodennisdev
authored andcommitted
Add some general comments to MapManager.
1 parent 7ff6633 commit 5a8d7ed

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/mapviewer/MapManager.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export class MapManager<T extends MapSquare> {
153153
const cameraX = camera.getPosX();
154154
const cameraZ = camera.getPosZ();
155155

156+
// Calculate which map square id to start and end on based on camera location and render distance (in tiles).
156157
const mapStartX = Math.floor((cameraX - renderDistance) / Scene.MAP_SQUARE_SIZE);
157158
const mapStartY = Math.floor((cameraZ - renderDistance) / Scene.MAP_SQUARE_SIZE);
158159

@@ -182,6 +183,9 @@ export class MapManager<T extends MapSquare> {
182183
}
183184
}
184185

186+
// Calculate which map squares to unload based on the unload distance and remove them.
187+
// Unload distance is the distance in number of map squares.
188+
185189
for (const map of this.mapSquares.values()) {
186190
const { mapX, mapY } = map;
187191
if (
@@ -195,6 +199,7 @@ export class MapManager<T extends MapSquare> {
195199
}
196200
}
197201

202+
// Sort the maps to render based on a front to back distance.
198203
if (renderBoundsChanged || camera.updatedPosition) {
199204
this.renderDistMapIds.length = this.renderDistMapCount;
200205
// sort front to back
@@ -229,6 +234,7 @@ export class MapManager<T extends MapSquare> {
229234
this.visibleMaps.length -= 1;
230235
}
231236

237+
// Update the render bounds based on the map squares we are rendering.
232238
this.renderBounds[0] = mapStartX;
233239
this.renderBounds[1] = mapStartY;
234240
this.renderBounds[2] = mapEndX;

0 commit comments

Comments
 (0)