Skip to content

Commit

Permalink
Merge branch 'webgpu-true' of https://github.com/sa2urami/prismarine-…
Browse files Browse the repository at this point in the history
…web-client into webgpu-true
  • Loading branch information
sa2urami committed Dec 4, 2024
2 parents 0b90dc5 + fa1daf6 commit de20a94
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
7 changes: 4 additions & 3 deletions prismarine-viewer/examples/chunksStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,10 @@ export class ChunksStorage {
const chunkIndex = this.chunks.indexOf(chunk)
this.chunksMap.set(rawPosKey, chunkIndex)

// newData.forEach(newDatum => {
// newDatum[3].chunk = chunkIndex
// })
for (const newDatum of newData) {
//@ts-expect-error
newDatum[3].chunk = chunkIndex
}

this.addBlocksData(start, newData)
this.awaitingUpdateStart = Math.min(this.awaitingUpdateStart ?? Infinity, start)
Expand Down
16 changes: 9 additions & 7 deletions prismarine-viewer/examples/webgpuRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,18 +624,18 @@ export class WebgpuRenderer {
const blocksToUpdate = allBlocks.slice(updateOffset, updateOffset + updateSize)
const actualCount = updateOffset + blocksToUpdate.length

let chunk = chunksStorage.findBelongingChunk(updateOffset)!
let remaining = chunk.chunk.length
// let chunk = chunksStorage.findBelongingChunk(updateOffset)!
// let remaining = chunk.chunk.length
// eslint-disable-next-line unicorn/no-for-loop
for (let i = 0; i < blocksToUpdate.length; i++) {
if (remaining-- === 0) {
chunk = chunksStorage.findBelongingChunk(updateOffset + i)!
remaining = chunk.chunk.length - 1
}
// if (remaining-- === 0) {
// chunk = chunksStorage.findBelongingChunk(updateOffset + i)!
// remaining = chunk.chunk.length - 1
// }

let first = 0
let second = 0
const third = chunk.index
let third = 0
const chunkBlock = blocksToUpdate[i]
if (chunkBlock) {
const [x, y, z, block] = chunkBlock
Expand All @@ -656,6 +656,8 @@ export class WebgpuRenderer {
(visibility[4] << 4) |
(visibility[5] << 5)
second = ((visibilityCombined << 8 | colors[2]) << 8 | colors[1]) << 8 | colors[0]
//@ts-expect-error
third = block.chunk
}

cubeFlatData[i * 3] = first
Expand Down

0 comments on commit de20a94

Please sign in to comment.