Ballistics extension


Project
Live demo
Sources on Github
Grab me a coffee image :slight_smile:

This extension helps to answer one common question - “What impulse should I give to my projectile so that it would hit the target?”

You can provide input values, like the speed of your projectile, or the maximum height the projectile should fly to, and the extension will reply you with the calculated impulse vector (or a few even).

How to install:
Simply drag and drop Ballistics folder from the project and wait for ballistics:ready event. The example has 4 different cannons set up, each using a different method of the extension, that you can apply, based on your own use case.

Features:

  • All heavy math is moved to WASM binary
  • Allows to calculate impulses against not only static, but also moving targets, providing a preemtive impulse.
  • Provides a point in world space where the projectile will hit the target in the future, when the target is moving.

API:
Please, refer to the Wiki on Github repository.

TODO:

  • Fix the project example environemnt assets, like light leaking in geometry or use an equirectangular cubemap for IBL, etc.
  • No changes to the library, though, so it can be used as is.
8 Likes

Wow @LeXXik, that is super useful and also seems super polished.

Many thanks for sharing!

I’d be very curious what speed improvements you observed with the math side running on WASM, if you have data on this.

1 Like

I only did a simple test with the heaviest method .solveLateralMoving() in NodeJS, which runs Javascript a little faster in some cases, so in browser it could be even slower. Haven’t tried in browser, but anyone interested can do additional tests, after I push it to Github.

WASM average 10-50k ns (~ 0.01 - 0.05 ms)
JS average 600k - 2.5kk ns (~0.6 - 2.5 ms)

4 Likes

Posted sources to Github: repository