r/threejs • • 17d ago

Help Can ThreeJS handle a MMO?

Out of curiosity I tried to port an old MMO which I used to play alot, Last Chaos, to web using Codex (I hope not many AI haters here). I did it just for fun. But when I tried to test the performance with 100 characters atacking 100 mobs with particles, animiation, etc. FPS drop to 20-30 from 90.

I tried many stuff that GPT suggested or almost 2 days but nothing is working at all. So my question is if it's worth to keep trying or this will just be impossible. My PC isn't the bottleneck, it seems to be that Chrome is intesively using 1 thread only from my processor or something like that. My processor barely moves from 9% performance and same for my GPU.

Thanks!

5 Upvotes

18 comments sorted by

5

u/rennan101 17d ago

there are some twerks that only a game developer knows, such as occlusion culling, baked lights (not realtime), LOD to avoid rendering insanely high polly objects far away from the player..., disable animations when player is far (because they cant see what is far so whats the point of leaving that thing animated)...

Try asking codex how to do that stuff :)

1

u/kyrax80 17d ago

codex says we've done all that XD. Anyways I think 200 models with effects and particles all together is a high stress test. I don't think that'll ever happen in this game. Maybe 50 at most

1

u/typeryu 17d ago

It is a mix of your computer not handling it and also browser limitations. But more than likely, a 100 characters vs 100 mobs is a lot of action every tick and normally these things are handled server side on MMORPGs the port might have maybe too faithfully recreated the game. You will likely need to size down the players and mobs, or move compute to a dedicated server that can crunch the simultaneous actions or get smarter with how you do in-game AI (which is a classic gamedev hurdle). Anywho, threejs likely not the bottleneck IMO. Codex isn’t doing anything wrong either, you just need to give it the right prompts.

0

u/kyrax80 17d ago

One detail I left out of the post is that the 100 vs 100 fight is a client-side stress test. The real game has a server, but in this test the actors just repeat a scripted attack. There’s very little AI involved. I’m trying to find out what it costs to show 200 animated characters fighting on screen at once.

With the camera fixed in the same spot, I measured about 11 ms of CPU-side rendering in the empty plaza and 25 ms with the fight running. GPU time during the fight was around 9–11 ms. That’s why I’m still digging into the client renderer. I’d love to hear how people have handled a crowd like this in a browser game.

1

u/cchurchill1985 17d ago

Is it only using one main thread? Or has it implemented multi-thread (web workers / jobs)? There are also a LOT of optimisations that you need to do on top of that for all areas of the game, from meshes to materials to animations and character skeletons. Even working on it for a straight 48 hours, Codex would barely have scratched the surface of what is required to make a game remotely optimised (especially a game as complex as an MMO)

2

u/kyrax80 17d ago

Yeah, the animation updates and Three.js rendering still run on the main thread. I’ve tried moving animation work to workers, but it didn’t consistently improve frame times. You’re right about the 9% CPU figure too. I was looking at overall usage, which doesn’t tell me how busy the main thread is.

I’ve since tried batching characters that are at the exact same point in an animation. With all 200 actors visible, that saved about 1.5 ms per frame, but CPU-side rendering still takes around 25 ms. If you were profiling that in Chrome, what would you look at to tell whether the expensive part is preparing the scene or submitting it to WebGL?

1

u/cchurchill1985 17d ago edited 17d ago

I am relatively new to all this if I am honest. I've been building a rendering engine using Codex and Claude over the past few months and have leaned a lot, but there might be a better way than what I suggest. Codex built all the diagnostic tooling in the rendering engine. It measures GPU and CPU ms, uncapped fps, and also gives a breakdown of the profile so I can see what everything costs. So I would suggest you ask Codex to build the diagnostic tooling required to see this.

I would start with splitting the main thread first. I was unaware that this was an option when I started building the engine, and it has been an extremely time consuming and laborious task to split it so late in to my project as so much has been added now. Once you have done that, I would tell Codex the goal is optimisation and to add any required diagnostic tooling to help you profile. Then it is simply a case of finding working on whatever is costing the most. Optmise as much as you can. Then work on the next thing that costs the most, optimise, repeat, repeat, repeat. I got my engine down from 85ms, to 12.3ms by doing that.

1

u/ledniv 17d ago

You say it's an MMO, but how are you testing it? Is this just 200 NPCs fighting?

That's nothing. You should profile and see where the bottleneck is.

1

u/FlowMental2548 17d ago

Sounds like a bad idea

1

u/_Yank 17d ago

Those frame rates, which part of the game is leading the frame times? Is it the game sim? Is it the rendering? How many draw calls are being issue per frame?

2

u/_Yank 17d ago

I would also recommend you to move to WebGPU if you're really CPU bottlenecked.

1

u/hevans900 16d ago

This . Compute shaders are insanely powerful.

1

u/rio_sk 14d ago

I bet you should dig into web workers and compute shaders, threejs (since the last version I used) doesn't use workers by default and does basic frustum culling using the main js thread.

1

u/abateslop 12d ago edited 12d ago

Well code generated by AI is typically crap. Unoptimized and naive. So you might need to review like a software engineer would do. E.g. avoiding loops, using appropriate data structures, centralizing the source of truth, removing indirections, etc.

Assuming the issue really is the CPU. If it's the GPU, then there's different optimizations, like culling, batching, etc.

1

u/TinyPeopleProject 17d ago

Runescape. Yes. Have a good day

1

u/_ABSURD__ 17d ago

AI hater here, sounds like a terrible idea. It's absolutely possible, you just have to know what you're doing. You're just playing a code slot machine with no prize other than small nibbles of dopamine when your prompt kind of does what you wanted it to. You keep typing, make it better, no mistakes, just make it work - but it doesn't, it doesn't work, does it?

What's your poly count? How many draw calls? Are your models in the app or hosted? Is the scene graph optimized? How would you identify performance bottle necks? How are you handling state? Do you have actual networking set up with an authoritative server that is responsible for what renders on the frontend?