Skip to content

Commit

Permalink
preserve webgpu params in options
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Dec 13, 2024
1 parent 7dde3fe commit 5b3fde9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/optionsStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const defaultOptions = {

// antiAliasing: false,

webgpuRendererParams: {},
clipWorldBelowY: undefined as undefined | number, // will be removed
disableSignsMapsSupport: false,
singleplayerAutoSave: false,
Expand Down
10 changes: 10 additions & 0 deletions src/watchOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { subscribeKey } from 'valtio/utils'
import { WorldRendererThree } from 'prismarine-viewer/viewer/lib/worldrendererThree'
import { isMobile } from 'prismarine-viewer/viewer/lib/simpleUtils'
import { WorldRendererWebgpu } from 'prismarine-viewer/viewer/lib/worldrendererWebgpu'
import { options, watchValue } from './optionsStorage'
import { reloadChunks } from './utils'
import { miscUiState } from './globalState'
Expand Down Expand Up @@ -96,6 +97,15 @@ export const watchOptionsAfterViewerInit = () => {
watchValue(options, o => {
viewer.powerPreference = o.gpuPreference
})

if (viewer.world instanceof WorldRendererWebgpu) {
Object.assign(viewer.world.rendererParams, options.webgpuRendererParams)
const oldUpdateRendererParams = viewer.world.updateRendererParams.bind(viewer.world)
viewer.world.updateRendererParams = (...args) => {
oldUpdateRendererParams(...args)
Object.assign(options.webgpuRendererParams, viewer.world.rendererParams)
}
}
}

let viewWatched = false
Expand Down

0 comments on commit 5b3fde9

Please sign in to comment.