Skip to content

Commit 99d05fc

Browse files
committed
improve stability of minimap
(though full refactor is still needed)
1 parent 0c68e63 commit 99d05fc

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

renderer/viewer/lib/mesher/mesher.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Vec3 } from 'vec3'
22
import { World } from './world'
33
import { getSectionGeometry, setBlockStatesData as setMesherData } from './models'
44
import { BlockStateModelInfo } from './shared'
5+
import { INVISIBLE_BLOCKS } from './worldConstants'
56

67
globalThis.structuredClone ??= (value) => JSON.parse(JSON.stringify(value))
78

@@ -156,10 +157,11 @@ const handleMessage = data => {
156157
for (let x = 0; x < 16; x++) {
157158
const blockX = x + data.x
158159
const blockZ = z + data.z
159-
blockPos.x = blockX; blockPos.z = blockZ
160-
blockPos.y = 256
160+
blockPos.x = blockX
161+
blockPos.z = blockZ
162+
blockPos.y = world.config.worldMaxY
161163
let block = world.getBlock(blockPos)
162-
while (block?.name.includes('air')) {
164+
while (block && INVISIBLE_BLOCKS.has(block.name)) {
163165
blockPos.y -= 1
164166
block = world.getBlock(blockPos)
165167
}

renderer/viewer/lib/mesher/shared.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { BlockType } from '../../../playground/shared'
33
// only here for easier testing
44
export const defaultMesherConfig = {
55
version: '',
6+
worldMaxY: 256,
7+
worldMinY: 0,
68
enableLighting: true,
79
skyLight: 15,
810
smoothLighting: true,

renderer/viewer/lib/worldrendererCommon.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,9 @@ export abstract class WorldRendererCommon<WorkerSend = any, WorkerReceive = any>
560560
textureSize: this.resourcesManager.currentResources!.blocksAtlasParser.atlas.latest.width,
561561
debugModelVariant: undefined,
562562
clipWorldBelowY: this.worldRendererConfig.clipWorldBelowY,
563-
disableSignsMapsSupport: !this.worldRendererConfig.extraBlockRenderers
563+
disableSignsMapsSupport: !this.worldRendererConfig.extraBlockRenderers,
564+
worldMinY: this.worldMinYRender,
565+
worldMaxY: this.worldMinYRender + this.worldSizeParams.worldHeight,
564566
}
565567
}
566568

src/react/MinimapProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class DrawerAdapterImpl extends TypedEventEmitter<MapUpdates> implements
4545
chunksStore = new Map<string, undefined | null | 'requested' | ChunkInfo>()
4646
loadingChunksQueue = new Set<string>()
4747
loadChunk: (key: string) => Promise<void> = this.loadChunkMinimap
48-
mapDrawer = new MinimapDrawer(this.loadChunk, this.warps, this.loadingChunksQueue, this.chunksStore)
48+
mapDrawer = new MinimapDrawer(this.loadChunk.bind(this), this.warps, this.loadingChunksQueue, this.chunksStore)
4949
currChunk: PCChunk | undefined
5050
currChunkPos: { x: number, z: number } = { x: 0, z: 0 }
5151
isOldVersion: boolean

0 commit comments

Comments
 (0)