feat: add a setting to disable entities rendering
This commit is contained in:
parent
0d4023981d
commit
999afe5fa7
3 changed files with 14 additions and 0 deletions
|
|
@ -80,6 +80,7 @@ export class Entities extends EventEmitter {
|
|||
this.debugMode = 'none'
|
||||
this.onSkinUpdate = () => { }
|
||||
this.clock = new THREE.Clock()
|
||||
this.visible = true
|
||||
}
|
||||
|
||||
clear () {
|
||||
|
|
@ -102,6 +103,13 @@ export class Entities extends EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
setVisible(visible, /** @type {THREE.Object3D?} */entity = null) {
|
||||
this.visible = visible
|
||||
for (const mesh of entity ? [entity] : Object.values(this.entities)) {
|
||||
mesh.visible = visible
|
||||
}
|
||||
}
|
||||
|
||||
render () {
|
||||
const dt = this.clock.getDelta()
|
||||
for (const entityId of Object.keys(this.entities)) {
|
||||
|
|
@ -284,6 +292,7 @@ export class Entities extends EventEmitter {
|
|||
this.updatePlayerSkin(entity.id, '', stevePng)
|
||||
}
|
||||
this.setDebugMode(this.debugMode, group)
|
||||
this.setVisible(this.visible, group)
|
||||
}
|
||||
|
||||
// this can be undefined in case where packet entity_destroy was sent twice (so it was already deleted)
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ const defaultOptions = {
|
|||
askGuestName: true,
|
||||
/** Actually might be useful */
|
||||
showCursorBlockInSpectator: false,
|
||||
renderEntities: true,
|
||||
|
||||
// advanced bot options
|
||||
autoRespawn: false,
|
||||
|
|
|
|||
|
|
@ -29,4 +29,8 @@ export const watchOptionsAfterViewerInit = () => {
|
|||
viewer.composer = undefined
|
||||
}
|
||||
})
|
||||
|
||||
watchValue(options, o => {
|
||||
viewer.entities.setVisible(o.renderEntities)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue