fix: fix more starfield issues, make disableable

This commit is contained in:
Vitaly Turovsky 2024-05-24 04:21:41 +03:00
commit 8fdcbdfc60
5 changed files with 44 additions and 18 deletions

View file

@ -277,11 +277,23 @@ export class WorldRendererThree extends WorldRendererCommon {
class StarField {
points?: THREE.Points
private _enabled = true
get enabled () {
return this._enabled
}
set enabled (value) {
this._enabled = value
if (this.points) {
this.points.visible = value
}
}
constructor(private scene: THREE.Scene) {
}
addToScene () {
if (this.points || !this.enabled) return
const radius = 80
const depth = 50
const count = 7000
@ -332,6 +344,7 @@ class StarField {
if (this.points) {
this.points.geometry.dispose();
(this.points.material as THREE.Material).dispose();
this.scene.remove(this.points)
this.points = undefined;
}

View file

@ -14,6 +14,7 @@ const updateAutoJump = () => {
jumpOnAllEdges: options.autoParkour,
// strictBlockCollision: true,
})
if (autoJump === bot.autoJumper.enabled) return
if (autoJump) {
bot.autoJumper.enable()
} else {

View file

@ -69,6 +69,7 @@ export const guiOptionsScheme: {
enableWarning: 'Enabling it will make chunks load ~4x slower',
disabledDuringGame: true
},
starfieldRendering: {}
},
],
main: [

View file

@ -30,24 +30,7 @@ const defaultOptions = {
touchButtonsSize: 40,
touchButtonsOpacity: 80,
touchButtonsPosition: 12,
touchControlsPositions: {
action: [
70,
85
],
sneak: [
90,
85
],
break: [
70,
65
],
jump: [
90,
65
],
} as Record<string, [number, number]>,
touchControlsPositions: getDefaultTouchControlsPositions(),
touchControlsType: 'classic' as 'classic' | 'joystick-buttons',
gpuPreference: 'default' as 'default' | 'high-performance' | 'low-power',
backgroundRendering: '20fps' as 'full' | '20fps' | '5fps',
@ -59,6 +42,7 @@ const defaultOptions = {
dayCycleAndLighting: true,
loadPlayerSkins: true,
lowMemoryMode: false,
starfieldRendering: true,
// antiAliasing: false,
showChunkBorders: false, // todo rename option
@ -73,6 +57,7 @@ const defaultOptions = {
disableLoadPrompts: false,
guestUsername: 'guest',
askGuestName: true,
errorReporting: true,
/** Actually might be useful */
showCursorBlockInSpectator: false,
renderEntities: true,
@ -91,6 +76,27 @@ const defaultOptions = {
wysiwygSignEditor: 'auto' as 'auto' | 'always' | 'never',
}
function getDefaultTouchControlsPositions () {
return {
action: [
70,
85
],
sneak: [
90,
85
],
break: [
70,
65
],
jump: [
90,
65
],
} as Record<string, [number, number]>
}
const qsOptionsRaw = new URLSearchParams(location.search).getAll('setting')
export const qsOptions = Object.fromEntries(qsOptionsRaw.map(o => {
const [key, value] = o.split(':')

View file

@ -57,4 +57,9 @@ export const watchOptionsAfterViewerInit = () => {
customEvents.on('gameLoaded', () => {
viewer.world.mesherConfig.enableLighting = !bot.supportFeature('blockStateId') || options.newVersionsLighting
})
watchValue(options, o => {
if (!(viewer.world instanceof WorldRendererThree)) return
viewer.world.starField.enabled = o.starfieldRendering
})
}