Belén Albeza

3D collision detection for HTML 5 games

The next batch of content we've made about game development in the MDN is out! Say hi to 3D collision detection techniques.

There is one generic article focusing on axis-aligned bounding boxes and spheres intersection algorithms, which is a very simple yet very used technique. Its strongest point is that it is one of the fastest ways to detect collisions, specially if you apply some kind of filtering beforehand to avoid testing for intersections between all pairs of 3D objects.

Box vs Box test

Although the code examples are in JavaScript, the content of that article will be useful regardless of the programming language or the platform.

And we also have one more practical article about using bounding volumes with Three.js.

Besides the article, there are companion demos with available source code! One of the demos also shows using a physics engine –cannon.js– to detect collisions.

3D collision demo

I'll keep you posted on the new content we'll be creating. Until next time :)