diff --git a/experiments/state.html b/experiments/state.html new file mode 100644 index 00000000..7a5282b7 --- /dev/null +++ b/experiments/state.html @@ -0,0 +1 @@ + diff --git a/experiments/state.ts b/experiments/state.ts new file mode 100644 index 00000000..b01523fc --- /dev/null +++ b/experiments/state.ts @@ -0,0 +1,37 @@ +import { SmoothSwitcher } from '../renderer/viewer/lib/smoothSwitcher' + +const div = document.createElement('div') +div.style.width = '100px' +div.style.height = '100px' +div.style.backgroundColor = 'red' +document.body.appendChild(div) + +const pos = {x: 0, y: 0} + +const positionSwitcher = new SmoothSwitcher(() => pos, (key, value) => { + pos[key] = value +}) +globalThis.positionSwitcher = positionSwitcher + +document.body.addEventListener('keydown', e => { + if (e.code === 'ArrowLeft' || e.code === 'ArrowRight') { + const to = { + x: e.code === 'ArrowLeft' ? -100 : 100 + } + console.log(pos, to) + positionSwitcher.transitionTo(to, e.code === 'ArrowLeft' ? 'Left' : 'Right', () => { + console.log('Switched to ', e.code === 'ArrowLeft' ? 'Left' : 'Right') + }) + } + if (e.code === 'Space') { + pos.x = 200 + } +}) + +const render = () => { + positionSwitcher.update() + div.style.transform = `translate(${pos.x}px, ${pos.y}px)` + requestAnimationFrame(render) +} + +render() diff --git a/renderer/viewer/lib/mesher/world.ts b/renderer/viewer/lib/mesher/world.ts index b914e8cf..2106e179 100644 --- a/renderer/viewer/lib/mesher/world.ts +++ b/renderer/viewer/lib/mesher/world.ts @@ -144,7 +144,7 @@ export class World { if (!this.blockCache[cacheKey]) { const b = column.getBlock(locInChunk) as unknown as WorldBlock if (modelOverride) { - b.name = modelOverride + // b.name = modelOverride } b.isCube = isCube(b.shapes) this.blockCache[cacheKey] = b @@ -228,6 +228,11 @@ export class World { } block.models = null } + + if (block.models && modelOverride) { + const model = block.models[0] + block.transparent = model['transparent'] ?? block.transparent + } } catch (err) { this.erroredBlockModel ??= blockProvider.getAllResolvedModels0_1({ name: 'errored', properties: {} }) block.models ??= this.erroredBlockModel diff --git a/src/customChannels.ts b/src/customChannels.ts index 33bc8fcd..71dc7067 100644 --- a/src/customChannels.ts +++ b/src/customChannels.ts @@ -41,7 +41,6 @@ customEvents.on('mineflayerBotCreated', async () => { bot._client.on(CHANNEL_NAME as any, (data) => { const { worldName, x, y, z, model } = data - console.debug('Received model data:', { worldName, x, y, z, model }) const chunkX = Math.floor(x / 16) * 16 const chunkZ = Math.floor(z / 16) * 16