minecraft-renderer 0.1.79 → 0.1.81
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 +66 -26
- package/dist/mesher.js +36 -36
- package/dist/mesher.js.map +4 -4
- package/dist/mesherWasm.js +217 -217
- package/dist/minecraft-renderer.js +66 -66
- package/dist/minecraft-renderer.js.meta.json +1 -1
- package/dist/threeWorker.js +450 -450
- 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 +349 -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/cameraCollisionBlockCache.ts +156 -0
- package/src/three/cameraCollisionSolidity.ts +50 -0
- package/src/three/cameraShake.ts +15 -6
- package/src/three/chunkMeshManager.ts +223 -390
- 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 +248 -264
- 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 +24 -110
- 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 -64
- 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/thirdPersonVoxelRaycast.ts +120 -0
- 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 +144 -166
- 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/cameraCollisionBlockCache.test.ts +82 -0
- 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 +1 -93
- package/src/wasm-mesher/tests/shaderCubeInstances.test.ts +103 -141
- package/src/wasm-mesher/tests/splitColumnWasmOutput.test.ts +14 -22
- package/src/wasm-mesher/tests/thirdPersonVoxelRaycast.test.ts +63 -0
- 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
package/README.md
CHANGED
|
@@ -2,7 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
One of the best Minecraft world rendererers implemented from scratch. Uses Three.js WebGL 2 backend. Designed for performance testing, experimentation, and integration into Minecraft clients or other use cases for game world display.
|
|
6
|
+
|
|
7
|
+
Features:
|
|
8
|
+
|
|
9
|
+
- 💡 Full-featured: hand, third-person view, entities, debug features and even more!
|
|
10
|
+
- ⚡️ Leverages all available WebGL 2 and WASM world meshing for the maximum performance
|
|
11
|
+
- 📦 Implemented from scratch; small bundle size and runtime footprint
|
|
12
|
+
- ⚙️ Easily customizable: modular architecture with Three.js API
|
|
13
|
+
|
|
14
|
+
## Implemented Features
|
|
15
|
+
|
|
16
|
+
- WASM mesher workers (default path) with legacy JS mesher fallback
|
|
17
|
+
- Instanced shader-cube rendering for full blocks (`GlobalBlockBuffer`, one GPU draw)
|
|
18
|
+
- Global legacy geometry buffer for models/stairs/slabs (merged indexed mesh, opaque + blend passes)
|
|
19
|
+
- Block and sky lighting, smooth lighting, and vanilla vs high-contrast (default) face shading (`vanillaLook`)
|
|
20
|
+
- Signs, banners, skulls, and other block-entity overlays
|
|
21
|
+
- Entities: players with skins & animations, mobs, items, armor, text/item display
|
|
22
|
+
- Day cycle, skybox, starfield, rain, fireworks
|
|
23
|
+
- Third-person camera, view bobbing, holding block / hand
|
|
24
|
+
- Optional off-thread graphics backend (render in a worker!)
|
|
25
|
+
- Smooth lighting (lighting data has to be provided)
|
|
26
|
+
|
|
27
|
+
### Browser support
|
|
28
|
+
|
|
29
|
+
**Requires WebGL 2.0.** WebGL 1 is not supported as a full-feature path (shader cubes and several block shaders need WebGL2).
|
|
30
|
+
|
|
31
|
+
| Browser | Minimum version |
|
|
32
|
+
| -------------------- | --------------- |
|
|
33
|
+
| Chrome / Chromium | 56+ |
|
|
34
|
+
| Firefox | 51+ |
|
|
35
|
+
| Edge | 79+ (Chromium) |
|
|
36
|
+
| Safari (macOS / iOS) | 15.3+ |
|
|
37
|
+
| Opera | 43+ |
|
|
38
|
+
|
|
39
|
+
**Not supported:** Safari before 15.
|
|
40
|
+
|
|
41
|
+
Optional extensions (`WEBGL_multi_draw`, instanced base vertex) improve draw-call batching when present; the renderer falls back to capped multi-draw loops when they are missing.
|
|
6
42
|
|
|
7
43
|
## Architecture Overview
|
|
8
44
|
|
|
@@ -96,12 +132,12 @@ Renderer-owned options live in `RENDERER_DEFAULT_OPTIONS` and `RENDERER_OPTIONS_
|
|
|
96
132
|
This updates `inWorldRenderingConfig`, `appViewer.config` (FPS/stats), and live menu-background controls when `currentDisplay === 'menu'`.
|
|
97
133
|
6. **App-only** — keep `volume` and bot/world hooks in the client (`applyRendererEnableLighting`, `applyRendererWorldViewOptions`, weather).
|
|
98
134
|
|
|
99
|
-
| Change
|
|
100
|
-
|
|
101
|
-
| Menu V2 scene / camera / speeds
|
|
102
|
-
| `rendererMesher` (`wasm` / `legacy-js`) | Yes — recreates mesher workers
|
|
103
|
-
| `rendererWorldPerformance`
|
|
104
|
-
| Volume
|
|
135
|
+
| Change | Live update | Reload required |
|
|
136
|
+
| --------------------------------------- | --------------------------------- | -------------------------------------- |
|
|
137
|
+
| Menu V2 scene / camera / speeds | Yes (`backend.getMenuBackground`) | Mode switch needs restart |
|
|
138
|
+
| `rendererMesher` (`wasm` / `legacy-js`) | Yes — recreates mesher workers | Chunks reload (`requiresChunksReload`) |
|
|
139
|
+
| `rendererWorldPerformance` | Yes — recreates mesher workers | Chunks reload (`requiresChunksReload`) |
|
|
140
|
+
| Volume | App `watchValue` only | No |
|
|
105
141
|
|
|
106
142
|
Sync runs on the **main thread** only; `inWorldRenderingConfig` uses existing valtio `__syncToWorker` for off-thread backends. Do not call `subscribeRendererOptions` from mesher workers.
|
|
107
143
|
|
|
@@ -122,11 +158,13 @@ World Provider → WorldView → GraphicsBackend → Mesher Workers → Three.js
|
|
|
122
158
|
### 2. Mesher Worker Communication
|
|
123
159
|
|
|
124
160
|
Workers receive:
|
|
161
|
+
|
|
125
162
|
- Block data (chunk JSON with block state IDs)
|
|
126
163
|
- Block models and textures atlas
|
|
127
164
|
- Lighting configuration
|
|
128
165
|
|
|
129
166
|
Workers produce:
|
|
167
|
+
|
|
130
168
|
- Float32Array of vertex positions (x, y, z per vertex)
|
|
131
169
|
- Float32Array of normals
|
|
132
170
|
- Float32Array of colors (vertex colors for lighting)
|
|
@@ -139,13 +177,15 @@ Each block face is a quad with 4 vertices and 6 indices:
|
|
|
139
177
|
|
|
140
178
|
```typescript
|
|
141
179
|
interface MesherGeometryOutput {
|
|
142
|
-
positions: Float32Array
|
|
143
|
-
normals: Float32Array
|
|
144
|
-
colors: Float32Array
|
|
145
|
-
uvs: Float32Array
|
|
146
|
-
indices: Uint32Array
|
|
147
|
-
sx
|
|
148
|
-
|
|
180
|
+
positions: Float32Array // [x1,y1,z1, x2,y2,z2, ...]
|
|
181
|
+
normals: Float32Array // [nx,ny,nz, ...]
|
|
182
|
+
colors: Float32Array // [r,g,b, r,g,b, ...] (0-1 range, lighting)
|
|
183
|
+
uvs: Float32Array // [u1,v1, u2,v2, ...] (texture atlas coords)
|
|
184
|
+
indices: Uint32Array // [0,1,2, 2,3,0, ...] (triangles)
|
|
185
|
+
sx
|
|
186
|
+
sy
|
|
187
|
+
sz: number // Section position offset
|
|
188
|
+
blocksCount: number // Number of non-air blocks
|
|
149
189
|
signs: Record<string, SignData>
|
|
150
190
|
banners: Record<string, BannerData>
|
|
151
191
|
heads: Record<string, HeadData>
|
|
@@ -194,21 +234,21 @@ Smooth lighting uses ambient occlusion based on neighboring blocks:
|
|
|
194
234
|
```typescript
|
|
195
235
|
interface WorldRendererConfig {
|
|
196
236
|
// Performance
|
|
197
|
-
mesherWorkers: number
|
|
198
|
-
addChunksBatchWaitTime: number
|
|
237
|
+
mesherWorkers: number // Number of worker threads (default: 4)
|
|
238
|
+
addChunksBatchWaitTime: number // Batch delay for chunk loading (ms)
|
|
199
239
|
_experimentalSmoothChunkLoading: boolean
|
|
200
240
|
|
|
201
241
|
// Rendering
|
|
202
|
-
enableLighting: boolean
|
|
203
|
-
smoothLighting: boolean
|
|
204
|
-
dayCycle: boolean
|
|
205
|
-
starfield: boolean
|
|
206
|
-
fov: number
|
|
242
|
+
enableLighting: boolean // Enable block/sky lighting
|
|
243
|
+
smoothLighting: boolean // Enable ambient occlusion
|
|
244
|
+
dayCycle: boolean // Enable time-based sky changes
|
|
245
|
+
starfield: boolean // Enable star field at night
|
|
246
|
+
fov: number // Camera field of view
|
|
207
247
|
|
|
208
248
|
// Debug
|
|
209
|
-
showChunkBorders: boolean
|
|
210
|
-
enableDebugOverlay: boolean
|
|
211
|
-
clipWorldBelowY: number | undefined
|
|
249
|
+
showChunkBorders: boolean // Show chunk boundary helpers
|
|
250
|
+
enableDebugOverlay: boolean // Show advanced stats
|
|
251
|
+
clipWorldBelowY: number | undefined // Don't render below Y level
|
|
212
252
|
}
|
|
213
253
|
```
|
|
214
254
|
|
|
@@ -223,7 +263,7 @@ The renderer implements several memory optimizations:
|
|
|
223
263
|
```typescript
|
|
224
264
|
// Get memory usage
|
|
225
265
|
const { bytes, readable } = worldGeometryHandler.getMemoryUsageReadable()
|
|
226
|
-
console.log(`GPU Memory: ${readable}`)
|
|
266
|
+
console.log(`GPU Memory: ${readable}`) // e.g., "45.32 MB"
|
|
227
267
|
```
|
|
228
268
|
|
|
229
269
|
## Performance Tips
|
|
@@ -301,7 +341,7 @@ viewer.resourcesManager = {
|
|
|
301
341
|
await viewer.loadBackend(createGraphicsBackend)
|
|
302
342
|
|
|
303
343
|
// Start world
|
|
304
|
-
await viewer.startWorld(world, 4)
|
|
344
|
+
await viewer.startWorld(world, 4) // 4 chunk render distance
|
|
305
345
|
|
|
306
346
|
// Initialize world view
|
|
307
347
|
await viewer.worldView!.init(new Vec3(0, 64, 0))
|