minecraft-renderer 0.1.92 → 0.1.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/minecraft-renderer.js +21 -21
- package/dist/minecraft-renderer.js.meta.json +1 -1
- package/dist/threeWorker.js +3 -3
- package/package.json +1 -1
- package/src/graphicsBackend/config.ts +1 -1
- package/src/lib/worldrendererCommon.ts +1 -1
- package/src/three/entities.ts +27 -10
- package/src/three/worldRendererThree.ts +6 -5
package/package.json
CHANGED
|
@@ -22,7 +22,7 @@ export const defaultWorldRendererConfig = {
|
|
|
22
22
|
futuristicReveal: false,
|
|
23
23
|
|
|
24
24
|
/** Master toggle for section occlusion graph (smart / cave cull). Disabled in spectator. */
|
|
25
|
-
smartCull:
|
|
25
|
+
smartCull: false,
|
|
26
26
|
|
|
27
27
|
// Performance settings
|
|
28
28
|
wasmMesher: true,
|
|
@@ -57,7 +57,7 @@ export abstract class WorldRendererCommon<WorkerSend = any, WorkerReceive = any>
|
|
|
57
57
|
disableEntities: false,
|
|
58
58
|
/** Tint section borders by occlusion BFS step (perf debug overlay). */
|
|
59
59
|
caveCullingDebug: false,
|
|
60
|
-
smartCull:
|
|
60
|
+
smartCull: false
|
|
61
61
|
// disableParticles: false
|
|
62
62
|
})
|
|
63
63
|
|
package/src/three/entities.ts
CHANGED
|
@@ -316,6 +316,7 @@ export class Entities {
|
|
|
316
316
|
}
|
|
317
317
|
|
|
318
318
|
handlePlayerEntity(playerData: SceneEntity['originalEntity']) {
|
|
319
|
+
if (!this.isRenderingAllowed()) return
|
|
319
320
|
// Create player entity if it doesn't exist
|
|
320
321
|
if (!this.playerEntity) {
|
|
321
322
|
// Create the player entity similar to how normal entities are created
|
|
@@ -329,7 +330,7 @@ export class Entities {
|
|
|
329
330
|
|
|
330
331
|
group.name = 'player_entity'
|
|
331
332
|
this.playerEntity = group
|
|
332
|
-
this.
|
|
333
|
+
this.syncSceneAttachment(group)
|
|
333
334
|
|
|
334
335
|
void this.updatePlayerSkin(playerData.id, playerData.username, playerData.uuid ?? undefined, stevePngUrl)
|
|
335
336
|
}
|
|
@@ -392,9 +393,27 @@ export class Entities {
|
|
|
392
393
|
}
|
|
393
394
|
|
|
394
395
|
setRendering(rendering: boolean, entity: THREE.Object3D | null = null) {
|
|
395
|
-
this.currentlyRendering = rendering
|
|
396
|
-
|
|
397
|
-
|
|
396
|
+
this.currentlyRendering = rendering && this.isRenderingAllowed()
|
|
397
|
+
this.setSceneAttached(this.currentlyRendering, entity)
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
isRenderingAllowed(): boolean {
|
|
401
|
+
return this.worldRenderer.worldRendererConfig.renderEntities !== false && !this.worldRenderer.reactiveDebugParams.disableEntities
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/** Add or remove entity meshes from the scene (including third-person player). */
|
|
405
|
+
syncSceneAttachment(entity: THREE.Object3D | null = null): void {
|
|
406
|
+
const attached = this.isRenderingAllowed()
|
|
407
|
+
this.currentlyRendering = attached
|
|
408
|
+
this.setSceneAttached(attached, entity)
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
private setSceneAttached(attached: boolean, entity: THREE.Object3D | null = null): void {
|
|
412
|
+
const targets = entity
|
|
413
|
+
? [entity]
|
|
414
|
+
: [...Object.values(this.entities), ...(this.playerEntity ? [this.playerEntity] : [])]
|
|
415
|
+
for (const ent of targets) {
|
|
416
|
+
if (attached) {
|
|
398
417
|
if (!this.worldRenderer.scene.children.includes(ent)) this.worldRenderer.scene.add(ent)
|
|
399
418
|
} else {
|
|
400
419
|
this.worldRenderer.scene.remove(ent)
|
|
@@ -414,10 +433,8 @@ export class Entities {
|
|
|
414
433
|
}
|
|
415
434
|
|
|
416
435
|
render() {
|
|
417
|
-
|
|
418
|
-
if (
|
|
419
|
-
this.setRendering(renderEntitiesConfig)
|
|
420
|
-
}
|
|
436
|
+
this.syncSceneAttachment()
|
|
437
|
+
if (!this.isRenderingAllowed()) return
|
|
421
438
|
|
|
422
439
|
this.clock.update(performance.now())
|
|
423
440
|
const dt = Math.min(this.clock.getDelta(), 1 / 30)
|
|
@@ -892,6 +909,7 @@ export class Entities {
|
|
|
892
909
|
delete this.entities[entity.id]
|
|
893
910
|
return
|
|
894
911
|
}
|
|
912
|
+
if (!this.isRenderingAllowed()) return
|
|
895
913
|
|
|
896
914
|
let mesh: THREE.Object3D | undefined
|
|
897
915
|
if (e === undefined) {
|
|
@@ -985,7 +1003,6 @@ export class Entities {
|
|
|
985
1003
|
group.add(mesh)
|
|
986
1004
|
group.add(boxHelper)
|
|
987
1005
|
boxHelper.visible = false
|
|
988
|
-
this.worldRenderer.scene.add(group)
|
|
989
1006
|
|
|
990
1007
|
e = group
|
|
991
1008
|
e.name = 'entity'
|
|
@@ -996,7 +1013,7 @@ export class Entities {
|
|
|
996
1013
|
void this.updatePlayerSkin(entity.id, entity.username, overrides?.texture ? entity.uuid : undefined, overrides?.texture || stevePngUrl)
|
|
997
1014
|
}
|
|
998
1015
|
this.setDebugMode(this.debugMode, group)
|
|
999
|
-
this.
|
|
1016
|
+
this.syncSceneAttachment(group)
|
|
1000
1017
|
|
|
1001
1018
|
this.afterAddEntity(entity)
|
|
1002
1019
|
} else {
|
|
@@ -584,6 +584,9 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
584
584
|
this.onReactiveConfigUpdated('futuristicReveal', () => {
|
|
585
585
|
this.updateModulesFromConfig()
|
|
586
586
|
})
|
|
587
|
+
this.onReactiveDebugUpdated('disableEntities', () => {
|
|
588
|
+
this.entities.syncSceneAttachment()
|
|
589
|
+
})
|
|
587
590
|
|
|
588
591
|
let currentHandRenderer = this.displayOptions.inWorldRenderingConfig.handRenderer
|
|
589
592
|
this.onReactiveConfigUpdated('handRenderer', value => {
|
|
@@ -1363,11 +1366,9 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
1363
1366
|
this.chunkMeshManager.clearCullDirty()
|
|
1364
1367
|
}
|
|
1365
1368
|
this.chunkMeshManager.updateCaveCullingDebug(this.reactiveDebugParams.caveCullingDebug, smartCull)
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
entitiesRenderMs = performance.now() - entitiesStart
|
|
1370
|
-
}
|
|
1369
|
+
const entitiesStart = performance.now()
|
|
1370
|
+
this.entities.render()
|
|
1371
|
+
entitiesRenderMs = performance.now() - entitiesStart
|
|
1371
1372
|
this.chunkMeshManager.sortVisibleBlendSections(camX, camY, camZ)
|
|
1372
1373
|
if (!didBlendAllAttrUpload && globalLegacyBlendBuffer?.hasPendingIndexUploads()) {
|
|
1373
1374
|
globalLegacyBlendBuffer.uploadDirtyIndexRange()
|