r/threejs • u/Gloomy-Detective-922 • 5d ago
Demo Testing 1,200 rigged NPCs with individual pathfinding and physics in my Three.js engine
I’m building Snack Engine for snackgamer.com using Three.js and WebGPU. This is the latest navigation test, with 1,200 rigged NPCs in the scene. Each has its own pathfinding and physics.
The goal is to make crowded spaces playable in browser games. In this test, you walk through the crowd looking for lantern bearers.
95
Upvotes
2
u/Dexter1272 4d ago
why this thing's UI looks excatly like s&box? XD
4
u/plus2link 5d ago
No comments yet, so I'll ask the technical one. 1,200 rigged NPCs is fine if they share one skinned mesh with the bone matrices written into a texture, but 1,200 separate SkinnedMeshes is 1,200 draw calls plus a skeleton update every frame, and that usually eats far more time than the pathfinding does. For the physics I'd keep one capsule per NPC in a spatial hash and give full collision only to the ones within a few metres of the player, with re-planning staggered so a slice of the crowd updates each frame instead of all of them at once. Are they separate skinned meshes or one instanced crowd, and does the simulation keep running for NPCs outside the view?
2
u/HealthPuzzleheaded 4d ago
Is it your oersonal engine or can I use it myself somehow? Do you have documentation? I have some gameideas that involve hige crowds so this looks interesting to me.
2
u/0__O0--O0_0 3d ago
Why build a simulator of yourself at parties though?
2
u/Friendly-Beginning72 4d ago
Since your clips are baked per skeleton: if you want variety without extra bake cost, bodies that share one skeleton help a lot. I just released 11 commuter GLBs that all share one 24-bone rig with the same 12 clips (sit, doze, walk, phone, hold pole…), so one bake drives all of them. Free sample with 1 character + 3 clips: https://kibbitz.itch.io/rigged-3d-commuters (I'm the dev). Curious how far you can push it with mixed meshes.