Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New realisation of renderer on WebGPU (webgpu.mcraft.fun) #120

Open
wants to merge 359 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
359 commits
Select commit Hold shift + click to select a range
ae4618b
fix basic world opening, wip export tiles
zardoy Jun 24, 2024
2ea730e
huge work by ilya. again.
zardoy Jul 9, 2024
92afdf5
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Jul 10, 2024
c9b1a9e
refactor webgpu renderer
zardoy Jul 10, 2024
16d4f5d
fix build
zardoy Jul 18, 2024
8e7d7b9
wip compute pipeline: indirect draw
zardoy Jul 18, 2024
de8e3de
Working compute shader
sa2urami Jul 30, 2024
e62b4d8
Passtrough of cubes
sa2urami Jul 31, 2024
2dfd179
Merge remote-tracking branch 'origin/next' into webgpu-true-fresh
zardoy Jul 31, 2024
7d3c046
Merge remote-tracking branch 'origin/next' into webgpu-tree-fresh
zardoy Aug 1, 2024
c23075b
Working frustrum culling
sa2urami Aug 2, 2024
b34a637
typo fix
sa2urami Aug 2, 2024
aba18dc
Small fixes for mobile platform
sa2urami Aug 2, 2024
c01f818
fix make it work
zardoy Aug 2, 2024
eeca0e6
Merge branch 'webgpu-true' into webgpu-tree-fresh
zardoy Aug 2, 2024
d46a475
effective updates & fov
zardoy Aug 2, 2024
7be450d
a bit bigger oversize
zardoy Aug 2, 2024
e3e69fa
impl tint, a bit faster load
zardoy Aug 4, 2024
2654a63
dynamic number of cubes
zardoy Aug 4, 2024
618d95f
disable removal for now
zardoy Aug 4, 2024
a02605d
optimize mesher for preflat!
zardoy Aug 5, 2024
1001300
add dummy optimization
zardoy Aug 15, 2024
7f60ead
Proper oversize
sa2urami Aug 15, 2024
bbb2e90
Merge branch 'webgpu-true' of https://github.com/sa2urami/prismarine-…
sa2urami Aug 15, 2024
abb9d53
change background color
zardoy Sep 3, 2024
c0ac938
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Sep 3, 2024
cf8a5aa
fix some types
zardoy Sep 3, 2024
bc493a4
fix lint
zardoy Sep 3, 2024
744f4d0
chore: remove unused globals.d.ts file
zardoy Sep 3, 2024
46db302
Second camera and preparation for data optimization
sa2urami Sep 3, 2024
5d4bcc4
fix lints
zardoy Sep 4, 2024
963e587
tweak updates
zardoy Sep 4, 2024
0d98c94
noy w compacting
sa2urami Sep 4, 2024
3e8f94f
Fixes for compacting,, fixes for texture color
sa2urami Sep 9, 2024
7b9f903
fix build and pick texture change
zardoy Sep 9, 2024
0ead63b
should fix build
zardoy Sep 9, 2024
b886559
Merge remote-tracking branch 'sa2urami/webgpu-compact' into webgpu-true
zardoy Sep 9, 2024
97be12d
MSAA and luggy context
sa2urami Sep 9, 2024
7b77f12
remove nullRenderer
zardoy Sep 10, 2024
0b5050f
fix very stupid memory leak
zardoy Sep 10, 2024
b504404
fix again
zardoy Sep 10, 2024
1396031
msaa temporarily off, index optimization.
sa2urami Sep 10, 2024
3cec6e4
Fix for second camera
sa2urami Sep 10, 2024
558a9e2
fix mobile controls
zardoy Sep 10, 2024
095825d
add params to renderer
zardoy Sep 10, 2024
d134f75
no code duplication
zardoy Sep 10, 2024
3e320e6
Toggle acting in calss
sa2urami Sep 10, 2024
b5114be
Merge branch 'webgpu-compact' of https://github.com/sa2urami/prismari…
sa2urami Sep 10, 2024
c8b4651
even less duplication
zardoy Sep 10, 2024
790fa11
restore sizse
zardoy Sep 10, 2024
f70f940
move playground to rsbuild! now fast reloads!
zardoy Sep 10, 2024
d9e84df
reload on workers change
zardoy Sep 10, 2024
cf945d8
Small fixes
sa2urami Sep 10, 2024
f42bad6
Merge branch 'webgpu-compact' of https://github.com/sa2urami/prismari…
sa2urami Sep 10, 2024
b12c919
fix cd
zardoy Sep 10, 2024
309608e
move 2nd down camera, add option, and fix select
zardoy Sep 10, 2024
bbfd38f
use only one thread in safari!!!
zardoy Sep 11, 2024
a1e1670
Merge remote-tracking branch 'origin/next' into webgpu-compact
zardoy Sep 11, 2024
b0e8f08
disable adjustnent updates
zardoy Sep 11, 2024
0f14d02
skip adding data
zardoy Sep 11, 2024
a66525d
Merge pull request #1 from sa2urami/webgpu-compact
sa2urami Sep 11, 2024
37a7229
[skip ci] prepare for new storage format
zardoy Oct 17, 2024
501c658
Co-authored-by: Vitaly <[email protected]>
sa2urami Oct 17, 2024
b722075
done
sa2urami Oct 17, 2024
4f418bf
fsdafasdfsadf
sa2urami Oct 18, 2024
c15b405
Rap
sa2urami Oct 18, 2024
5be5877
Done again
sa2urami Oct 18, 2024
3675d3a
Indexes now bigger
sa2urami Oct 19, 2024
2f8da5b
Merge remote-tracking branch 'origin/next' into webgpu-update-playground
zardoy Oct 19, 2024
7ddf77a
Merge remote-tracking branch 'sa2urami/webgpu-true' into webgpu-updat…
zardoy Oct 19, 2024
1fcf24c
finish playground code!
zardoy Oct 19, 2024
64aabc3
up lockfile
zardoy Oct 19, 2024
0ce76ba
add real world case
zardoy Oct 19, 2024
cca6cb2
Fixed indexes
sa2urami Oct 19, 2024
97dd35c
Something wrong with data generation/ If cubes more than total pointe…
sa2urami Oct 19, 2024
93586a9
a lot of code cleanup, fix playgorund world sync! fix updates and oth…
zardoy Oct 19, 2024
8e3cfe7
faster chunks init in real demo
zardoy Oct 20, 2024
b642336
normalize camera movement direction in BasePlaygroundScene for smooth…
zardoy Oct 21, 2024
b1ab92f
Co-authored-by: Vitaly <[email protected]>
sa2urami Oct 21, 2024
bcc8f08
fix & enable chunk updates, more scenes
zardoy Oct 22, 2024
fc7bcd2
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Oct 22, 2024
a0019df
tint normalize
sa2urami Oct 22, 2024
bd3b06d
Merge branch 'webgpu-true' of https://github.com/sa2urami/prismarine-…
sa2urami Oct 22, 2024
d8e6e7f
fix update issues in chunks storage and improve chunk loading logic f…
zardoy Oct 22, 2024
e749fbb
Merge branch 'webgpu-true' of https://github.com/sa2urami/prismarine-…
zardoy Oct 22, 2024
1b98622
fix bug with worker was not used
zardoy Oct 22, 2024
bd24709
test
zardoy Oct 22, 2024
9621179
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Oct 22, 2024
985de70
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Oct 22, 2024
9d07572
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Oct 22, 2024
36ff493
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Oct 22, 2024
ca7e81d
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Oct 22, 2024
79764b1
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Oct 22, 2024
d444be9
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Oct 22, 2024
d7cd9fd
try checking there
zardoy Oct 22, 2024
6b7b858
ok it works
zardoy Oct 22, 2024
ebf6681
alias
zardoy Oct 22, 2024
7ba0df2
3
zardoy Oct 22, 2024
a310b5e
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Oct 22, 2024
f06f0f9
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Oct 22, 2024
63d0ca2
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Oct 22, 2024
c2c384d
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Oct 22, 2024
46838e8
worker auto mode
zardoy Oct 22, 2024
cf97ed2
add debug buffer
zardoy Oct 24, 2024
e0fd48a
fix: fix important issue with buffers edit
zardoy Oct 24, 2024
7a8b6ad
trye to fix updates
zardoy Oct 24, 2024
fe0683a
sdafasdf
sa2urami Oct 24, 2024
81e470c
Merge branch 'webgpu-true' of https://github.com/sa2urami/prismarine-…
sa2urami Oct 24, 2024
535fea6
add layers
zardoy Oct 24, 2024
64376ed
stop any updates
zardoy Oct 24, 2024
4caf2cd
important fixes
zardoy Oct 25, 2024
6a7996a
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Oct 29, 2024
ab51d95
display renderer errors
zardoy Nov 1, 2024
8caa041
Working occlusion culling, regrettebly without locks and depth checking
sa2urami Nov 1, 2024
7d60bff
Merge branch 'webgpu-true' of https://github.com/sa2urami/prismarine-…
sa2urami Nov 1, 2024
e316eea
fix webgpu params set, cleanup duplicated logic, working actions menu…
zardoy Nov 1, 2024
e2f3286
format wgsl
zardoy Nov 1, 2024
bdf7164
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Nov 1, 2024
2fb9b90
fsdfsdf
sa2urami Nov 1, 2024
6e61ebe
Merge branch 'webgpu-true' of https://github.com/sa2urami/prismarine-…
sa2urami Nov 1, 2024
f56cbcb
fix merge conflict
zardoy Nov 2, 2024
04c9fa0
playground add T keybinding for Y tp
zardoy Nov 2, 2024
e2d426d
NO textures. Another startegy try
sa2urami Nov 3, 2024
db95d11
No for loops in compute
sa2urami Nov 4, 2024
3710d0c
fix
sa2urami Nov 4, 2024
d045fe8
Fix for one block
sa2urami Nov 4, 2024
28758ca
add screen size buffer
zardoy Nov 4, 2024
0a184bc
fix disabling chunk updates
zardoy Nov 4, 2024
0252acc
use texture size in sort shader
zardoy Nov 4, 2024
a9d957e
workaround for allChunksLoaded bug
zardoy Nov 4, 2024
81adbf8
oversize proper
sa2urami Nov 5, 2024
44d68ea
Merge branch 'webgpu-true' of https://github.com/sa2urami/prismarine-…
sa2urami Nov 5, 2024
3553e05
report data size
zardoy Nov 25, 2024
97392fa
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Nov 26, 2024
985b6fe
small fixes
zardoy Nov 26, 2024
9164430
implement faces storage
zardoy Nov 27, 2024
ac111a8
disable opacity
zardoy Nov 27, 2024
373b965
do not use rotation and instead use lookAt to avoid mirroring initial…
zardoy Nov 28, 2024
cb1af9e
quads
sa2urami Dec 2, 2024
d7fb417
Merge branch 'webgpu-true' of https://github.com/sa2urami/prismarine-…
sa2urami Dec 2, 2024
b83e2cd
no flickering
sa2urami Dec 2, 2024
642c37d
Refactor
sa2urami Dec 2, 2024
2511a52
[to pick] fix racing condition load check, fix actual number in scene…
sa2urami Dec 2, 2024
5526b4d
add block model data integration
zardoy Dec 2, 2024
5e350c1
improve data debug display
sa2urami Dec 2, 2024
3bbad05
Fixes
sa2urami Dec 3, 2024
d763650
all models working, fix sides
zardoy Dec 3, 2024
980327a
small fixes
sa2urami Dec 3, 2024
087b58c
Merge branch 'webgpu-sides' of https://github.com/sa2urami/prismarine…
sa2urami Dec 3, 2024
79c40dc
fix sides
zardoy Dec 3, 2024
fa5b492
random blocks
zardoy Dec 3, 2024
2d080bf
fix preflat
zardoy Dec 3, 2024
9721dee
fix preflat
zardoy Dec 3, 2024
020ee27
Merge branch 'webgpu-sides' into webgpu-true
sa2urami Dec 3, 2024
c2e05fe
fix
sa2urami Dec 3, 2024
ef3f847
refactor
sa2urami Dec 3, 2024
f91ca19
[skip ci] [broken] use new storage
zardoy Dec 3, 2024
616d235
small important fixes, add blocks mapping
zardoy Dec 3, 2024
e3968b2
add layers
zardoy Dec 3, 2024
d1549fd
fix negative chunks display
zardoy Dec 3, 2024
e676ac8
Model buffer incrased to 16384, Heigh now 10 bits
sa2urami Dec 4, 2024
2c7e38a
Default Rotations
sa2urami Dec 4, 2024
71c13fe
fix display all models, suppress current problems, enable color! and …
zardoy Dec 4, 2024
d1d25ea
[skip ci] move reporter below
zardoy Dec 4, 2024
74a8271
Mapping of how many quads are now drawn
sa2urami Dec 4, 2024
44c337f
Merge branch 'webgpu-true' of https://github.com/sa2urami/prismarine-…
sa2urami Dec 4, 2024
fa1daf6
use robust chunk value
zardoy Dec 4, 2024
0b90dc5
Real cullfaces
sa2urami Dec 4, 2024
de20a94
Merge branch 'webgpu-true' of https://github.com/sa2urami/prismarine-…
sa2urami Dec 4, 2024
f6e7b83
Slightly less flickering
sa2urami Dec 4, 2024
6a7b3c5
Smaller oversize. Current chunkn always visible
sa2urami Dec 4, 2024
65f9c46
Waiting for renderer fix
sa2urami Dec 4, 2024
b12560a
[skip ci] refactor get rendering count
zardoy Dec 4, 2024
f59ff5a
get rendering tiles without blocking loop
zardoy Dec 4, 2024
0a2430c
disable opacity
zardoy Dec 4, 2024
b0a2ffe
print debug info!
zardoy Dec 4, 2024
e820621
[skip ci] gen impr, buf ch n n n
zardoy Dec 4, 2024
9af459c
Revert "Slightly less flickering" so it works in safari
zardoy Dec 4, 2024
c8d3087
newStats fix
zardoy Dec 4, 2024
9794847
to pick: add ping display on mobile & via f3, playground ui improvements
zardoy Dec 4, 2024
912cf73
fix all known issues with chunk storage, cover with test, remove data…
zardoy Dec 5, 2024
51561b6
ww
zardoy Dec 5, 2024
3da0e68
fix l check
zardoy Dec 5, 2024
36daed9
limit data updates
zardoy Dec 5, 2024
12df1f2
revertm
zardoy Dec 5, 2024
4fffd67
Camera in block fix
sa2urami Dec 5, 2024
2ed8b82
add unknown blocks
zardoy Dec 5, 2024
8415f64
dispatch real number of cubes
zardoy Dec 5, 2024
052f6e0
fix clipping
zardoy Dec 6, 2024
8a737c5
Refactor cube visibility check for better performance
zardoy Dec 6, 2024
b1f9ccf
refactor storage, clear unused data
sa2urami Dec 6, 2024
f095c13
Updated buffer
sa2urami Dec 6, 2024
a5f0c0e
mesher gpu opt, water + lava
zardoy Dec 6, 2024
03452de
use fov, fix models crash
zardoy Dec 6, 2024
c2bb7b4
use webgpu settings
zardoy Dec 6, 2024
37e7c04
refactor renderer to a single interface, implement destroying, render…
zardoy Dec 6, 2024
89ebcc3
playground fix, add light and transparent data
zardoy Dec 6, 2024
e4e53b9
(Experiment early z rejection)
sa2urami Dec 6, 2024
a9b1d86
Merge branch 'webgpu-true' of https://github.com/sa2urami/prismarine-…
sa2urami Dec 6, 2024
56757d7
fix camera crash, sync code
zardoy Dec 6, 2024
b2cb1e0
display more stats, fix gpu crash, fix negative worlds display, add 1…
zardoy Dec 7, 2024
1039448
fix possible mcdata crash, print meshers count
zardoy Dec 7, 2024
311cb3b
support power preference switch, display real webgpu gpu in f3
zardoy Dec 7, 2024
aa2058c
fix safari init
zardoy Dec 7, 2024
ce9262e
refactor
sa2urami Dec 7, 2024
2515af5
Refactor v2
sa2urami Dec 7, 2024
c4dea62
Some more fixes
sa2urami Dec 7, 2024
6b9b955
Fix some platforms crash
zardoy Dec 8, 2024
d2c0639
fix: do camera updates asap in mouse event not waiting for the main l…
zardoy Dec 8, 2024
b39f47f
update main menu!
zardoy Dec 9, 2024
e34ebaa
fix chunks rewrite, optimize tint trransfer
zardoy Dec 9, 2024
97aa385
redeploy
zardoy Dec 9, 2024
d41a9d2
extend buffer not that frequent
zardoy Dec 9, 2024
a392da4
Fix restore clearing memory
zardoy Dec 9, 2024
b6337a6
try to always use worker, show render ms pass, minor adjustments, fix…
zardoy Dec 10, 2024
3a057b6
add debug ui, minor changes
zardoy Dec 10, 2024
c5015cb
Volumetric lightning
sa2urami Dec 10, 2024
6421ff6
Merge branch 'webgpu-true' of https://github.com/sa2urami/prismarine-…
sa2urami Dec 10, 2024
e53f7f4
revert govno
sa2urami Dec 10, 2024
37db5ff
fix a few crashes
zardoy Dec 10, 2024
b99d46e
[skip ci] fix lint
zardoy Dec 10, 2024
335c84d
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Dec 10, 2024
4e6d6ae
fix window
zardoy Dec 10, 2024
393eaa5
Background as it is
sa2urami Dec 10, 2024
7245052
fix possible race condition crash on initial load
zardoy Dec 10, 2024
97ae5f2
implement cursor block, fix models patching in preflat, snow
zardoy Dec 11, 2024
4eb1353
Merge remote-tracking branch 'origin/next' into webgpu-true
zardoy Dec 11, 2024
96cd6b2
revert only gray tint
zardoy Dec 11, 2024
4c811a2
SSAO not good, not terrible
sa2urami Dec 11, 2024
300c2ae
Merge branch 'webgpu-true' of https://github.com/sa2urami/prismarine-…
sa2urami Dec 11, 2024
9ff04e7
fix all stats display!
zardoy Dec 11, 2024
23da795
fix frag shader
zardoy Dec 11, 2024
39e54c8
add analytics 😈
zardoy Dec 11, 2024
b50de91
Merge remote-tracking branch 'origin/next' into pr/sa2urami/120
zardoy Dec 12, 2024
92aa80d
implement god rays flag
zardoy Dec 12, 2024
9000445
Co
sa2urami Dec 13, 2024
71d8e73
a lot of useless optimizations
zardoy Dec 13, 2024
09d8aaa
g
sa2urami Dec 13, 2024
069831c
fix textures for full blocks
zardoy Dec 13, 2024
1686acd
uv in uniform
sa2urami Dec 13, 2024
ea82415
Merge branch 'webgpu-true' of https://github.com/sa2urami/prismarine-…
sa2urami Dec 13, 2024
af82c41
Chunk opacity
sa2urami Dec 13, 2024
7dde3fe
Godrays fixes
sa2urami Dec 13, 2024
5b3fde9
preserve webgpu params in options
zardoy Dec 13, 2024
da06ea7
No godray spotlight
sa2urami Dec 13, 2024
a9f30a8
Sides fix
sa2urami Dec 13, 2024
23fd25f
implement fade chunks loading! implement unloading! new setting for c…
zardoy Dec 13, 2024
67e5024
Rewrite of oldVisibleCubes
sa2urami Dec 13, 2024
c89c42f
god rays addition
sa2urami Dec 13, 2024
68b18bf
display webgpu info, a bit better perf
zardoy Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"@stylistic"
],
"rules": {
"unicorn/no-typeof-undefined": "off",
// style
"@stylistic/space-infix-ops": "error",
"@stylistic/no-multi-spaces": "error",
Expand Down
20 changes: 19 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,25 @@
"outFiles": [
"${workspaceFolder}/dist/**/*.js",
// "!${workspaceFolder}/dist/**/*vendors*",
"!${workspaceFolder}/dist/**/*mc-data*",
"!**/node_modules/**"
],
"skipFiles": [
// "<node_internals>/**/*vendors*"
"<node_internals>/**/*mc-data*"
],
},
{
// not recommended as in most cases it will slower as it launches from extension host so it slows down extension host, not sure why
"type": "chrome",
"name": "Launch Chrome (playground)",
"request": "launch",
"url": "http://localhost:9090/",
"pathMapping": {
"/": "${workspaceFolder}/prismarine-viewer/dist"
},
"outFiles": [
"${workspaceFolder}/prismarine-viewer/dist/**/*.js",
// "!${workspaceFolder}/dist/**/*vendors*",
"!**/node_modules/**"
],
"skipFiles": [
Expand Down
14 changes: 12 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,20 @@
},
},
{
"label": "viewer server+esbuild",
"label": "webgl-worker",
"type": "shell",
"command": "node buildWorkers.mjs -w",
"problemMatcher": "$esbuild-watch",
"presentation": {
"reveal": "silent"
},
},
{
"label": "viewer server+esbuild+workers",
"dependsOn": [
"viewer-server",
"viewer-esbuild"
"viewer-esbuild",
"webgl-worker"
],
"dependsOrder": "parallel",
}
Expand Down
109 changes: 109 additions & 0 deletions buildWorkers.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
//@ts-check
// main worker file intended for computing world geometry is built using prismarine-viewer/buildWorker.mjs
import { build, context } from 'esbuild'
import fs from 'fs'
import path, { join } from 'path'
import { polyfillNode } from 'esbuild-plugin-polyfill-node'

const watch = process.argv.includes('-w')

const result = await (watch ? context : build)({
bundle: true,
platform: 'browser',
// entryPoints: ['prismarine-viewer/examples/webgpuRendererWorker.ts', 'src/worldSaveWorker.ts'],
entryPoints: ['prismarine-viewer/examples/webgpuRendererWorker.ts'],
outdir: 'prismarine-viewer/dist/',
sourcemap: watch ? 'inline' : 'external',
minify: !watch,
treeShaking: true,
logLevel: 'info',
alias: {
'three': './node_modules/three/src/Three.js',
events: 'events', // make explicit
buffer: 'buffer',
'fs': 'browserfs/dist/shims/fs.js',
http: 'http-browserify',
perf_hooks: './src/perf_hooks_replacement.js',
crypto: './src/crypto.js',
stream: 'stream-browserify',
net: 'net-browserify',
assert: 'assert',
dns: './src/dns.js'
},
plugins: [
{
name: 'writeOutput',
setup (build) {
build.onEnd(({ outputFiles }) => {
fs.mkdirSync('prismarine-viewer/public', { recursive: true })
fs.mkdirSync('dist', { recursive: true })
for (const file of outputFiles) {
for (const dir of ['prismarine-viewer/dist', 'dist']) {
const baseName = path.basename(file.path)
fs.mkdirSync(dir, { recursive: true })
fs.writeFileSync(path.join(dir, baseName), file.contents)
}
}
})
}
},
{
name: 'fix-dynamic-require',
setup (build) {
build.onResolve({
filter: /1\.14\/chunk/,
}, async ({ resolveDir, path }) => {
if (!resolveDir.includes('prismarine-provider-anvil')) return
return {
namespace: 'fix-dynamic-require',
path,
pluginData: {
resolvedPath: `${join(resolveDir, path)}.js`,
resolveDir
},
}
})
build.onLoad({
filter: /.+/,
namespace: 'fix-dynamic-require',
}, async ({ pluginData: { resolvedPath, resolveDir } }) => {
const resolvedFile = await fs.promises.readFile(resolvedPath, 'utf8')
return {
contents: resolvedFile.replace("require(`prismarine-chunk/src/pc/common/BitArray${noSpan ? 'NoSpan' : ''}`)", "noSpan ? require(`prismarine-chunk/src/pc/common/BitArray`) : require(`prismarine-chunk/src/pc/common/BitArrayNoSpan`)"),
resolveDir,
loader: 'js',
}
})
}
},
polyfillNode({
polyfills: {
fs: false,
dns: false,
crypto: false,
events: false,
http: false,
stream: false,
buffer: false,
perf_hooks: false,
net: false,
assert: false,
},
})
],
loader: {
'.vert': 'text',
'.frag': 'text',
'.wgsl': 'text',
},
mainFields: [
'browser', 'module', 'main'
],
keepNames: true,
write: false,
})

