minecraft-renderer 0.1.79 → 0.1.80
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/README.md +29 -25
- package/dist/mesher.js +36 -36
- package/dist/mesher.js.map +4 -4
- package/dist/mesherWasm.js +217 -217
- package/dist/minecraft-renderer.js +27 -27
- package/dist/minecraft-renderer.js.meta.json +1 -1
- package/dist/threeWorker.js +133 -133
- package/package.json +5 -2
- package/src/bundler/bundlePrepare.ts +3 -8
- package/src/graphicsBackend/appViewer.ts +10 -7
- package/src/graphicsBackend/config.ts +1 -5
- package/src/graphicsBackend/playerState.ts +35 -34
- package/src/graphicsBackend/preloadWorkers.ts +43 -41
- package/src/graphicsBackend/rendererDefaultOptions.ts +68 -70
- package/src/graphicsBackend/rendererOptionsSync.ts +24 -50
- package/src/graphicsBackend/types.ts +2 -2
- package/src/index.ts +6 -27
- package/src/lib/DebugGui.ts +34 -31
- package/src/lib/animationController.ts +9 -9
- package/src/lib/bakeLegacyLight.ts +1 -6
- package/src/lib/bindAbortableListener.test.ts +32 -12
- package/src/lib/bindAbortableListener.ts +14 -6
- package/src/lib/blockEntityLightRegistry.ts +11 -20
- package/src/lib/blockEntityLighting.test.ts +1 -6
- package/src/lib/blockEntityLighting.ts +5 -5
- package/src/lib/buildSharedConfig.mjs +4 -4
- package/src/lib/buildWorkerMcDataIndexes.test.ts +4 -4
- package/src/lib/buildWorkerMcDataIndexes.ts +11 -19
- package/src/lib/cameraBobbing.ts +1 -1
- package/src/lib/canvas2DOverlay.example.ts +13 -33
- package/src/lib/canvas2DOverlay.quickstart.ts +24 -54
- package/src/lib/canvas2DOverlay.ts +28 -47
- package/src/lib/cleanupDecorator.ts +2 -2
- package/src/lib/createPlayerObject.test.ts +2 -7
- package/src/lib/createPlayerObject.ts +18 -25
- package/src/lib/frameTimingCollector.ts +2 -5
- package/src/lib/guiRenderer.ts +57 -42
- package/src/lib/items.ts +15 -9
- package/src/lib/mesherlogReader.ts +5 -6
- package/src/lib/simpleUtils.ts +5 -5
- package/src/lib/skyLight.ts +3 -3
- package/src/lib/smoothSwitcher.ts +11 -18
- package/src/lib/ui/newStats.ts +10 -12
- package/src/lib/utils/proxy.ts +7 -1
- package/src/lib/utils/skins.ts +4 -4
- package/src/lib/utils.ts +1 -1
- package/src/lib/workerMessageSanitize.ts +5 -12
- package/src/lib/workerProxy.ts +52 -42
- package/src/lib/workerSyncOps.test.ts +58 -41
- package/src/lib/worldrendererCommon.reconfigure.test.ts +24 -21
- package/src/lib/worldrendererCommon.removeColumn.test.ts +11 -13
- package/src/lib/worldrendererCommon.ts +338 -211
- package/src/mesher-legacy/mesher.ts +9 -4
- package/src/mesher-legacy/test/a.ts +1 -1
- package/src/mesher-legacy/test/mesherTester.ts +2 -2
- package/src/mesher-legacy/test/playground.ts +1 -1
- package/src/mesher-legacy/test/run/test-js.ts +1 -1
- package/src/mesher-legacy/test/snapshotUtils.ts +3 -8
- package/src/mesher-legacy/test/test-perf.ts +1 -1
- package/src/mesher-legacy/test/tests.test.ts +2 -2
- package/src/mesher-shared/blockEntityMetadata.test.ts +7 -5
- package/src/mesher-shared/blockEntityMetadata.ts +28 -19
- package/src/mesher-shared/blockPropertiesForMeshing.ts +2 -2
- package/src/mesher-shared/computeHeightmap.ts +2 -4
- package/src/mesher-shared/exportedGeometryTypes.ts +3 -3
- package/src/mesher-shared/faceOcclusion.ts +324 -0
- package/src/mesher-shared/models.ts +80 -131
- package/src/mesher-shared/modelsGeometryCommon.ts +30 -15
- package/src/mesher-shared/shared.ts +46 -46
- package/src/mesher-shared/standaloneRenderer.ts +40 -44
- package/src/mesher-shared/tests/faceOcclusion.test.ts +179 -0
- package/src/mesher-shared/tests/liquidQuadInvariant.test.ts +12 -8
- package/src/mesher-shared/vertexShading.ts +2 -11
- package/src/mesher-shared/world.ts +19 -19
- package/src/mesher-shared/worldLighting.test.ts +2 -2
- package/src/performanceMonitor/PerformanceMonitor.ts +4 -13
- package/src/performanceMonitor/formatPerformanceFactorsDebug.ts +2 -2
- package/src/performanceMonitor/index.ts +1 -5
- package/src/performanceMonitor/types.ts +1 -1
- package/src/playerState/playerState.ts +55 -50
- package/src/playerState/types.ts +2 -8
- package/src/playground/allEntitiesDebug.ts +19 -16
- package/src/playground/baseScene.ts +29 -32
- package/src/playground/mobileControls.tsx +133 -129
- package/src/playground/playground.html +76 -73
- package/src/playground/playground.ts +14 -1
- package/src/playground/playgroundUi.tsx +100 -74
- package/src/playground/reactUtils.ts +3 -7
- package/src/playground/scenes/entities.ts +10 -7
- package/src/playground/scenes/frequentUpdates.ts +5 -5
- package/src/playground/scenes/geometryExport.ts +6 -20
- package/src/playground/scenes/highPosEntityUpdates.ts +2 -10
- package/src/playground/scenes/index.ts +1 -1
- package/src/playground/scenes/lightingStarfield.ts +18 -12
- package/src/playground/scenes/main.ts +15 -11
- package/src/playground/scenes/partialBlockCulling.ts +31 -0
- package/src/playground/scenes/railsCobweb.ts +1 -1
- package/src/playground/scenes/rotationIssue.ts +1 -1
- package/src/playground/scenes/slabsOptimization.ts +1 -2
- package/src/playground/scenes/transparencyIssue.ts +1 -1
- package/src/playground/shared.ts +2 -2
- package/src/resourcesManager/resourcesManager.ts +29 -54
- package/src/resourcesManager/resourcesManager.worker.test.ts +6 -10
- package/src/shims/minecraftData.ts +70 -24
- package/src/sign-renderer/index.html +10 -12
- package/src/sign-renderer/index.ts +29 -29
- package/src/sign-renderer/playground.ts +22 -15
- package/src/sign-renderer/tests.test.ts +16 -13
- package/src/sign-renderer/vite.config.ts +2 -2
- package/src/three/appShared.ts +46 -25
- package/src/three/bannerRenderer.ts +33 -61
- package/src/three/cameraShake.ts +15 -6
- package/src/three/chunkMeshManager.ts +239 -282
- package/src/three/cinimaticScript.ts +26 -15
- package/src/three/cubeDrawSpans.ts +27 -37
- package/src/three/cubeMultiDraw.ts +9 -22
- package/src/three/documentRenderer.ts +15 -18
- package/src/three/entities.ts +175 -150
- package/src/three/entity/EntityMesh.ts +114 -108
- package/src/three/entity/animations.js +3 -3
- package/src/three/entity/armorModels.ts +15 -15
- package/src/three/entity/gltfAnimationUtils.ts +2 -5
- package/src/three/fireworks.ts +34 -32
- package/src/three/fireworksRenderer.ts +32 -29
- package/src/three/globalBlockBuffer.ts +167 -100
- package/src/three/globalLegacyBuffer.ts +257 -166
- package/src/three/graphicsBackendBase.ts +19 -25
- package/src/three/graphicsBackendOffThread.ts +12 -15
- package/src/three/hand.ts +21 -21
- package/src/three/handLegacy.ts +3 -13
- package/src/three/holdingBlock.ts +116 -79
- package/src/three/holdingBlockFactory.ts +1 -4
- package/src/three/holdingBlockItemIdentity.test.ts +25 -17
- package/src/three/holdingBlockItemIdentity.ts +9 -6
- package/src/three/holdingBlockLegacy.ts +113 -132
- package/src/three/itemMesh.ts +20 -29
- package/src/three/legacyMultiDraw.ts +10 -16
- package/src/three/legacySectionCull.ts +8 -14
- package/src/three/menuBackground/activeView.ts +1 -4
- package/src/three/menuBackground/assetUrl.ts +1 -1
- package/src/three/menuBackground/classic.ts +4 -12
- package/src/three/menuBackground/gpuPreference.ts +1 -3
- package/src/three/menuBackground/index.ts +2 -11
- package/src/three/menuBackground/renderer.ts +1 -5
- package/src/three/menuBackground/types.ts +1 -4
- package/src/three/menuBackground/v2.ts +196 -96
- package/src/three/menuBackground/v2Meta.ts +3 -3
- package/src/three/menuBackground/worldBlocks.ts +37 -35
- package/src/three/modules/blockBreakParticles.ts +59 -28
- package/src/three/modules/cameraBobbing.ts +3 -6
- package/src/three/modules/index.ts +1 -1
- package/src/three/modules/rain.ts +10 -23
- package/src/three/modules/sciFiWorldReveal.ts +11 -25
- package/src/three/modules/starfield.ts +7 -13
- package/src/three/renderSlot.ts +28 -16
- package/src/three/rendererModuleSystem.ts +1 -3
- package/src/three/sceneOrigin.ts +96 -33
- package/src/three/sectionRaycastAabb.ts +30 -18
- package/src/three/shaderCubeMesh.ts +6 -17
- package/src/three/shaders/cubeBlockShader.ts +85 -96
- package/src/three/shaders/legacyBlockShader.ts +21 -43
- package/src/three/shaders/textureIndexMapping.ts +89 -95
- package/src/three/shaders/tintPalette.ts +156 -170
- package/src/three/signTextureCache.ts +9 -12
- package/src/three/skyboxRenderer.ts +62 -70
- package/src/three/tests/chunkMeshManagerLegacy.test.ts +34 -34
- package/src/three/tests/cubeDrawSpans.test.ts +55 -25
- package/src/three/tests/globalBlockBuffer.test.ts +217 -0
- package/src/three/tests/globalLegacyBuffer.test.ts +300 -41
- package/src/three/tests/legacyMultiDraw.test.ts +8 -29
- package/src/three/tests/pr3PerFrameCpuCuts.test.ts +106 -29
- package/src/three/tests/signTextureCache.test.ts +4 -4
- package/src/three/threeJsMedia.ts +55 -72
- package/src/three/threeJsParticles.ts +32 -41
- package/src/three/threeJsSound.ts +3 -3
- package/src/three/threeJsUtils.ts +3 -3
- package/src/three/threeWorker.ts +2 -2
- package/src/three/waypointSprite.ts +55 -82
- package/src/three/waypoints.ts +20 -23
- package/src/three/world/cursorBlock.ts +25 -12
- package/src/three/world/vr.ts +11 -17
- package/src/three/worldGeometryExport.ts +15 -34
- package/src/three/worldRendererThree.ts +117 -129
- package/src/wasm-mesher/bridge/convertChunk.ts +3 -9
- package/src/wasm-mesher/bridge/render-from-wasm.ts +204 -229
- package/src/wasm-mesher/bridge/shaderCubeBridge.ts +26 -67
- package/src/wasm-mesher/tests/cullingRegression.test.ts +307 -0
- package/src/wasm-mesher/tests/heightmapParity.test.ts +8 -18
- package/src/wasm-mesher/tests/mesherWasmConversionCache.test.ts +2 -2
- package/src/wasm-mesher/tests/sectionRaycastAabb.test.ts +17 -4
- package/src/wasm-mesher/tests/shaderCubeInstances.test.ts +103 -141
- package/src/wasm-mesher/tests/splitColumnWasmOutput.test.ts +14 -22
- package/src/wasm-mesher/worker/mesherWasm.ts +150 -141
- package/src/wasm-mesher/worker/mesherWasmConversionCache.ts +2 -8
- package/src/wasm-mesher/worker/mesherWasmLightDirty.test.ts +1 -3
- package/src/wasm-mesher/worker/mesherWasmLightDirty.ts +1 -5
- package/src/wasm-mesher/worker/mesherWasmRequestTracker.ts +42 -42
- package/src/worldView/worldView.spiral.test.ts +1 -1
- package/src/worldView/worldView.ts +34 -39
- package/src/worldView/worldViewWorkerBridge.test.ts +4 -4
|
@@ -46,8 +46,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
46
46
|
private static readonly LEGACY_TO_PHYSICAL_LIGHT = Math.PI
|
|
47
47
|
|
|
48
48
|
protected override isShaderCubeBlocksEnabled(): boolean {
|
|
49
|
-
return this.worldRendererConfig.shaderCubeBlocks === true
|
|
50
|
-
&& !!this.renderer?.capabilities?.isWebGL2
|
|
49
|
+
return this.worldRendererConfig.shaderCubeBlocks === true && !!this.renderer?.capabilities?.isWebGL2
|
|
51
50
|
}
|
|
52
51
|
chunkMeshManager: ChunkMeshManager
|
|
53
52
|
get sectionObjects() {
|
|
@@ -92,7 +91,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
92
91
|
*/
|
|
93
92
|
camera!: THREE.PerspectiveCamera
|
|
94
93
|
renderTimeAvg = 0
|
|
95
|
-
private pendingSectionUpdates = new Map<string, { geometry: MesherGeometryOutput
|
|
94
|
+
private pendingSectionUpdates = new Map<string, { geometry: MesherGeometryOutput; key: string; type: string }>()
|
|
96
95
|
/**
|
|
97
96
|
* Per-section buffering timestamps for `applyPendingSectionUpdates`.
|
|
98
97
|
* Each section gets its own deadline so a continuous stream of updates
|
|
@@ -110,19 +109,19 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
110
109
|
private modules = {} as Record<string, RegisteredModule>
|
|
111
110
|
sectionsOffsetsAnimations = {} as {
|
|
112
111
|
[chunkKey: string]: {
|
|
113
|
-
time: number
|
|
112
|
+
time: number
|
|
114
113
|
// also specifies direction
|
|
115
|
-
speedX: number
|
|
116
|
-
speedY: number
|
|
117
|
-
speedZ: number
|
|
114
|
+
speedX: number
|
|
115
|
+
speedY: number
|
|
116
|
+
speedZ: number
|
|
118
117
|
|
|
119
|
-
currentOffsetX: number
|
|
120
|
-
currentOffsetY: number
|
|
121
|
-
currentOffsetZ: number
|
|
118
|
+
currentOffsetX: number
|
|
119
|
+
currentOffsetY: number
|
|
120
|
+
currentOffsetZ: number
|
|
122
121
|
|
|
123
|
-
limitX?: number
|
|
124
|
-
limitY?: number
|
|
125
|
-
limitZ?: number
|
|
122
|
+
limitX?: number
|
|
123
|
+
limitY?: number
|
|
124
|
+
limitZ?: number
|
|
126
125
|
}
|
|
127
126
|
}
|
|
128
127
|
fountains: Fountain[] = []
|
|
@@ -139,8 +138,8 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
139
138
|
|
|
140
139
|
private readonly _tmpCameraPos = new THREE.Vector3()
|
|
141
140
|
|
|
142
|
-
private currentPosTween?: tweenJs.Tween<{ x: number
|
|
143
|
-
private currentRotTween?: tweenJs.Tween<{ pitch: number
|
|
141
|
+
private currentPosTween?: tweenJs.Tween<{ x: number; y: number; z: number }>
|
|
142
|
+
private currentRotTween?: tweenJs.Tween<{ pitch: number; yaw: number }>
|
|
144
143
|
|
|
145
144
|
// Pre-allocated objects for getThirdPersonCamera (avoid per-frame allocs)
|
|
146
145
|
private readonly _tpDirection = new THREE.Vector3()
|
|
@@ -161,7 +160,11 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
161
160
|
return this.chunkMeshManager.getTotalBlocks()
|
|
162
161
|
}
|
|
163
162
|
|
|
164
|
-
constructor(
|
|
163
|
+
constructor(
|
|
164
|
+
public renderer: THREE.WebGLRenderer,
|
|
165
|
+
public initOptions: GraphicsInitOptions,
|
|
166
|
+
public displayOptions: DisplayWorldOptions
|
|
167
|
+
) {
|
|
165
168
|
if (!displayOptions.resourcesManager) throw new Error('resourcesManager is required in displayOptions')
|
|
166
169
|
super(displayOptions.resourcesManager, displayOptions, initOptions)
|
|
167
170
|
|
|
@@ -173,13 +176,13 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
173
176
|
|
|
174
177
|
// Initialize chunk mesh manager
|
|
175
178
|
this.chunkMeshManager = new ChunkMeshManager(this, this.scene, this.material, this.worldSizeParams.worldHeight, this.viewDistance)
|
|
176
|
-
this.onRenderDistanceChanged =
|
|
179
|
+
this.onRenderDistanceChanged = viewDistance => {
|
|
177
180
|
this.chunkMeshManager.updateViewDistance(viewDistance)
|
|
178
181
|
}
|
|
179
182
|
|
|
180
183
|
// Final lightmap values TBD — compare against https://v99.mcraft.fun/
|
|
181
184
|
if (typeof window !== 'undefined') {
|
|
182
|
-
(window as any).setBlockLightmap = (params: { curve?: number
|
|
185
|
+
;(window as any).setBlockLightmap = (params: { curve?: number; minBrightness?: number; gamma?: number }) => {
|
|
183
186
|
this.chunkMeshManager.setBlockLightmapParams(params)
|
|
184
187
|
}
|
|
185
188
|
}
|
|
@@ -211,7 +214,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
211
214
|
this.cinimaticScript = new CinimaticScriptRunner(
|
|
212
215
|
this,
|
|
213
216
|
(pos, yaw, pitch) => this.setCinimaticCamera(pos, yaw, pitch),
|
|
214
|
-
|
|
217
|
+
fov => this.setCinimaticFov(fov),
|
|
215
218
|
() => ({
|
|
216
219
|
position: new Vec3(this.cameraWorldPos.x, this.cameraWorldPos.y, this.cameraWorldPos.z),
|
|
217
220
|
yaw: this.cameraShake.getBaseRotation().yaw,
|
|
@@ -249,7 +252,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
249
252
|
manifest,
|
|
250
253
|
controller,
|
|
251
254
|
enabled: false,
|
|
252
|
-
toggle: () => this.toggleModule(manifest.id)
|
|
255
|
+
toggle: () => this.toggleModule(manifest.id)
|
|
253
256
|
}
|
|
254
257
|
|
|
255
258
|
this.modules[manifest.id] = registered
|
|
@@ -259,7 +262,6 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
259
262
|
}
|
|
260
263
|
}
|
|
261
264
|
|
|
262
|
-
|
|
263
265
|
/**
|
|
264
266
|
* Enable a module
|
|
265
267
|
*/
|
|
@@ -406,7 +408,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
406
408
|
self._cameraPositionAccessWarned = true
|
|
407
409
|
console.warn(
|
|
408
410
|
'[WorldRendererThree] Do not set camera.position to world coordinates — it is scene-local. ' +
|
|
409
|
-
|
|
411
|
+
'Use cameraWorldPos and sceneOrigin.update() to move the camera.'
|
|
410
412
|
)
|
|
411
413
|
}
|
|
412
414
|
}
|
|
@@ -415,7 +417,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
415
417
|
if ((prop === 'x' || prop === 'y' || prop === 'z') && typeof value === 'number' && Math.abs(value) > WORLD_COORD_THRESHOLD) {
|
|
416
418
|
warnOnce()
|
|
417
419
|
}
|
|
418
|
-
;
|
|
420
|
+
;(target as any)[prop] = value
|
|
419
421
|
return true
|
|
420
422
|
},
|
|
421
423
|
get(target, prop, receiver) {
|
|
@@ -462,7 +464,12 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
462
464
|
}
|
|
463
465
|
|
|
464
466
|
downloadWorldGeometry() {
|
|
465
|
-
downloadWorldGeometry(
|
|
467
|
+
downloadWorldGeometry(
|
|
468
|
+
this,
|
|
469
|
+
new THREE.Vector3(this.cameraWorldPos.x, this.cameraWorldPos.y, this.cameraWorldPos.z),
|
|
470
|
+
this.cameraShake.getBaseRotation(),
|
|
471
|
+
'world-geometry.json'
|
|
472
|
+
)
|
|
466
473
|
}
|
|
467
474
|
|
|
468
475
|
updateEntity(e, isPosUpdate = false) {
|
|
@@ -509,27 +516,27 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
509
516
|
|
|
510
517
|
override watchReactivePlayerState() {
|
|
511
518
|
super.watchReactivePlayerState()
|
|
512
|
-
this.onReactivePlayerStateUpdated('inWater',
|
|
519
|
+
this.onReactivePlayerStateUpdated('inWater', value => {
|
|
513
520
|
this.skyboxRenderer.updateWaterState(value, this.playerStateReactive.waterBreathing)
|
|
514
521
|
})
|
|
515
|
-
this.onReactivePlayerStateUpdated('waterBreathing',
|
|
522
|
+
this.onReactivePlayerStateUpdated('waterBreathing', value => {
|
|
516
523
|
this.skyboxRenderer.updateWaterState(this.playerStateReactive.inWater, value)
|
|
517
524
|
})
|
|
518
|
-
this.onReactivePlayerStateUpdated('ambientLight',
|
|
525
|
+
this.onReactivePlayerStateUpdated('ambientLight', value => {
|
|
519
526
|
if (!value) return
|
|
520
527
|
this.ambientLight.intensity = value * WorldRendererThree.LEGACY_TO_PHYSICAL_LIGHT
|
|
521
528
|
})
|
|
522
|
-
this.onReactivePlayerStateUpdated('directionalLight',
|
|
529
|
+
this.onReactivePlayerStateUpdated('directionalLight', value => {
|
|
523
530
|
if (!value) return
|
|
524
531
|
this.directionalLight.intensity = value * WorldRendererThree.LEGACY_TO_PHYSICAL_LIGHT
|
|
525
532
|
})
|
|
526
|
-
this.onReactivePlayerStateUpdated('lookingAtBlock',
|
|
533
|
+
this.onReactivePlayerStateUpdated('lookingAtBlock', value => {
|
|
527
534
|
this.cursorBlock.setHighlightCursorBlock(value ? new Vec3(value.x, value.y, value.z) : null, value?.shapes)
|
|
528
535
|
})
|
|
529
|
-
this.onReactivePlayerStateUpdated('diggingBlock',
|
|
536
|
+
this.onReactivePlayerStateUpdated('diggingBlock', value => {
|
|
530
537
|
this.cursorBlock.updateBreakAnimation(value ? { x: value.x, y: value.y, z: value.z } : undefined, value?.stage ?? null, value?.mergedShape)
|
|
531
538
|
})
|
|
532
|
-
this.onReactivePlayerStateUpdated('perspective',
|
|
539
|
+
this.onReactivePlayerStateUpdated('perspective', value => {
|
|
533
540
|
// Update camera perspective when it changes
|
|
534
541
|
const vecPos = new Vec3(this.cameraWorldPos.x, this.cameraWorldPos.y, this.cameraWorldPos.z)
|
|
535
542
|
this.updateCamera(vecPos, this.cameraShake.getBaseRotation().yaw, this.cameraShake.getBaseRotation().pitch)
|
|
@@ -539,10 +546,10 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
539
546
|
|
|
540
547
|
override watchReactiveConfig() {
|
|
541
548
|
super.watchReactiveConfig()
|
|
542
|
-
this.onReactiveConfigUpdated('showChunkBorders',
|
|
549
|
+
this.onReactiveConfigUpdated('showChunkBorders', value => {
|
|
543
550
|
this.updateShowChunksBorder(value)
|
|
544
551
|
})
|
|
545
|
-
this.onReactiveConfigUpdated('defaultSkybox',
|
|
552
|
+
this.onReactiveConfigUpdated('defaultSkybox', value => {
|
|
546
553
|
this.skyboxRenderer.updateDefaultSkybox(value)
|
|
547
554
|
})
|
|
548
555
|
this.onReactiveConfigUpdated('shaderCubeDebugMode', () => {
|
|
@@ -560,7 +567,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
560
567
|
})
|
|
561
568
|
|
|
562
569
|
let currentHandRenderer = this.displayOptions.inWorldRenderingConfig.handRenderer
|
|
563
|
-
this.onReactiveConfigUpdated('handRenderer',
|
|
570
|
+
this.onReactiveConfigUpdated('handRenderer', value => {
|
|
564
571
|
if (value === currentHandRenderer) return
|
|
565
572
|
currentHandRenderer = value
|
|
566
573
|
const wasReady = this.holdingBlock.ready
|
|
@@ -742,9 +749,12 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
742
749
|
demoItem() {
|
|
743
750
|
//@ts-expect-error
|
|
744
751
|
const pos = cursorBlockRel(0, 1, 0).position
|
|
745
|
-
const { mesh } = this.entities.getItemMesh(
|
|
746
|
-
|
|
747
|
-
|
|
752
|
+
const { mesh } = this.entities.getItemMesh(
|
|
753
|
+
{
|
|
754
|
+
itemId: 541
|
|
755
|
+
},
|
|
756
|
+
{}
|
|
757
|
+
)!
|
|
748
758
|
mesh.position.set(pos.x + 0.5, pos.y + 0.5, pos.z + 0.5)
|
|
749
759
|
// mesh.scale.set(0.5, 0.5, 0.5)
|
|
750
760
|
const helper = new THREE.BoxHelper(mesh, 0xff_ff_00)
|
|
@@ -800,9 +810,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
800
810
|
const renderOrder = 500 - chunkDistance
|
|
801
811
|
|
|
802
812
|
// Cubes in globalBlockBuffer may leave sectionObj.mesh unset.
|
|
803
|
-
const drawable = sectionObj.mesh
|
|
804
|
-
?? sectionObj.shaderMesh
|
|
805
|
-
?? sectionObj.children.find(child => child.name === 'mesh' || child.name === 'shaderMesh')
|
|
813
|
+
const drawable = sectionObj.mesh ?? sectionObj.shaderMesh ?? sectionObj.children.find(child => child.name === 'mesh' || child.name === 'shaderMesh')
|
|
806
814
|
if (drawable) {
|
|
807
815
|
drawable.renderOrder = renderOrder
|
|
808
816
|
}
|
|
@@ -847,17 +855,16 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
847
855
|
// the just-updated section and a stale neighbor (sky-flicker bug).
|
|
848
856
|
const [sx, sy, sz] = key.split(',').map(Number)
|
|
849
857
|
const neighborKeys = [
|
|
850
|
-
`${sx - 16},${sy},${sz}`,
|
|
851
|
-
`${sx
|
|
852
|
-
`${sx},${sy
|
|
858
|
+
`${sx - 16},${sy},${sz}`,
|
|
859
|
+
`${sx + 16},${sy},${sz}`,
|
|
860
|
+
`${sx},${sy - sectionHeight},${sz}`,
|
|
861
|
+
`${sx},${sy + sectionHeight},${sz}`,
|
|
862
|
+
`${sx},${sy},${sz - 16}`,
|
|
863
|
+
`${sx},${sy},${sz + 16}`
|
|
853
864
|
]
|
|
854
865
|
let neighborBusy = false
|
|
855
866
|
for (const neighborKey of neighborKeys) {
|
|
856
|
-
if (
|
|
857
|
-
this.sectionsWaiting.has(neighborKey) &&
|
|
858
|
-
!this.pendingSectionUpdates.has(neighborKey) &&
|
|
859
|
-
this.sectionObjects[neighborKey]
|
|
860
|
-
) {
|
|
867
|
+
if (this.sectionsWaiting.has(neighborKey) && !this.pendingSectionUpdates.has(neighborKey) && this.sectionObjects[neighborKey]) {
|
|
861
868
|
neighborBusy = true
|
|
862
869
|
break
|
|
863
870
|
}
|
|
@@ -891,8 +898,9 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
891
898
|
const sectionObject = this.chunkMeshManager.updateSection(update.key, update.geometry)
|
|
892
899
|
this.updatePosDataChunk(update.key)
|
|
893
900
|
if (sectionObject) {
|
|
894
|
-
this.getModule<{ onSectionMeshed?: (key: string, geometry: MesherGeometryOutput, section: typeof sectionObject) => void }>(
|
|
895
|
-
|
|
901
|
+
this.getModule<{ onSectionMeshed?: (key: string, geometry: MesherGeometryOutput, section: typeof sectionObject) => void }>(
|
|
902
|
+
'futuristicReveal'
|
|
903
|
+
)?.onSectionMeshed?.(update.key, update.geometry, sectionObject)
|
|
896
904
|
}
|
|
897
905
|
}
|
|
898
906
|
}
|
|
@@ -906,7 +914,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
906
914
|
}
|
|
907
915
|
}
|
|
908
916
|
|
|
909
|
-
handleWorkerMessage(data: { geometry: MesherGeometryOutput
|
|
917
|
+
handleWorkerMessage(data: { geometry: MesherGeometryOutput; key; type }): void {
|
|
910
918
|
if (data.type === 'geometry') {
|
|
911
919
|
const chunkCoords = data.key.split(',')
|
|
912
920
|
const chunkKey = `${chunkCoords[0]},${chunkCoords[2]}`
|
|
@@ -933,24 +941,20 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
933
941
|
const sectionObject = this.chunkMeshManager.updateSection(data.key, data.geometry)
|
|
934
942
|
this.updatePosDataChunk(data.key)
|
|
935
943
|
if (sectionObject) {
|
|
936
|
-
this.getModule<{ onSectionMeshed?: (key: string, geometry: MesherGeometryOutput, section: typeof sectionObject) => void }>(
|
|
937
|
-
|
|
944
|
+
this.getModule<{ onSectionMeshed?: (key: string, geometry: MesherGeometryOutput, section: typeof sectionObject) => void }>(
|
|
945
|
+
'futuristicReveal'
|
|
946
|
+
)?.onSectionMeshed?.(data.key, data.geometry, sectionObject)
|
|
938
947
|
}
|
|
939
948
|
}
|
|
940
949
|
}
|
|
941
950
|
|
|
942
|
-
|
|
943
951
|
getCameraPosition(target?: THREE.Vector3): THREE.Vector3 {
|
|
944
952
|
return (target ?? this._tmpCameraPos).set(this.cameraWorldPos.x, this.cameraWorldPos.y, this.cameraWorldPos.z)
|
|
945
953
|
}
|
|
946
954
|
|
|
947
955
|
getSectionCameraPosition() {
|
|
948
956
|
const pos = this.getCameraPosition()
|
|
949
|
-
return new Vec3(
|
|
950
|
-
Math.floor(pos.x / 16),
|
|
951
|
-
Math.floor(pos.y / 16),
|
|
952
|
-
Math.floor(pos.z / 16)
|
|
953
|
-
)
|
|
957
|
+
return new Vec3(Math.floor(pos.x / 16), Math.floor(pos.y / 16), Math.floor(pos.z / 16))
|
|
954
958
|
}
|
|
955
959
|
|
|
956
960
|
updateCameraSectionPos() {
|
|
@@ -1033,30 +1037,17 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
1033
1037
|
}
|
|
1034
1038
|
|
|
1035
1039
|
// Shader cubes in global buffer: tight per-section AABBs (no mesh raycast).
|
|
1036
|
-
const boxHit = this.chunkMeshManager.raycastShaderSectionAABBs(
|
|
1037
|
-
pos,
|
|
1038
|
-
direction,
|
|
1039
|
-
finalDistance,
|
|
1040
|
-
maxCenterDistance,
|
|
1041
|
-
)
|
|
1040
|
+
const boxHit = this.chunkMeshManager.raycastShaderSectionAABBs(pos, direction, finalDistance, maxCenterDistance)
|
|
1042
1041
|
if (boxHit !== undefined) {
|
|
1043
1042
|
finalDistance = Math.max(0.5, boxHit - 0.2)
|
|
1044
1043
|
}
|
|
1045
1044
|
|
|
1046
|
-
const legacyGlobalHit = this.chunkMeshManager.raycastGlobalLegacySections(
|
|
1047
|
-
raycaster,
|
|
1048
|
-
pos,
|
|
1049
|
-
maxCenterDistance,
|
|
1050
|
-
)
|
|
1045
|
+
const legacyGlobalHit = this.chunkMeshManager.raycastGlobalLegacySections(raycaster, pos, maxCenterDistance)
|
|
1051
1046
|
if (legacyGlobalHit !== undefined) {
|
|
1052
1047
|
finalDistance = Math.max(0.5, legacyGlobalHit - 0.2)
|
|
1053
1048
|
}
|
|
1054
1049
|
|
|
1055
|
-
const finalPos = new Vec3(
|
|
1056
|
-
pos.x + direction.x * finalDistance,
|
|
1057
|
-
pos.y + direction.y * finalDistance,
|
|
1058
|
-
pos.z + direction.z * finalDistance
|
|
1059
|
-
)
|
|
1050
|
+
const finalPos = new Vec3(pos.x + direction.x * finalDistance, pos.y + direction.y * finalDistance, pos.z + direction.z * finalDistance)
|
|
1060
1051
|
|
|
1061
1052
|
return finalPos
|
|
1062
1053
|
}
|
|
@@ -1076,11 +1067,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
1076
1067
|
}
|
|
1077
1068
|
|
|
1078
1069
|
// Convert world position to scene-relative coordinates
|
|
1079
|
-
const scenePos = new THREE.Vector3(
|
|
1080
|
-
this.sceneOrigin.toSceneX(pos.x),
|
|
1081
|
-
this.sceneOrigin.toSceneY(pos.y),
|
|
1082
|
-
this.sceneOrigin.toSceneZ(pos.z)
|
|
1083
|
-
)
|
|
1070
|
+
const scenePos = new THREE.Vector3(this.sceneOrigin.toSceneX(pos.x), this.sceneOrigin.toSceneY(pos.y), this.sceneOrigin.toSceneZ(pos.z))
|
|
1084
1071
|
|
|
1085
1072
|
// Create raycast arrow
|
|
1086
1073
|
this.debugRaycastHelper = new THREE.ArrowHelper(
|
|
@@ -1170,9 +1157,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
1170
1157
|
|
|
1171
1158
|
this.currentPosTween?.stop()
|
|
1172
1159
|
// Use instant camera updates (0 delay) in playground mode when camera controls are enabled
|
|
1173
|
-
const tweenDelay = this.displayOptions.inWorldRenderingConfig.instantCameraUpdate
|
|
1174
|
-
? 0
|
|
1175
|
-
: (this.playerStateUtils.isSpectatingEntity() ? 150 : 50)
|
|
1160
|
+
const tweenDelay = this.displayOptions.inWorldRenderingConfig.instantCameraUpdate ? 0 : this.playerStateUtils.isSpectatingEntity() ? 150 : 50
|
|
1176
1161
|
this.currentPosTween = new tweenJs.Tween(this.cameraWorldPos)
|
|
1177
1162
|
.to({ x: pos.x, y: pos.y, z: pos.z }, tweenDelay)
|
|
1178
1163
|
.onUpdate(() => {
|
|
@@ -1194,8 +1179,10 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
1194
1179
|
yawOffset = Math.PI * 2
|
|
1195
1180
|
}
|
|
1196
1181
|
this.currentRotTween?.stop()
|
|
1197
|
-
this.currentRotTween = new tweenJs.Tween(rotation)
|
|
1198
|
-
.
|
|
1182
|
+
this.currentRotTween = new tweenJs.Tween(rotation)
|
|
1183
|
+
.to({ pitch, yaw: yaw + yawOffset }, 100)
|
|
1184
|
+
.onUpdate(params => this.cameraShake.setBaseRotation(params.pitch, params.yaw - yawOffset))
|
|
1185
|
+
.start()
|
|
1199
1186
|
} else {
|
|
1200
1187
|
this.currentRotTween?.stop()
|
|
1201
1188
|
this.cameraShake.setBaseRotation(pitch, yaw)
|
|
@@ -1204,11 +1191,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
1204
1191
|
if (perspective === 'third_person_back' || perspective === 'third_person_front') {
|
|
1205
1192
|
// Use getThirdPersonCamera for proper raycasting with max distance of 4
|
|
1206
1193
|
const currentWorldPos = new THREE.Vector3(this.cameraWorldPos.x, this.cameraWorldPos.y, this.cameraWorldPos.z)
|
|
1207
|
-
const thirdPersonPos = this.getThirdPersonCamera(
|
|
1208
|
-
currentWorldPos,
|
|
1209
|
-
yaw,
|
|
1210
|
-
pitch
|
|
1211
|
-
)
|
|
1194
|
+
const thirdPersonPos = this.getThirdPersonCamera(currentWorldPos, yaw, pitch)
|
|
1212
1195
|
|
|
1213
1196
|
const distance = currentWorldPos.distanceTo(new THREE.Vector3(thirdPersonPos.x, thirdPersonPos.y, thirdPersonPos.z))
|
|
1214
1197
|
// Apply Z offset based on perspective and calculated distance
|
|
@@ -1242,14 +1225,20 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
1242
1225
|
}
|
|
1243
1226
|
|
|
1244
1227
|
debugChunksVisibilityOverride() {
|
|
1245
|
-
const {
|
|
1228
|
+
const {
|
|
1229
|
+
chunksRenderAboveOverride,
|
|
1230
|
+
chunksRenderBelowOverride,
|
|
1231
|
+
chunksRenderDistanceOverride,
|
|
1232
|
+
chunksRenderAboveEnabled,
|
|
1233
|
+
chunksRenderBelowEnabled,
|
|
1234
|
+
chunksRenderDistanceEnabled
|
|
1235
|
+
} = this.reactiveDebugParams
|
|
1246
1236
|
|
|
1247
1237
|
const sectionHeight = this.getSectionHeight()
|
|
1248
1238
|
const baseY = this.cameraSectionPos.y * sectionHeight
|
|
1249
1239
|
|
|
1250
1240
|
if (
|
|
1251
|
-
this.displayOptions.inWorldRenderingConfig.enableDebugOverlay &&
|
|
1252
|
-
chunksRenderAboveOverride !== undefined ||
|
|
1241
|
+
(this.displayOptions.inWorldRenderingConfig.enableDebugOverlay && chunksRenderAboveOverride !== undefined) ||
|
|
1253
1242
|
chunksRenderBelowOverride !== undefined ||
|
|
1254
1243
|
chunksRenderDistanceOverride !== undefined
|
|
1255
1244
|
) {
|
|
@@ -1258,11 +1247,19 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
1258
1247
|
const [x, y, z] = key.split(',').map(Number)
|
|
1259
1248
|
const isVisible =
|
|
1260
1249
|
// eslint-disable-next-line no-constant-binary-expression, sonarjs/no-redundant-boolean
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1250
|
+
chunksRenderAboveEnabled && chunksRenderAboveOverride !== undefined
|
|
1251
|
+
? y <= baseY + chunksRenderAboveOverride
|
|
1252
|
+
: true &&
|
|
1253
|
+
// eslint-disable-next-line @stylistic/indent-binary-ops, no-constant-binary-expression, sonarjs/no-redundant-boolean
|
|
1254
|
+
chunksRenderBelowEnabled &&
|
|
1255
|
+
chunksRenderBelowOverride !== undefined
|
|
1256
|
+
? y >= baseY - chunksRenderBelowOverride
|
|
1257
|
+
: true &&
|
|
1258
|
+
// eslint-disable-next-line @stylistic/indent-binary-ops
|
|
1259
|
+
chunksRenderDistanceEnabled &&
|
|
1260
|
+
chunksRenderDistanceOverride !== undefined
|
|
1261
|
+
? Math.abs(y - baseY) <= chunksRenderDistanceOverride
|
|
1262
|
+
: true
|
|
1266
1263
|
|
|
1267
1264
|
object.visible = isVisible
|
|
1268
1265
|
}
|
|
@@ -1281,9 +1278,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
1281
1278
|
this.debugChunksVisibilityOverride()
|
|
1282
1279
|
const start = performance.now()
|
|
1283
1280
|
this.lastRendered = performance.now()
|
|
1284
|
-
const deltaTime = this.lastRenderTime > 0
|
|
1285
|
-
? Math.min(Math.max((start - this.lastRenderTime) / 1000, 0), 0.1)
|
|
1286
|
-
: 1 / 60
|
|
1281
|
+
const deltaTime = this.lastRenderTime > 0 ? Math.min(Math.max((start - this.lastRenderTime) / 1000, 0), 0.1) : 1 / 60
|
|
1287
1282
|
this.lastRenderTime = start
|
|
1288
1283
|
this.cursorBlock.render()
|
|
1289
1284
|
this.updateSectionOffsets()
|
|
@@ -1307,7 +1302,10 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
1307
1302
|
}
|
|
1308
1303
|
|
|
1309
1304
|
// eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style
|
|
1310
|
-
const cam =
|
|
1305
|
+
const cam =
|
|
1306
|
+
this.cameraGroupVr instanceof THREE.Group
|
|
1307
|
+
? (this.cameraGroupVr.children.find(child => child instanceof THREE.PerspectiveCamera) as THREE.PerspectiveCamera)
|
|
1308
|
+
: this.camera
|
|
1311
1309
|
// Flush buffered section geometry before reveal tick (calls onSectionMeshed synchronously in handleWorkerMessage).
|
|
1312
1310
|
this.applyPendingSectionUpdates()
|
|
1313
1311
|
const sciFiNow = performance.now()
|
|
@@ -1347,15 +1345,11 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
1347
1345
|
}
|
|
1348
1346
|
globalLegacyBlendBuffer.suppressThreeDraw()
|
|
1349
1347
|
}
|
|
1348
|
+
this.chunkMeshManager.markCullDirtyIfBufferStateChanged()
|
|
1350
1349
|
this.chunkMeshManager.setLegacyCameraOrigin(camX, camY, camZ)
|
|
1351
1350
|
this.chunkMeshManager.updateCullDirtyFromCamera(cam, camX, camY, camZ)
|
|
1352
1351
|
if (this.chunkMeshManager.cullDirty) {
|
|
1353
|
-
this.chunkMeshManager.updateSectionCullAndSort(
|
|
1354
|
-
cam,
|
|
1355
|
-
this.cameraWorldPos.x,
|
|
1356
|
-
this.cameraWorldPos.y,
|
|
1357
|
-
this.cameraWorldPos.z,
|
|
1358
|
-
)
|
|
1352
|
+
this.chunkMeshManager.updateSectionCullAndSort(cam, this.cameraWorldPos.x, this.cameraWorldPos.y, this.cameraWorldPos.z)
|
|
1359
1353
|
this.chunkMeshManager.clearCullDirty()
|
|
1360
1354
|
}
|
|
1361
1355
|
this.renderer.render(this.scene, cam)
|
|
@@ -1391,14 +1385,14 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
1391
1385
|
this.chunkMeshManager.recordRenderTime(totalTime)
|
|
1392
1386
|
}
|
|
1393
1387
|
this.renderTimeAvgCount++
|
|
1394
|
-
this.renderTimeAvg = (
|
|
1388
|
+
this.renderTimeAvg = (this.renderTimeAvg * (this.renderTimeAvgCount - 1) + totalTime) / this.renderTimeAvgCount
|
|
1395
1389
|
this.renderTimeMax = Math.max(this.renderTimeMax, totalTime)
|
|
1396
1390
|
|
|
1397
1391
|
this.performanceMonitor.onFrame({
|
|
1398
1392
|
totalMs: totalTime,
|
|
1399
1393
|
entitiesMs: entitiesRenderMs,
|
|
1400
1394
|
loadedTextureCount: this.renderer.info.memory.textures,
|
|
1401
|
-
fps: this.lastFps
|
|
1395
|
+
fps: this.lastFps
|
|
1402
1396
|
})
|
|
1403
1397
|
}
|
|
1404
1398
|
|
|
@@ -1416,8 +1410,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
1416
1410
|
let skinUrl = decodedData.textures?.SKIN?.url
|
|
1417
1411
|
const { skinTexturesProxy } = this.worldRendererConfig
|
|
1418
1412
|
if (skinTexturesProxy) {
|
|
1419
|
-
skinUrl = skinUrl?.replace('http://textures.minecraft.net/', skinTexturesProxy)
|
|
1420
|
-
.replace('https://textures.minecraft.net/', skinTexturesProxy)
|
|
1413
|
+
skinUrl = skinUrl?.replace('http://textures.minecraft.net/', skinTexturesProxy).replace('https://textures.minecraft.net/', skinTexturesProxy)
|
|
1421
1414
|
}
|
|
1422
1415
|
|
|
1423
1416
|
const mesh = getMesh(this, skinUrl, armorModel.head as any)
|
|
@@ -1430,11 +1423,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
1430
1423
|
group.add(mesh)
|
|
1431
1424
|
this.sceneOrigin.track(group)
|
|
1432
1425
|
group.position.set(position.x + 0.5, position.y + 0.045, position.z + 0.5)
|
|
1433
|
-
group.rotation.set(
|
|
1434
|
-
0,
|
|
1435
|
-
-THREE.MathUtils.degToRad(rotation * (isWall ? 90 : 45 / 2)),
|
|
1436
|
-
0
|
|
1437
|
-
)
|
|
1426
|
+
group.rotation.set(0, -THREE.MathUtils.degToRad(rotation * (isWall ? 90 : 45 / 2)), 0)
|
|
1438
1427
|
group.scale.set(0.8, 0.8, 0.8)
|
|
1439
1428
|
return group
|
|
1440
1429
|
} catch (err) {
|
|
@@ -1449,7 +1438,8 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
1449
1438
|
}
|
|
1450
1439
|
}
|
|
1451
1440
|
|
|
1452
|
-
rerenderAllChunks() {
|
|
1441
|
+
rerenderAllChunks() {
|
|
1442
|
+
// todo not clear what to do with loading chunks
|
|
1453
1443
|
for (const key of Object.keys(this.sectionObjects)) {
|
|
1454
1444
|
const [x, y, z] = key.split(',').map(Number)
|
|
1455
1445
|
this.setSectionDirty(new Vec3(x, y, z))
|
|
@@ -1483,12 +1473,14 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
1483
1473
|
|
|
1484
1474
|
getLoadedChunksRelative(pos: Vec3, includeY = false) {
|
|
1485
1475
|
const [currentX, currentY, currentZ] = sectionPos(pos)
|
|
1486
|
-
return Object.fromEntries(
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1476
|
+
return Object.fromEntries(
|
|
1477
|
+
Object.entries(this.sectionObjects).map(([key, o]) => {
|
|
1478
|
+
const [xRaw, yRaw, zRaw] = key.split(',').map(Number)
|
|
1479
|
+
const [x, y, z] = sectionPos({ x: xRaw, y: yRaw, z: zRaw })
|
|
1480
|
+
const setKey = includeY ? `${x - currentX},${y - currentY},${z - currentZ}` : `${x - currentX},${z - currentZ}`
|
|
1481
|
+
return [setKey, o]
|
|
1482
|
+
})
|
|
1483
|
+
)
|
|
1492
1484
|
}
|
|
1493
1485
|
|
|
1494
1486
|
readdChunks() {
|
|
@@ -1633,11 +1625,7 @@ export class WorldRendererThree extends WorldRendererCommon {
|
|
|
1633
1625
|
// Apply the offset to the section object (compose with camera-relative base position)
|
|
1634
1626
|
const section = this.sectionObjects[key]
|
|
1635
1627
|
if (section) {
|
|
1636
|
-
section.position.set(
|
|
1637
|
-
anim.currentOffsetX,
|
|
1638
|
-
anim.currentOffsetY,
|
|
1639
|
-
anim.currentOffsetZ
|
|
1640
|
-
)
|
|
1628
|
+
section.position.set(anim.currentOffsetX, anim.currentOffsetY, anim.currentOffsetZ)
|
|
1641
1629
|
section.updateMatrix()
|
|
1642
1630
|
}
|
|
1643
1631
|
}
|
|
@@ -14,7 +14,7 @@ type BlockMeta = {
|
|
|
14
14
|
|
|
15
15
|
const metaCache = new Map<string, BlockMeta>()
|
|
16
16
|
|
|
17
|
-
const blockToIds = (block: { minStateId: number
|
|
17
|
+
const blockToIds = (block: { minStateId: number; maxStateId: number }) => {
|
|
18
18
|
const ids: number[] = []
|
|
19
19
|
for (let i = block.minStateId; i <= block.maxStateId; i++) {
|
|
20
20
|
ids.push(i)
|
|
@@ -169,13 +169,7 @@ export function convertChunkToWasm(
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
const {
|
|
173
|
-
invisibleBlocks,
|
|
174
|
-
transparentBlocks,
|
|
175
|
-
noAoBlocks,
|
|
176
|
-
cullIdenticalBlocks,
|
|
177
|
-
occludingBlocks
|
|
178
|
-
} = getBlockMeta(version)
|
|
172
|
+
const { invisibleBlocks, transparentBlocks, noAoBlocks, cullIdenticalBlocks, occludingBlocks } = getBlockMeta(version)
|
|
179
173
|
|
|
180
174
|
return {
|
|
181
175
|
blockStates,
|
|
@@ -187,6 +181,6 @@ export function convertChunkToWasm(
|
|
|
187
181
|
noAoBlocks,
|
|
188
182
|
cullIdenticalBlocks,
|
|
189
183
|
occludingBlocks,
|
|
190
|
-
blockCount
|
|
184
|
+
blockCount
|
|
191
185
|
}
|
|
192
186
|
}
|