fix: fix visual gaps between blocks of water!
This commit is contained in:
parent
1b20845ed5
commit
f126f56844
4 changed files with 45 additions and 26 deletions
|
|
@ -132,7 +132,7 @@ const getVec = (v: Vec3, dir: Vec3) => {
|
|||
return v.plus(dir)
|
||||
}
|
||||
|
||||
function renderLiquid (world: World, cursor: Vec3, texture: any | undefined, type: number, biome: string, water: boolean, attr: Record<string, any>, isRealWater: boolean) {
|
||||
function renderLiquid (world: World, cursor: Vec3, texture: any | undefined, type: number, biome: string, water: boolean, attr: MesherGeometryOutput, isRealWater: boolean) {
|
||||
const heights: number[] = []
|
||||
for (let z = -1; z <= 1; z++) {
|
||||
for (let x = -1; x <= 1; x++) {
|
||||
|
|
@ -192,13 +192,14 @@ function renderLiquid (world: World, cursor: Vec3, texture: any | undefined, typ
|
|||
|
||||
for (const pos of corners) {
|
||||
const height = cornerHeights[pos[2] * 2 + pos[0]]
|
||||
attr.t_positions.push(
|
||||
(pos[0] ? 0.999 : 0.001) + (cursor.x & 15) - 8,
|
||||
(pos[1] ? height - 0.001 : 0.001) + (cursor.y & 15) - 8,
|
||||
(pos[2] ? 0.999 : 0.001) + (cursor.z & 15) - 8
|
||||
const OFFSET = 0.0001
|
||||
attr.t_positions!.push(
|
||||
(pos[0] ? 1 - OFFSET : OFFSET) + (cursor.x & 15) - 8,
|
||||
(pos[1] ? height - OFFSET : OFFSET) + (cursor.y & 15) - 8,
|
||||
(pos[2] ? 1 - OFFSET : OFFSET) + (cursor.z & 15) - 8
|
||||
)
|
||||
attr.t_normals.push(...dir)
|
||||
attr.t_uvs.push(pos[3] * su + u, pos[4] * sv * (pos[1] ? 1 : height) + v)
|
||||
attr.t_normals!.push(...dir)
|
||||
attr.t_uvs!.push(pos[3] * su + u, pos[4] * sv * (pos[1] ? 1 : height) + v)
|
||||
|
||||
let cornerLightResult = baseLight
|
||||
if (world.config.smoothLighting) {
|
||||
|
|
@ -223,7 +224,7 @@ function renderLiquid (world: World, cursor: Vec3, texture: any | undefined, typ
|
|||
}
|
||||
|
||||
// Apply light value to tint
|
||||
attr.t_colors.push(tint[0] * cornerLightResult, tint[1] * cornerLightResult, tint[2] * cornerLightResult)
|
||||
attr.t_colors!.push(tint[0] * cornerLightResult, tint[1] * cornerLightResult, tint[2] * cornerLightResult)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -487,7 +488,7 @@ const isBlockWaterlogged = (block: Block) => {
|
|||
}
|
||||
|
||||
let unknownBlockModel: BlockModelPartsResolved
|
||||
export function getSectionGeometry (sx, sy, sz, world: World) {
|
||||
export function getSectionGeometry (sx: number, sy: number, sz: number, world: World) {
|
||||
let delayedRender = [] as Array<() => void>
|
||||
|
||||
const attr: MesherGeometryOutput = {
|
||||
|
|
|
|||
|
|
@ -197,7 +197,9 @@ export class WorldDataEmitter extends (EventEmitter as new () => TypedEmitter<Wo
|
|||
async init (pos: Vec3) {
|
||||
this.updateViewDistance(this.viewDistance)
|
||||
this.emitter.emit('chunkPosUpdate', { pos })
|
||||
this.emitter.emit('time', bot.time.timeOfDay)
|
||||
if (bot?.time?.timeOfDay) {
|
||||
this.emitter.emit('time', bot.time.timeOfDay)
|
||||
}
|
||||
this.emitterGotConnected()
|
||||
const [botX, botZ] = chunkPos(pos)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { WorldDataEmitter, WorldDataEmitterWorker } from 'renderer/viewer/lib/worldDataEmitter'
|
||||
import { PlayerStateRenderer } from 'renderer/viewer/lib/basePlayerState'
|
||||
import { getInitialPlayerState, PlayerStateRenderer } from 'renderer/viewer/lib/basePlayerState'
|
||||
import { subscribeKey } from 'valtio/utils'
|
||||
import { defaultWorldRendererConfig, WorldRendererConfig } from 'renderer/viewer/lib/worldrendererCommon'
|
||||
import { Vec3 } from 'vec3'
|
||||
|
|
@ -281,19 +281,31 @@ const initialMenuStart = async () => {
|
|||
if (appViewer.currentDisplay === 'world') {
|
||||
appViewer.resetBackend(true)
|
||||
}
|
||||
appViewer.startPanorama()
|
||||
const demo = new URLSearchParams(window.location.search).get('demo')
|
||||
if (!demo) {
|
||||
appViewer.startPanorama()
|
||||
return
|
||||
}
|
||||
|
||||
// const version = '1.18.2'
|
||||
// const version = '1.21.4'
|
||||
// await appViewer.resourcesManager.loadMcData(version)
|
||||
// const world = getSyncWorld(version)
|
||||
// world.setBlockStateId(new Vec3(0, 64, 0), loadedData.blocksByName.water.defaultState)
|
||||
// appViewer.resourcesManager.currentConfig = { version }
|
||||
// await appViewer.resourcesManager.updateAssetsData({})
|
||||
// appViewer.playerState = new BasePlayerState() as any
|
||||
// await appViewer.startWorld(world, 3)
|
||||
// appViewer.backend?.updateCamera(new Vec3(0, 64, 2), 0, 0)
|
||||
// void appViewer.worldView!.init(new Vec3(0, 64, 0))
|
||||
const version = '1.21.4'
|
||||
const { loadMinecraftData } = await import('./connect')
|
||||
const { getSyncWorld } = await import('../renderer/playground/shared')
|
||||
await loadMinecraftData(version)
|
||||
const world = getSyncWorld(version)
|
||||
world.setBlockStateId(new Vec3(0, 64, 0), loadedData.blocksByName.water.defaultState)
|
||||
world.setBlockStateId(new Vec3(1, 64, 0), loadedData.blocksByName.water.defaultState)
|
||||
world.setBlockStateId(new Vec3(1, 64, 1), loadedData.blocksByName.water.defaultState)
|
||||
world.setBlockStateId(new Vec3(0, 64, 1), loadedData.blocksByName.water.defaultState)
|
||||
world.setBlockStateId(new Vec3(-1, 64, -1), loadedData.blocksByName.water.defaultState)
|
||||
world.setBlockStateId(new Vec3(-1, 64, 0), loadedData.blocksByName.water.defaultState)
|
||||
world.setBlockStateId(new Vec3(0, 64, -1), loadedData.blocksByName.water.defaultState)
|
||||
appViewer.resourcesManager.currentConfig = { version }
|
||||
appViewer.playerState.reactive = getInitialPlayerState()
|
||||
await appViewer.resourcesManager.updateAssetsData({})
|
||||
await appViewer.startWorld(world, 3)
|
||||
appViewer.backend!.updateCamera(new Vec3(0, 65.7, 0), 0, -Math.PI / 2) // Y+1 and pitch = PI/2 to look down
|
||||
void appViewer.worldView!.init(new Vec3(0, 64, 0))
|
||||
}
|
||||
window.initialMenuStart = initialMenuStart
|
||||
|
||||
|
|
|
|||
|
|
@ -276,13 +276,17 @@ const PerComponentErrorBoundary = ({ children }) => {
|
|||
</ErrorBoundary>)
|
||||
}
|
||||
|
||||
renderToDom(<App />, {
|
||||
strictMode: false,
|
||||
selector: '#react-root',
|
||||
})
|
||||
if (!new URLSearchParams(window.location.search).get('no-ui')) {
|
||||
renderToDom(<App />, {
|
||||
strictMode: false,
|
||||
selector: '#react-root',
|
||||
})
|
||||
}
|
||||
|
||||
disableReactProfiling()
|
||||
function disableReactProfiling () {
|
||||
if (window.reactPerfPatchApplied) return
|
||||
window.reactPerfPatchApplied = true
|
||||
//@ts-expect-error
|
||||
window.performance.markOrig = window.performance.mark
|
||||
//@ts-expect-error
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue