Creating a cannon with Cannon.js

Had an idea to create a cannon with shooting cannon balls using Cannon.js (confusing sentence I know).
I’m very new to THREE.js so I’m struggling a little bit. All of the tutorials online have shooting physics working like a first person game shooting from the rotation of the camera to a point (guessing raycasted). I’m need to shoot in the direction the cannon is facing which I don’t understand how to do.

If anyone has a link to any resources or tutorials I would greatly appreciate it!

Why do you want to use a physics engine for this use case?

To add gravity and rigidbody to the cannonball. Also to move it using velocity over just moving the transform.

I’m asking because for basic concepts like velocity or gravity a physics engine is overkill. Some three.js examples use basic math for realizing both concepts in a straightforward and performant manner. E.g.

https://threejs.org/examples/misc_controls_pointerlock
https://threejs.org/examples/webxr_vr_ballshooter

1 Like