if (watch) {
//@ts-ignore
await result.watch()
}
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": 1,
"defaultHost": "<from-proxy>",
"defaultProxy": "proxy.mcraft.fun",
"mapsProvider": "https://maps.mcraft.fun/",
"mapsProvider": "https://maps.mcraft.fun/?label=webgpu",
"peerJsServer": "",
"peerJsServerFallback": "https://p2p.mcraft.fun",
"promoteServers": [
Expand Down
25 changes: 25 additions & 0 deletions cypress/e2e/performance.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { cleanVisit, setOptions } from './shared'

it('Loads & renders singleplayer', () => {
cleanVisit('/?singleplayer=1')
setOptions({
renderDistance: 2
})
// wait for .initial-loader to disappear
cy.get('.initial-loader', { timeout: 20_000 }).should('not.exist')
cy.window()
.its('performance')
.invoke('mark', 'worldLoad')

cy.document().then({ timeout: 20_000 }, doc => {
return new Cypress.Promise(resolve => {
doc.addEventListener('cypress-world-ready', resolve)
})
}).then(() => {
const duration = cy.window()
.its('performance')
.invoke('measure', 'modalOpen')
.its('duration')
cy.log('Duration', duration)
})
})
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
"scripts": {
"dev-rsbuild": "rsbuild dev",
"dev-proxy": "node server.js",
"start": "run-p dev-proxy dev-rsbuild watch-mesher",
"start2": "run-p dev-rsbuild watch-mesher",
"start": "run-p dev-rsbuild dev-proxy watch-mesher watch-other-workers",
"start2": "run-p dev-rsbuild watch-mesher watch-other-workers",
"build": "pnpm build-other-workers && rsbuild build",
"build-analyze": "BUNDLE_ANALYZE=true rsbuild build && pnpm build-other-workers",
"check-build": "tsx scripts/genShims.ts && tsc && pnpm build",
"test:cypress": "cypress run",
"test:cypress:perf": "cypress run --spec cypress/e2e/perf.spec.ts --browser edge",
"test-unit": "vitest",
"test:e2e": "start-test http-get://localhost:8080 test:cypress",
"prod-start": "node server.js --prod",
Expand All @@ -19,12 +20,13 @@
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build && node scripts/build.js moveStorybookFiles",
"start-experiments": "vite --config experiments/vite.config.ts --host",
"watch-other-workers": "echo NOT IMPLEMENTED",
"build-other-workers": "echo NOT IMPLEMENTED",
"watch-other-workers": "node buildWorkers.mjs -w",
"build-other-workers": "node buildWorkers.mjs",
"build-mesher": "node prismarine-viewer/buildMesherWorker.mjs",
"watch-mesher": "pnpm build-mesher -w",
"run-playground": "run-p watch-mesher watch-other-workers watch-playground",
"run-all": "run-p start run-playground",
"run-all2": "run-p start2 run-playground",
"build-playground": "rsbuild build --config prismarine-viewer/rsbuild.config.ts",
"watch-playground": "rsbuild dev --config prismarine-viewer/rsbuild.config.ts"
},
Expand All @@ -47,11 +49,13 @@
"@nxg-org/mineflayer-auto-jump": "^0.7.12",
"@nxg-org/mineflayer-tracker": "1.2.1",
"@react-oauth/google": "^0.12.1",
"@rsbuild/plugin-basic-ssl": "^1.1.1",
"@stylistic/eslint-plugin": "^2.6.1",
"@types/gapi": "^0.0.47",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
"@types/wicg-file-system-access": "^2023.10.2",
"@webgpu/types": "^0.1.44",
"@xmcl/text-component": "^2.1.3",
"@zardoy/react-util": "^0.2.4",
"@zardoy/utils": "^0.0.11",
Expand Down Expand Up @@ -102,6 +106,7 @@
"stats.js": "^0.17.0",
"tabbable": "^6.2.0",
"title-case": "3.x",
"twgl.js": "^5.5.4",
"ua-parser-js": "^1.0.37",
"use-typed-event-listener": "^4.0.2",
"valtio": "^1.11.1",
Expand Down Expand Up @@ -142,7 +147,7 @@
"http-browserify": "^1.7.0",
"http-server": "^14.1.1",
"https-browserify": "^1.0.0",
"mc-assets": "^0.2.23",
"mc-assets": "^0.2.25",
"minecraft-inventory-gui": "github:zardoy/minecraft-inventory-gui#next",
"mineflayer": "github:zardoy/mineflayer",
"mineflayer-pathfinder": "^2.4.4",
Expand Down
Loading
Loading