pages235/renderer/viewer/lib/mesher/shared.ts
Vitaly Turovsky 33debc1475 feat(experimental): make loading chunks as smooth as possible by delaying work to get more rendered fps at that time. It helps to eliminate massive fps drops on big chunks of data, however might introduce new possible race conditions.
Also disabled full maps completely because it was hard to optimize atm.
Now chunks load ~30-50% slower but smoother. Note that using waitChunksToLoad settings remains unchanged - time is the same
2025-03-26 03:48:22 +03:00

58 lines
1.5 KiB
TypeScript

import { BlockType } from '../../../playground/shared'
// only here for easier testing
export const defaultMesherConfig = {
version: '',
enableLighting: true,
skyLight: 15,
smoothLighting: true,
outputFormat: 'threeJs' as 'threeJs' | 'webgpu',
textureSize: 1024, // for testing
debugModelVariant: undefined as undefined | number[],
clipWorldBelowY: undefined as undefined | number,
disableSignsMapsSupport: false
}
export type CustomBlockModels = {
[blockPosKey: string]: string // blockPosKey is "x,y,z" -> model name
}
export type MesherConfig = typeof defaultMesherConfig
export type MesherGeometryOutput = {
sx: number,
sy: number,
sz: number,
// resulting: float32array
positions: any,
normals: any,
colors: any,
uvs: any,
t_positions?: number[],
t_normals?: number[],
t_colors?: number[],
t_uvs?: number[],
indices: number[],
tiles: Record<string, BlockType>,
heads: Record<string, any>,
signs: Record<string, any>,
// isFull: boolean
highestBlocks: Record<string, HighestBlockInfo>
hadErrors: boolean
blocksCount: number
customBlockModels?: CustomBlockModels
}
export type HighestBlockInfo = { y: number, stateId: number | undefined, biomeId: number | undefined }
export type BlockStateModelInfo = {
cacheKey: string
issues: string[]
modelNames: string[]
conditions: string[]
}
export const getBlockAssetsCacheKey = (stateId: number, modelNameOverride?: string) => {
return modelNameOverride ? `${stateId}:${modelNameOverride}` : String(stateId)
}