pages235/renderer/viewer/lib/mesher/shared.ts
Vitaly Turovsky 14ad1c5934 sync fork: add a bunch of not needed side core features like translation
AND fix critical performance regression (& ram)
2025-04-23 05:55:59 +03:00

60 lines
1.6 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: Uint32Array | Uint16Array | number[],
indicesCount: number,
using32Array: boolean,
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)
}