minecraft-renderer 0.1.49 → 0.1.51
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/mesherWasm.js +32 -32
- package/dist/minecraft-renderer.js +54 -54
- package/dist/minecraft-renderer.js.meta.json +1 -1
- package/dist/threeWorker.js +393 -393
- package/package.json +1 -1
- package/src/graphicsBackend/rendererOptionsSync.ts +2 -0
- package/src/three/documentRenderer.ts +1 -1
- package/src/three/menuBackground/defaultOptions.ts +35 -12
- package/src/three/menuBackground/futuristic.ts +18 -34
- package/src/three/menuBackground/futuristicMeta.ts +36 -0
- package/src/three/menuBackground/gpuPreference.ts +11 -0
- package/src/three/menuBackground/index.ts +4 -2
- package/src/wasm-mesher/bridge/shaderCubeBridge.ts +6 -3
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { subscribe } from 'valtio/vanilla'
|
|
8
8
|
import type { AppViewer } from './appViewer'
|
|
9
9
|
import type { RendererStorageOptions } from '../three/menuBackground/defaultOptions'
|
|
10
|
+
import { rendererShaderCubeDebugModeToValue } from '../three/menuBackground/defaultOptions'
|
|
10
11
|
import type { MenuBackgroundOptions } from '../three/menuBackground/types'
|
|
11
12
|
import type { MenuBackgroundRenderer } from '../three/menuBackground/renderer'
|
|
12
13
|
import { menuBackgroundSpeedToMultiplier } from '../three/menuBackground/config'
|
|
@@ -171,6 +172,7 @@ export function applyRendererOptions(
|
|
|
171
172
|
cfg.starfield = o.starfieldRendering
|
|
172
173
|
cfg.defaultSkybox = o.defaultSkybox
|
|
173
174
|
cfg.fov = o.fov
|
|
175
|
+
cfg.shaderCubeDebugMode = rendererShaderCubeDebugModeToValue(o.rendererShaderCubeDebugMode)
|
|
174
176
|
}
|
|
175
177
|
|
|
176
178
|
/** World-view + hand/camera options (call when WorldView is ready). */
|
|
@@ -14,7 +14,7 @@ import Stats from 'stats.js'
|
|
|
14
14
|
import StatsGl from 'stats-gl'
|
|
15
15
|
import * as tween from '@tweenjs/tween.js'
|
|
16
16
|
import type { GraphicsBackendConfig, GraphicsInitOptions } from '../graphicsBackend/types'
|
|
17
|
-
import { gpuPreferenceToWebGLPowerPreference } from '../three/menuBackground/
|
|
17
|
+
import { gpuPreferenceToWebGLPowerPreference } from '../three/menuBackground/gpuPreference'
|
|
18
18
|
import { WorldRendererConfig } from '../graphicsBackend'
|
|
19
19
|
|
|
20
20
|
// ============================================================================
|
|
@@ -6,8 +6,9 @@ import {
|
|
|
6
6
|
FUTURISTIC_SCENE_LABELS,
|
|
7
7
|
MINECRAFT_BLOCK_GROUP_IDS,
|
|
8
8
|
MINECRAFT_BLOCK_GROUP_LABELS
|
|
9
|
-
} from './
|
|
9
|
+
} from './futuristicMeta'
|
|
10
10
|
import { MENU_BACKGROUND_OPTION_DEFAULTS } from './config'
|
|
11
|
+
import type { RendererGpuPreference } from './gpuPreference'
|
|
11
12
|
|
|
12
13
|
export type RendererOptionMeta = {
|
|
13
14
|
possibleValues?: string[] | Array<[string, string]>
|
|
@@ -20,19 +21,26 @@ export type RendererOptionMeta = {
|
|
|
20
21
|
requiresRestart?: boolean
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
export type RendererDefaultOptionKey = keyof typeof RENDERER_DEFAULT_OPTIONS
|
|
24
|
-
|
|
25
24
|
export type RendererMesherPipeline = 'wasm' | 'legacy-js'
|
|
26
25
|
|
|
27
|
-
export type
|
|
26
|
+
export type RendererShaderCubeDebugMode =
|
|
27
|
+
| 'off'
|
|
28
|
+
| 'holes'
|
|
29
|
+
| 'texIndex'
|
|
30
|
+
| 'faces'
|
|
31
|
+
| 'atlasAlpha'
|
|
32
|
+
|
|
33
|
+
const SHADER_CUBE_DEBUG_MODE_TO_VALUE: Record<RendererShaderCubeDebugMode, number> = {
|
|
34
|
+
off: 0,
|
|
35
|
+
holes: 1,
|
|
36
|
+
texIndex: 2,
|
|
37
|
+
faces: 3,
|
|
38
|
+
atlasAlpha: 4,
|
|
39
|
+
}
|
|
28
40
|
|
|
29
|
-
/** Maps stored
|
|
30
|
-
export function
|
|
31
|
-
|
|
32
|
-
): 'high-performance' | 'low-power' | undefined {
|
|
33
|
-
if (preference === 'high-performance') return 'high-performance'
|
|
34
|
-
if (preference === 'low-power') return 'low-power'
|
|
35
|
-
return undefined
|
|
41
|
+
/** Maps stored option → `inWorldRenderingConfig.shaderCubeDebugMode` (0–4). */
|
|
42
|
+
export function rendererShaderCubeDebugModeToValue(mode: RendererShaderCubeDebugMode): number {
|
|
43
|
+
return SHADER_CUBE_DEBUG_MODE_TO_VALUE[mode]
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
const MB = MENU_BACKGROUND_OPTION_DEFAULTS
|
|
@@ -54,6 +62,7 @@ export const RENDERER_DEFAULT_OPTIONS = {
|
|
|
54
62
|
rendererPerfDebugOverlay: false as boolean,
|
|
55
63
|
disableBlockEntityTextures: false as boolean,
|
|
56
64
|
rendererMesher: 'wasm' as RendererMesherPipeline,
|
|
65
|
+
rendererShaderCubeDebugMode: 'off' as RendererShaderCubeDebugMode,
|
|
57
66
|
showChunkBorders: false as boolean,
|
|
58
67
|
renderEntities: true as boolean,
|
|
59
68
|
renderDebug: 'basic' as 'none' | 'basic' | 'advanced',
|
|
@@ -76,6 +85,8 @@ export const RENDERER_DEFAULT_OPTIONS = {
|
|
|
76
85
|
fov: 75
|
|
77
86
|
} as const
|
|
78
87
|
|
|
88
|
+
export type RendererDefaultOptionKey = keyof typeof RENDERER_DEFAULT_OPTIONS
|
|
89
|
+
|
|
79
90
|
/** App options storage shape for renderer-owned keys. */
|
|
80
91
|
export type RendererStorageOptions = typeof RENDERER_DEFAULT_OPTIONS
|
|
81
92
|
|
|
@@ -166,6 +177,17 @@ export const RENDERER_OPTIONS_META: Partial<Record<RendererDefaultOptionKey, Ren
|
|
|
166
177
|
tooltip: 'WASM is faster. Use JS if WASM is not working. Requires reload.',
|
|
167
178
|
requiresRestart: true
|
|
168
179
|
},
|
|
180
|
+
rendererShaderCubeDebugMode: {
|
|
181
|
+
text: 'Shader cube debug',
|
|
182
|
+
tooltip: 'Instanced cube path visualization (requires shader cubes enabled).',
|
|
183
|
+
possibleValues: [
|
|
184
|
+
['off', 'Off'],
|
|
185
|
+
['holes', 'Hole test (red)'],
|
|
186
|
+
['texIndex', 'Tile index colors'],
|
|
187
|
+
['faces', 'Face id colors'],
|
|
188
|
+
['atlasAlpha', 'Atlas alpha'],
|
|
189
|
+
],
|
|
190
|
+
},
|
|
169
191
|
showChunkBorders: {
|
|
170
192
|
text: 'Chunk borders'
|
|
171
193
|
},
|
|
@@ -301,7 +323,8 @@ export const RENDERER_RENDER_GUI_SECTIONS: ReadonlyArray<{
|
|
|
301
323
|
title: 'Renderer debug',
|
|
302
324
|
keys: [
|
|
303
325
|
'rendererFuturisticReveal',
|
|
304
|
-
'rendererPerfDebugOverlay'
|
|
326
|
+
'rendererPerfDebugOverlay',
|
|
327
|
+
'rendererShaderCubeDebugMode',
|
|
305
328
|
]
|
|
306
329
|
}
|
|
307
330
|
]
|
|
@@ -7,28 +7,24 @@ import type { MenuBackgroundView } from './activeView'
|
|
|
7
7
|
import { resizeMenuBackgroundCamera } from './activeView'
|
|
8
8
|
import { loadThreeJsTextureFromBitmap } from '../threeJsUtils'
|
|
9
9
|
import { MENU_BACKGROUND_MOTION_DEFAULTS, MENU_BACKGROUND_OPTION_DEFAULTS } from './config'
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
dive: 'Dive',
|
|
29
|
-
orbit: 'Orbit',
|
|
30
|
-
snake: 'Snake'
|
|
31
|
-
}
|
|
10
|
+
import {
|
|
11
|
+
FUTURISTIC_CAMERA_IDS,
|
|
12
|
+
FUTURISTIC_SCENE_IDS,
|
|
13
|
+
MINECRAFT_BLOCK_GROUP_IDS,
|
|
14
|
+
type FuturisticCameraId,
|
|
15
|
+
type FuturisticSceneId,
|
|
16
|
+
type MinecraftBlockGroupId,
|
|
17
|
+
} from './futuristicMeta'
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
FUTURISTIC_SCENE_IDS,
|
|
21
|
+
FUTURISTIC_SCENE_LABELS,
|
|
22
|
+
FUTURISTIC_CAMERA_IDS,
|
|
23
|
+
FUTURISTIC_CAMERA_LABELS,
|
|
24
|
+
MINECRAFT_BLOCK_GROUP_IDS,
|
|
25
|
+
MINECRAFT_BLOCK_GROUP_LABELS,
|
|
26
|
+
} from './futuristicMeta'
|
|
27
|
+
export type { FuturisticSceneId, FuturisticCameraId, MinecraftBlockGroupId } from './futuristicMeta'
|
|
32
28
|
|
|
33
29
|
/** Mouse parallax scale (HTML prototype uses 1). */
|
|
34
30
|
const MOUSE_INFLUENCE = 0.1
|
|
@@ -86,18 +82,6 @@ export const MINECRAFT_BLOCK_GROUPS = {
|
|
|
86
82
|
]
|
|
87
83
|
} as const
|
|
88
84
|
|
|
89
|
-
export const MINECRAFT_BLOCK_GROUP_IDS = ['mixed', 'stainedGlass', 'wool', 'construction', 'glow', 'world'] as const
|
|
90
|
-
export type MinecraftBlockGroupId = typeof MINECRAFT_BLOCK_GROUP_IDS[number]
|
|
91
|
-
|
|
92
|
-
export const MINECRAFT_BLOCK_GROUP_LABELS: Record<MinecraftBlockGroupId, string> = {
|
|
93
|
-
mixed: 'Mixed',
|
|
94
|
-
stainedGlass: 'Stained glass',
|
|
95
|
-
wool: 'Wool',
|
|
96
|
-
construction: 'Construction',
|
|
97
|
-
glow: 'Glow',
|
|
98
|
-
world: 'World (grass & ores)'
|
|
99
|
-
}
|
|
100
|
-
|
|
101
85
|
interface ScenePalette {
|
|
102
86
|
bg: number
|
|
103
87
|
fog: number
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//@ts-nocheck
|
|
2
|
+
/** Settings / labels only — no Three.js or DocumentRenderer (safe for defaultOptions imports). */
|
|
3
|
+
|
|
4
|
+
export const FUTURISTIC_SCENE_IDS = ['galaxy', 'nether', 'end', 'cyber', 'light'] as const
|
|
5
|
+
export type FuturisticSceneId = typeof FUTURISTIC_SCENE_IDS[number]
|
|
6
|
+
|
|
7
|
+
export const FUTURISTIC_CAMERA_IDS = ['cruise', 'barrel', 'dive', 'orbit', 'snake'] as const
|
|
8
|
+
export type FuturisticCameraId = typeof FUTURISTIC_CAMERA_IDS[number]
|
|
9
|
+
|
|
10
|
+
export const FUTURISTIC_SCENE_LABELS: Record<FuturisticSceneId, string> = {
|
|
11
|
+
galaxy: 'Galaxy',
|
|
12
|
+
nether: 'Nether',
|
|
13
|
+
end: 'The End',
|
|
14
|
+
cyber: 'Cyber',
|
|
15
|
+
light: 'Light Space'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const FUTURISTIC_CAMERA_LABELS: Record<FuturisticCameraId, string> = {
|
|
19
|
+
cruise: 'Cruise',
|
|
20
|
+
barrel: 'Barrel',
|
|
21
|
+
dive: 'Dive',
|
|
22
|
+
orbit: 'Orbit',
|
|
23
|
+
snake: 'Snake'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const MINECRAFT_BLOCK_GROUP_IDS = ['mixed', 'stainedGlass', 'wool', 'construction', 'glow', 'world'] as const
|
|
27
|
+
export type MinecraftBlockGroupId = typeof MINECRAFT_BLOCK_GROUP_IDS[number]
|
|
28
|
+
|
|
29
|
+
export const MINECRAFT_BLOCK_GROUP_LABELS: Record<MinecraftBlockGroupId, string> = {
|
|
30
|
+
mixed: 'Mixed',
|
|
31
|
+
stainedGlass: 'Stained glass',
|
|
32
|
+
wool: 'Wool',
|
|
33
|
+
construction: 'Construction',
|
|
34
|
+
glow: 'Glow',
|
|
35
|
+
world: 'World (grass & ores)'
|
|
36
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//@ts-nocheck
|
|
2
|
+
export type RendererGpuPreference = 'default' | 'high-performance' | 'low-power'
|
|
3
|
+
|
|
4
|
+
/** Maps stored `gpuPreference` to WebGL `powerPreference` (undefined = browser default). */
|
|
5
|
+
export function gpuPreferenceToWebGLPowerPreference(
|
|
6
|
+
preference: RendererGpuPreference
|
|
7
|
+
): 'high-performance' | 'low-power' | undefined {
|
|
8
|
+
if (preference === 'high-performance') return 'high-performance'
|
|
9
|
+
if (preference === 'low-power') return 'low-power'
|
|
10
|
+
return undefined
|
|
11
|
+
}
|
|
@@ -36,9 +36,11 @@ export {
|
|
|
36
36
|
} from './defaultOptions'
|
|
37
37
|
export type {
|
|
38
38
|
RendererDefaultOptionKey,
|
|
39
|
-
RendererGpuPreference,
|
|
40
39
|
RendererMesherPipeline,
|
|
40
|
+
RendererShaderCubeDebugMode,
|
|
41
41
|
RendererOptionMeta,
|
|
42
42
|
RendererStorageOptions
|
|
43
43
|
} from './defaultOptions'
|
|
44
|
-
export { gpuPreferenceToWebGLPowerPreference } from './
|
|
44
|
+
export { gpuPreferenceToWebGLPowerPreference } from './gpuPreference'
|
|
45
|
+
export type { RendererGpuPreference } from './gpuPreference'
|
|
46
|
+
export { rendererShaderCubeDebugModeToValue } from './defaultOptions'
|
|
@@ -121,10 +121,13 @@ export function resolveFaceTileIndex(
|
|
|
121
121
|
return texMapping.tileIndexFromTextureEntry(entry)
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
/**
|
|
124
|
+
/** Main thread + worker: use `loadedData` set by the app / mesher (see mesherWasm). */
|
|
125
125
|
function getTintsJson(): Record<string, any> {
|
|
126
|
-
const
|
|
127
|
-
|
|
126
|
+
const tints = (globalThis as any).loadedData?.tints
|
|
127
|
+
if (!tints) {
|
|
128
|
+
throw new Error('shaderCubeBridge: globalThis.loadedData.tints is not available yet')
|
|
129
|
+
}
|
|
130
|
+
return tints
|
|
128
131
|
}
|
|
129
132
|
|
|
130
133
|
export function getShaderCubeResources(): {
|