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
|
@@ -1,83 +1,86 @@
|
|
|
1
|
-
<!
|
|
1
|
+
<!doctype html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Minecraft Renderer Playground</title>
|
|
7
|
+
<style>
|
|
8
|
+
* {
|
|
9
|
+
margin: 0;
|
|
10
|
+
padding: 0;
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
html,
|
|
15
|
+
body {
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
background: #1a1a1a;
|
|
20
|
+
}
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
#viewer-canvas {
|
|
23
|
+
position: fixed;
|
|
24
|
+
top: 0;
|
|
25
|
+
left: 0;
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: 100%;
|
|
28
|
+
}
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
.lil-gui {
|
|
31
|
+
position: fixed !important;
|
|
32
|
+
top: 10px;
|
|
33
|
+
right: 10px;
|
|
34
|
+
z-index: 1000;
|
|
35
|
+
}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
37
|
+
.loading-overlay {
|
|
38
|
+
position: fixed;
|
|
39
|
+
top: 0;
|
|
40
|
+
left: 0;
|
|
41
|
+
width: 100%;
|
|
42
|
+
height: 100%;
|
|
43
|
+
background: #1a1a1a;
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
align-items: center;
|
|
48
|
+
z-index: 10000;
|
|
49
|
+
color: #fff;
|
|
50
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
51
|
+
}
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
.loading-overlay.hidden {
|
|
54
|
+
display: none;
|
|
55
|
+
}
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
.loading-spinner {
|
|
58
|
+
width: 50px;
|
|
59
|
+
height: 50px;
|
|
60
|
+
border: 3px solid #333;
|
|
61
|
+
border-top-color: #4ade80;
|
|
62
|
+
border-radius: 50%;
|
|
63
|
+
animation: spin 1s linear infinite;
|
|
64
|
+
}
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
@keyframes spin {
|
|
67
|
+
to {
|
|
68
|
+
transform: rotate(360deg);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
68
71
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
</head>
|
|
76
|
-
<body>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
</body>
|
|
72
|
+
.loading-text {
|
|
73
|
+
margin-top: 16px;
|
|
74
|
+
font-size: 14px;
|
|
75
|
+
color: #888;
|
|
76
|
+
}
|
|
77
|
+
</style>
|
|
78
|
+
</head>
|
|
79
|
+
<body>
|
|
80
|
+
<div id="react-root"></div>
|
|
81
|
+
<div class="loading-overlay" id="loading">
|
|
82
|
+
<div class="loading-spinner"></div>
|
|
83
|
+
<div class="loading-text">Loading Minecraft Renderer...</div>
|
|
84
|
+
</div>
|
|
85
|
+
</body>
|
|
83
86
|
</html>
|
|
@@ -5,7 +5,20 @@ import * as scenes from './scenes'
|
|
|
5
5
|
|
|
6
6
|
const qsScene = new URLSearchParams(window.location.search).get('scene')
|
|
7
7
|
const Scene: typeof BasePlaygroundScene = qsScene ? scenes[qsScene] : scenes.main
|
|
8
|
-
playgroundGlobalUiState.scenes = [
|
|
8
|
+
playgroundGlobalUiState.scenes = [
|
|
9
|
+
'main',
|
|
10
|
+
'railsCobweb',
|
|
11
|
+
'highPosEntityUpdates',
|
|
12
|
+
'floorRandom',
|
|
13
|
+
'lightingStarfield',
|
|
14
|
+
'transparencyIssue',
|
|
15
|
+
'entities',
|
|
16
|
+
'frequentUpdates',
|
|
17
|
+
'slabsOptimization',
|
|
18
|
+
'allEntities',
|
|
19
|
+
'geometryExport',
|
|
20
|
+
'partialBlockCulling'
|
|
21
|
+
]
|
|
9
22
|
playgroundGlobalUiState.selected = qsScene ?? 'main'
|
|
10
23
|
|
|
11
24
|
const scene = new Scene()
|
|
@@ -10,16 +10,15 @@ export const playgroundGlobalUiState = proxy({
|
|
|
10
10
|
scenes: [] as string[],
|
|
11
11
|
selected: '',
|
|
12
12
|
selectorOpened: false,
|
|
13
|
-
actions: {} as Record<string, () => void
|
|
13
|
+
actions: {} as Record<string, () => void>
|
|
14
14
|
})
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
renderToDom(<Playground />, {
|
|
18
17
|
strictMode: false,
|
|
19
|
-
selector: '#react-root'
|
|
18
|
+
selector: '#react-root'
|
|
20
19
|
})
|
|
21
20
|
|
|
22
|
-
function Playground
|
|
21
|
+
function Playground() {
|
|
23
22
|
useEffect(() => {
|
|
24
23
|
const style = document.createElement('style')
|
|
25
24
|
style.innerHTML = /* css */ `
|
|
@@ -41,99 +40,126 @@ function Playground () {
|
|
|
41
40
|
}
|
|
42
41
|
}, [])
|
|
43
42
|
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
return (
|
|
44
|
+
<div
|
|
45
|
+
style={{
|
|
46
|
+
fontFamily: 'monospace',
|
|
47
|
+
color: 'white'
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
<Controls />
|
|
51
|
+
<SceneSelector />
|
|
52
|
+
<ActionsSelector />
|
|
53
|
+
</div>
|
|
54
|
+
)
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
function SceneSelector
|
|
57
|
+
function SceneSelector() {
|
|
55
58
|
const mobile = isMobile()
|
|
56
59
|
const { scenes, selected } = useSnapshot(playgroundGlobalUiState)
|
|
57
60
|
const [hidden, setHidden] = useState(false)
|
|
58
|
-
const longPressEvents = useLongPress(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
const longPressEvents = useLongPress(
|
|
62
|
+
() => {
|
|
63
|
+
playgroundGlobalUiState.selectorOpened = true
|
|
64
|
+
},
|
|
65
|
+
() => {}
|
|
66
|
+
)
|
|
61
67
|
|
|
62
68
|
if (hidden) return null
|
|
63
69
|
|
|
64
|
-
return
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
{
|
|
75
|
-
|
|
70
|
+
return (
|
|
71
|
+
<div
|
|
72
|
+
style={{
|
|
73
|
+
position: 'fixed',
|
|
74
|
+
top: 0,
|
|
75
|
+
left: 0,
|
|
76
|
+
display: 'flex',
|
|
77
|
+
alignItems: 'flex-start',
|
|
78
|
+
zIndex: 1
|
|
79
|
+
}}
|
|
80
|
+
{...longPressEvents}
|
|
81
|
+
>
|
|
82
|
+
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
|
83
|
+
{scenes.map(scene => (
|
|
84
|
+
<div
|
|
85
|
+
key={scene}
|
|
86
|
+
style={{
|
|
87
|
+
padding: mobile ? '5px' : '2px 5px',
|
|
88
|
+
cursor: 'pointer',
|
|
89
|
+
userSelect: 'none',
|
|
90
|
+
background: scene === selected ? 'rgba(0, 0, 0, 0.5)' : 'rgba(0, 0, 0, 0.6)',
|
|
91
|
+
fontWeight: scene === selected ? 'bold' : 'normal'
|
|
92
|
+
}}
|
|
93
|
+
onClick={() => {
|
|
94
|
+
const qs = new URLSearchParams(window.location.search)
|
|
95
|
+
qs.set('scene', scene)
|
|
96
|
+
location.search = qs.toString()
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
{scene}
|
|
100
|
+
</div>
|
|
101
|
+
))}
|
|
102
|
+
</div>
|
|
103
|
+
<div
|
|
76
104
|
style={{
|
|
77
105
|
padding: mobile ? '5px' : '2px 5px',
|
|
78
106
|
cursor: 'pointer',
|
|
79
107
|
userSelect: 'none',
|
|
80
|
-
background:
|
|
81
|
-
|
|
108
|
+
background: 'rgba(0, 0, 0, 0.6)',
|
|
109
|
+
fontSize: '14px',
|
|
110
|
+
lineHeight: '1'
|
|
82
111
|
}}
|
|
83
|
-
onClick={() =>
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}}
|
|
88
|
-
>{scene}</div>)}
|
|
112
|
+
onClick={() => setHidden(true)}
|
|
113
|
+
>
|
|
114
|
+
×
|
|
115
|
+
</div>
|
|
89
116
|
</div>
|
|
90
|
-
|
|
91
|
-
style={{
|
|
92
|
-
padding: mobile ? '5px' : '2px 5px',
|
|
93
|
-
cursor: 'pointer',
|
|
94
|
-
userSelect: 'none',
|
|
95
|
-
background: 'rgba(0, 0, 0, 0.6)',
|
|
96
|
-
fontSize: '14px',
|
|
97
|
-
lineHeight: '1',
|
|
98
|
-
}}
|
|
99
|
-
onClick={() => setHidden(true)}
|
|
100
|
-
>×</div>
|
|
101
|
-
</div>
|
|
117
|
+
)
|
|
102
118
|
}
|
|
103
119
|
|
|
104
120
|
const ActionsSelector = () => {
|
|
105
121
|
const { actions, selectorOpened } = useSnapshot(playgroundGlobalUiState)
|
|
106
122
|
|
|
107
123
|
if (!selectorOpened) return null
|
|
108
|
-
return
|
|
109
|
-
|
|
110
|
-
inset: 0,
|
|
111
|
-
background: 'rgba(0, 0, 0, 0.5)',
|
|
112
|
-
zIndex: 10,
|
|
113
|
-
display: 'flex',
|
|
114
|
-
flexDirection: 'column',
|
|
115
|
-
justifyContent: 'center',
|
|
116
|
-
alignItems: 'center',
|
|
117
|
-
gap: 5,
|
|
118
|
-
fontSize: 24,
|
|
119
|
-
}}>{Object.entries({
|
|
120
|
-
...actions,
|
|
121
|
-
'Close' () {
|
|
122
|
-
playgroundGlobalUiState.selectorOpened = false
|
|
123
|
-
}
|
|
124
|
-
}).map(([name, action]) => <div
|
|
125
|
-
key={name}
|
|
124
|
+
return (
|
|
125
|
+
<div
|
|
126
126
|
style={{
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
userSelect: 'none',
|
|
127
|
+
position: 'fixed',
|
|
128
|
+
inset: 0,
|
|
130
129
|
background: 'rgba(0, 0, 0, 0.5)',
|
|
130
|
+
zIndex: 10,
|
|
131
|
+
display: 'flex',
|
|
132
|
+
flexDirection: 'column',
|
|
133
|
+
justifyContent: 'center',
|
|
134
|
+
alignItems: 'center',
|
|
135
|
+
gap: 5,
|
|
136
|
+
fontSize: 24
|
|
131
137
|
}}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
>
|
|
139
|
+
{Object.entries({
|
|
140
|
+
...actions,
|
|
141
|
+
Close() {
|
|
142
|
+
playgroundGlobalUiState.selectorOpened = false
|
|
143
|
+
}
|
|
144
|
+
}).map(([name, action]) => (
|
|
145
|
+
<div
|
|
146
|
+
key={name}
|
|
147
|
+
style={{
|
|
148
|
+
padding: '2px 5px',
|
|
149
|
+
cursor: 'pointer',
|
|
150
|
+
userSelect: 'none',
|
|
151
|
+
background: 'rgba(0, 0, 0, 0.5)'
|
|
152
|
+
}}
|
|
153
|
+
onClick={() => {
|
|
154
|
+
action()
|
|
155
|
+
playgroundGlobalUiState.selectorOpened = false
|
|
156
|
+
}}
|
|
157
|
+
>
|
|
158
|
+
{name}
|
|
159
|
+
</div>
|
|
160
|
+
))}
|
|
161
|
+
</div>
|
|
162
|
+
)
|
|
137
163
|
}
|
|
138
164
|
|
|
139
165
|
const Controls = () => {
|
|
@@ -2,15 +2,11 @@
|
|
|
2
2
|
import { useCallback, useRef, useState } from 'react'
|
|
3
3
|
|
|
4
4
|
interface LongPressOptions {
|
|
5
|
-
shouldPreventDefault?: boolean
|
|
6
|
-
delay?: number
|
|
5
|
+
shouldPreventDefault?: boolean
|
|
6
|
+
delay?: number
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
const useLongPress = (
|
|
10
|
-
onLongPress: () => void,
|
|
11
|
-
onClick: () => void,
|
|
12
|
-
{ shouldPreventDefault = false, delay = 300 }: LongPressOptions = {}
|
|
13
|
-
) => {
|
|
9
|
+
const useLongPress = (onLongPress: () => void, onClick: () => void, { shouldPreventDefault = false, delay = 300 }: LongPressOptions = {}) => {
|
|
14
10
|
const [longPressTriggered, setLongPressTriggered] = useState(false)
|
|
15
11
|
const timeout = useRef<number | undefined>(null)
|
|
16
12
|
const target = useRef<EventTarget | null>(null)
|
|
@@ -7,7 +7,7 @@ import { WorldRendererThree } from '../../viewer/three/worldrendererThree'
|
|
|
7
7
|
export default class extends BasePlaygroundScene {
|
|
8
8
|
continuousRender = true
|
|
9
9
|
|
|
10
|
-
override initGui
|
|
10
|
+
override initGui(): void {
|
|
11
11
|
this.params = {
|
|
12
12
|
starfield: false,
|
|
13
13
|
entity: 'player',
|
|
@@ -15,7 +15,7 @@ export default class extends BasePlaygroundScene {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
override renderFinish
|
|
18
|
+
override renderFinish(): void {
|
|
19
19
|
if (this.params.starfield) {
|
|
20
20
|
;(viewer.world as WorldRendererThree).scene.background = new THREE.Color(0x00_00_00)
|
|
21
21
|
;(viewer.world as WorldRendererThree).starField.enabled = true
|
|
@@ -25,11 +25,14 @@ export default class extends BasePlaygroundScene {
|
|
|
25
25
|
for (let i = 0; i < this.params.count; i++) {
|
|
26
26
|
for (let j = 0; j < this.params.count; j++) {
|
|
27
27
|
for (let k = 0; k < this.params.count; k++) {
|
|
28
|
-
viewer.entities.update(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
viewer.entities.update(
|
|
29
|
+
{
|
|
30
|
+
id: i * 1000 + j * 100 + k,
|
|
31
|
+
name: this.params.entity,
|
|
32
|
+
pos: this.targetPos.offset(i, j, k)
|
|
33
|
+
} as any,
|
|
34
|
+
{}
|
|
35
|
+
)
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
}
|
|
@@ -6,7 +6,7 @@ export default class extends BasePlaygroundScene {
|
|
|
6
6
|
viewDistance = 5
|
|
7
7
|
continuousRender = true
|
|
8
8
|
|
|
9
|
-
override initGui
|
|
9
|
+
override initGui(): void {
|
|
10
10
|
this.params = {
|
|
11
11
|
testActive: false,
|
|
12
12
|
testUpdatesPerSecond: 10,
|
|
@@ -25,7 +25,7 @@ export default class extends BasePlaygroundScene {
|
|
|
25
25
|
|
|
26
26
|
lastUpdatedOffset = 0
|
|
27
27
|
lastUpdatedId = 2
|
|
28
|
-
updateBlock
|
|
28
|
+
updateBlock() {
|
|
29
29
|
const x = this.lastUpdatedOffset % 16
|
|
30
30
|
const z = Math.floor(this.lastUpdatedOffset / 16)
|
|
31
31
|
const y = 90
|
|
@@ -35,7 +35,7 @@ export default class extends BasePlaygroundScene {
|
|
|
35
35
|
if (this.lastUpdatedId > 500) this.lastUpdatedId = 1
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
testNeighborUpdates
|
|
38
|
+
testNeighborUpdates() {
|
|
39
39
|
viewer.world.setBlockStateId(new Vec3(15, 95, 15), 1)
|
|
40
40
|
viewer.world.setBlockStateId(new Vec3(0, 95, 15), 1)
|
|
41
41
|
viewer.world.setBlockStateId(new Vec3(15, 95, 0), 1)
|
|
@@ -53,7 +53,7 @@ export default class extends BasePlaygroundScene {
|
|
|
53
53
|
}, 3000)
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
setupTimer
|
|
56
|
+
setupTimer() {
|
|
57
57
|
// this.stopRender = true
|
|
58
58
|
|
|
59
59
|
let lastTime = 0
|
|
@@ -121,7 +121,7 @@ export default class extends BasePlaygroundScene {
|
|
|
121
121
|
// }, 1)
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
setupWorld
|
|
124
|
+
setupWorld() {
|
|
125
125
|
this.worldConfig.showChunkBorders = true
|
|
126
126
|
|
|
127
127
|
const maxSquareRadius = this.viewDistance * 16
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
//@ts-nocheck
|
|
2
2
|
import * as THREE from 'three'
|
|
3
3
|
import { BasePlaygroundScene } from '../baseScene'
|
|
4
|
-
import {
|
|
5
|
-
downloadWorldGeometry,
|
|
6
|
-
loadWorldGeometryFromUrl,
|
|
7
|
-
type ExportedWorldGeometry
|
|
8
|
-
} from '../../three/worldGeometryExport'
|
|
4
|
+
import { downloadWorldGeometry, loadWorldGeometryFromUrl, type ExportedWorldGeometry } from '../../three/worldGeometryExport'
|
|
9
5
|
|
|
10
6
|
type GeometryExportBackendMethods = {
|
|
11
7
|
loadGeometryExport?: (exportData: ExportedWorldGeometry) => Promise<number>
|
|
@@ -22,7 +18,7 @@ export default class extends BasePlaygroundScene {
|
|
|
22
18
|
params = {
|
|
23
19
|
exportGeometry: () => this.exportGeometry(),
|
|
24
20
|
exportWithTexture: () => this.exportGeometry(true),
|
|
25
|
-
showDebugMesh: true
|
|
21
|
+
showDebugMesh: true
|
|
26
22
|
}
|
|
27
23
|
|
|
28
24
|
// Loaded geometry data (when loading from URL)
|
|
@@ -38,7 +34,7 @@ export default class extends BasePlaygroundScene {
|
|
|
38
34
|
super({
|
|
39
35
|
viewDistance: geometryUrl ? 0 : 1,
|
|
40
36
|
continuousRender: false,
|
|
41
|
-
enableCameraOrbitControl: false
|
|
37
|
+
enableCameraOrbitControl: false
|
|
42
38
|
})
|
|
43
39
|
|
|
44
40
|
this.geometryUrl = geometryUrl
|
|
@@ -84,16 +80,8 @@ export default class extends BasePlaygroundScene {
|
|
|
84
80
|
|
|
85
81
|
// Apply rotation using lookAt direction
|
|
86
82
|
const { pitch, yaw } = camData.rotation
|
|
87
|
-
const forward = new THREE.Vector3(
|
|
88
|
-
|
|
89
|
-
Math.sin(pitch),
|
|
90
|
-
-Math.cos(yaw) * Math.cos(pitch)
|
|
91
|
-
)
|
|
92
|
-
this.camera.lookAt(
|
|
93
|
-
camData.position.x + forward.x,
|
|
94
|
-
camData.position.y + forward.y,
|
|
95
|
-
camData.position.z + forward.z
|
|
96
|
-
)
|
|
83
|
+
const forward = new THREE.Vector3(-Math.sin(yaw) * Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw) * Math.cos(pitch))
|
|
84
|
+
this.camera.lookAt(camData.position.x + forward.x, camData.position.y + forward.y, camData.position.z + forward.z)
|
|
97
85
|
this.controls?.update()
|
|
98
86
|
this.syncCameraToBackend()
|
|
99
87
|
|
|
@@ -117,7 +105,6 @@ export default class extends BasePlaygroundScene {
|
|
|
117
105
|
this.updateDebugMeshVisibility()
|
|
118
106
|
|
|
119
107
|
this.requestRender()
|
|
120
|
-
|
|
121
108
|
} catch (err) {
|
|
122
109
|
console.error('Failed to load geometry:', err)
|
|
123
110
|
}
|
|
@@ -135,7 +122,7 @@ export default class extends BasePlaygroundScene {
|
|
|
135
122
|
if (!container) return
|
|
136
123
|
|
|
137
124
|
// Traverse all meshes and add BoxHelper for each
|
|
138
|
-
container.traverse(
|
|
125
|
+
container.traverse(obj => {
|
|
139
126
|
if ((obj as THREE.Mesh).isMesh && obj.name === 'mesh') {
|
|
140
127
|
const mesh = obj as THREE.Mesh
|
|
141
128
|
const helper = new THREE.BoxHelper(mesh, 0xff_ff_00)
|
|
@@ -190,5 +177,4 @@ export default class extends BasePlaygroundScene {
|
|
|
190
177
|
downloadWorldGeometry(worldRenderer, cameraPosition, cameraRotation, filename, includeTexture)
|
|
191
178
|
console.log('Geometry exported to:', filename)
|
|
192
179
|
}
|
|
193
|
-
|
|
194
180
|
}
|
|
@@ -101,17 +101,9 @@ export default class extends BasePlaygroundScene {
|
|
|
101
101
|
const cameraOffset = new Vec3(5, 5, 5)
|
|
102
102
|
const cameraPos = this.targetPos.offset(cameraOffset.x, cameraOffset.y, cameraOffset.z)
|
|
103
103
|
|
|
104
|
-
this.controls.target.set(
|
|
105
|
-
this.targetPos.x + 0.5,
|
|
106
|
-
this.targetPos.y + 1,
|
|
107
|
-
this.targetPos.z + 0.5
|
|
108
|
-
)
|
|
104
|
+
this.controls.target.set(this.targetPos.x + 0.5, this.targetPos.y + 1, this.targetPos.z + 0.5)
|
|
109
105
|
this.camera.position.set(cameraPos.x, cameraPos.y, cameraPos.z)
|
|
110
|
-
this.camera.lookAt(
|
|
111
|
-
this.targetPos.x + 0.5,
|
|
112
|
-
this.targetPos.y + 1,
|
|
113
|
-
this.targetPos.z + 0.5
|
|
114
|
-
)
|
|
106
|
+
this.camera.lookAt(this.targetPos.x + 0.5, this.targetPos.y + 1, this.targetPos.z + 0.5)
|
|
115
107
|
this.controls.update()
|
|
116
108
|
this.syncCameraToBackend()
|
|
117
109
|
}
|
|
@@ -11,4 +11,4 @@ export { default as highPosEntityUpdates } from './highPosEntityUpdates'
|
|
|
11
11
|
// export { default as frequentUpdates } from './frequentUpdates'
|
|
12
12
|
// export { default as slabsOptimization } from './slabsOptimization'
|
|
13
13
|
// export { default as allEntities } from './allEntities'
|
|
14
|
-
export { default as
|
|
14
|
+
export { default as partialBlockCulling } from './partialBlockCulling'
|
|
@@ -7,7 +7,7 @@ import { WorldRendererThree } from '../../viewer/three/worldrendererThree'
|
|
|
7
7
|
export default class extends BasePlaygroundScene {
|
|
8
8
|
continuousRender = true
|
|
9
9
|
|
|
10
|
-
override setupWorld
|
|
10
|
+
override setupWorld(): void {
|
|
11
11
|
viewer.world.mesherConfig.enableLighting = true
|
|
12
12
|
viewer.world.mesherConfig.skyLight = 0
|
|
13
13
|
this.addWorldBlock(0, 0, 0, 'stone')
|
|
@@ -21,20 +21,26 @@ export default class extends BasePlaygroundScene {
|
|
|
21
21
|
worldView?.world.setBlockLight(this.targetPos.offset(1, 1, 1), 15)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
override renderFinish
|
|
24
|
+
override renderFinish(): void {
|
|
25
25
|
viewer.scene.background = new THREE.Color(0x00_00_00)
|
|
26
26
|
// starfield and test entities
|
|
27
27
|
;(viewer.world as WorldRendererThree).starField.enabled = true
|
|
28
28
|
;(viewer.world as WorldRendererThree).starField.addToScene()
|
|
29
|
-
viewer.entities.update(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
viewer.entities.update(
|
|
30
|
+
{
|
|
31
|
+
id: 0,
|
|
32
|
+
name: 'player',
|
|
33
|
+
pos: this.targetPos.clone()
|
|
34
|
+
} as any,
|
|
35
|
+
{}
|
|
36
|
+
)
|
|
37
|
+
viewer.entities.update(
|
|
38
|
+
{
|
|
39
|
+
id: 1,
|
|
40
|
+
name: 'creeper',
|
|
41
|
+
pos: this.targetPos.offset(1, 0, 0)
|
|
42
|
+
} as any,
|
|
43
|
+
{}
|
|
44
|
+
)
|
|
39
45
|
}
|
|
40
46
|
}
|