add debug method and fix f3 custom block name display
This commit is contained in:
parent
4f45cd072a
commit
f895304380
3 changed files with 26 additions and 1 deletions
|
|
@ -141,6 +141,13 @@ const handleMessage = data => {
|
|||
|
||||
break
|
||||
}
|
||||
case 'getCustomBlockModel': {
|
||||
const pos = new Vec3(data.pos.x, data.pos.y, data.pos.z)
|
||||
const chunkKey = `${Math.floor(pos.x / 16) * 16},${Math.floor(pos.z / 16) * 16}`
|
||||
const customBlockModel = world.customBlockModels.get(chunkKey)?.[`${pos.x},${pos.y},${pos.z}`]
|
||||
global.postMessage({ type: 'customBlockModel', chunkKey, customBlockModel })
|
||||
break
|
||||
}
|
||||
// No default
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -735,6 +735,24 @@ export abstract class WorldRendererCommon<WorkerSend = any, WorkerReceive = any>
|
|||
return hash + 1
|
||||
}
|
||||
|
||||
async debugGetWorkerCustomBlockModel (pos: Vec3) {
|
||||
const data = [] as Array<Promise<string>>
|
||||
for (const worker of this.workers) {
|
||||
data.push(new Promise((resolve) => {
|
||||
worker.addEventListener('message', (e) => {
|
||||
if (e.data.type === 'customBlockModel') {
|
||||
resolve(e.data.customBlockModel)
|
||||
}
|
||||
})
|
||||
}))
|
||||
worker.postMessage({
|
||||
type: 'getCustomBlockModel',
|
||||
pos
|
||||
})
|
||||
}
|
||||
return Promise.all(data)
|
||||
}
|
||||
|
||||
setSectionDirty (pos: Vec3, value = true, useChangeWorker = false) { // value false is used for unloading chunks
|
||||
if (this.viewDistance === -1) throw new Error('viewDistance not set')
|
||||
this.reactiveState.world.mesherWork = true
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ export default () => {
|
|||
setBlockInfo(null)
|
||||
return
|
||||
}
|
||||
const { customBlockName, modelInfo } = await getThreeJsRendererMethods()?.getBlockInfo(pos, block.stateId) ?? {}
|
||||
const { customBlockName, modelInfo } = await getThreeJsRendererMethods()?.getBlockInfo(block.position, block.stateId) ?? {}
|
||||
setBlockInfo({ customBlockName, modelInfo })
|
||||
}, 300)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue