We're creating an action MMO using Three.js (WebGL) with an arcadish feel, and implementing physics for it has been a pain in the butt.

Our game has a terrain where the character will walk on, and in the future 3D objects (a house, a tree, etc) that will have collisions. In terms of complexity, the physics engine should be like World of Warcraft. We don't need friction, bouncing behaviour or anything more complex like joints, etc. Just gravity.

I have managed to implement terrain physics so far by casting a ray downwards, but it does not take into account possible 3D objects. Note that these 3D objects need to have convex collisions, so our artists create a 3D house and the player can walk inside but can't walk through the walls.

How do I implement proper collision detection with 3D objects like in World of Warcraft? Do I need an advanced physics engine? I read about Physijs which looks cool, but I fear that it may be overkill to implement that for our game.

Also, how does WoW do it? Do they have a separate raycasting system for the terrain? Or do they treat the terrain like any other convex mesh?

A screenshot of our game so far: Ironbane MMO


2 Answers 2


You will likely need some kind of polygon collision detection and reaction. Also, you will need a way to organise it, like in a BSP tree or octree, as a lot of 3D objects will need to be culled when checking for collision or rendering to keep performance.

If this is the way you are going it is going to take a long time, not just to do but to learn if you don't know what you are doing already. The benefits are rewarding but much easier is to use an engine that has all this stuff in it already. Then you just have to learn how to use it.

Goodluck using javascript.

  • \$\begingroup\$ Thanks, I think for me it would be better if I used a premade physics engine. Just out of curiosity, why do you wish me good luck with javascript? \$\endgroup\$
    – Nick
    Jun 13, 2012 at 8:58
  • 1
    \$\begingroup\$ @Nick Probably because it has so many quirks... \$\endgroup\$ Jun 13, 2012 at 17:46

You stated that it will be a MMO game - don't do this kind of stuff client-side. You will have problems with cheaters, because it's fairly easy to modify your code so they can fly/no-clip etc.

If your terrain is heightmap-based just prepare your world so you have all of the objects inserted (houses, trees etc.) and generate some kind of mask which will exclude non-walkable places on the map. Take a look a this example for how it should look like:

example world world's mask

Then on the server-side just check if the user is not on one of the red spots, if so just move them away (or stop movement when they are about to enter one).

To generate such mask you should loop through all of your objects and get their intersections with terrain (for example raycast from every vertex below some height). At least that's how I'm doing it and it works perfectly.

Of course that will work only if your terrain is heightmap-based, so no overhangs, caves etc (you would have to modify it a bit to get it working on multiple heights).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .