Skip to content

Commit

Permalink
fix building, update test types
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Sep 3, 2024
1 parent c2a34ea commit 684261e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
19 changes: 13 additions & 6 deletions prismarine-viewer/examples/shared.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
export type BlockFaceType = {
side: number
textureIndex: number
textureName?: string
tint?: [number, number, number]
isTransparent?: boolean
side: number
textureIndex: number
tint?: [number, number, number]
isTransparent?: boolean

// for testing
face: string
neighbor: string
light?: number
}

export type BlockType = {
faces: BlockFaceType[]
faces: BlockFaceType[]

// for testing
block: string
}
15 changes: 4 additions & 11 deletions prismarine-viewer/viewer/lib/mesher/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,8 @@ for (const key of Object.keys(tintsData)) {
tints[key] = prepareTints(tintsData[key])
}

type TestTileData = {
block: string
faces: Array<{
face: string
neighbor: string
light?: number
}>
}

type Tiles = {
[blockPos: string]: BlockType & TestTileData
[blockPos: string]: BlockType
}

function prepareTints (tints) {
Expand Down Expand Up @@ -180,6 +171,8 @@ function renderLiquid (world: World, cursor: Vec3, texture: any | undefined, typ
tiles[`${cursor.x},${cursor.y},${cursor.z}`].faces.push({
face,
neighbor: `${neighborPos.x},${neighborPos.y},${neighborPos.z}`,
side: 0, // todo
textureIndex: 0,
// texture: eFace.texture.name,
})
}
Expand Down Expand Up @@ -374,7 +367,7 @@ function renderElement (world: World, cursor: Vec3, element: BlockElement, doAO:
tint: lightWithColor,
//@ts-expect-error debug prop
texture: eFace.texture.debugName || block.name,
} satisfies BlockType['faces'][number] & TestTileData['faces'][number] as any)
} satisfies BlockType['faces'][number])
}
}

Expand Down
7 changes: 4 additions & 3 deletions prismarine-viewer/viewer/lib/worldrendererCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import TypedEmitter from 'typed-emitter'
import { dynamicMcDataFiles } from '../../buildMesherConfig.mjs'
import { toMajorVersion } from '../../../src/utils'
import { buildCleanupDecorator } from './cleanupDecorator'
import { defaultMesherConfig } from './mesher/shared'
import { MesherGeometryOutput, defaultMesherConfig } from './mesher/shared'
import { chunkPos } from './simpleUtils'
import { HandItemBlock } from './holdingBlock'

Expand Down Expand Up @@ -123,8 +123,9 @@ export abstract class WorldRendererCommon<WorkerSend = any, WorkerReceive = any>
if (!this.active) return
this.handleWorkerMessage(data)
if (data.type === 'geometry') {
for (const key in data.geometry.highestBlocks) {
const highest = data.geometry.highestBlocks[key]
const geometry = data.geometry as MesherGeometryOutput
for (const key in geometry.highestBlocks) {
const highest = geometry.highestBlocks[key]
if (!this.highestBlocks[key] || this.highestBlocks[key].y < highest.y) {
this.highestBlocks[key] = highest
}
Expand Down

0 comments on commit 684261e

Please sign in to comment.