Three.js + Cannon.js Tutorial (part 2/2) | Rigid Vehicle Physics Example

Опубликовано: 29 Март 2025
на канале: Suboptimal Engineer
14,153
334

In this coding tutorial, we go over a car example in Three.js to get a better understanding of how Cannon.js physics works. We start off by initializing the physics world and adding a rigid vehicle to it. Then we add wheels to the car and ensure that it is moving in accordance with the physics world. After that, we set up event listeners that apply forces to the vehicle based on user inputs. Finally, we sync the Three.js game world with the Cannon.js physics world.

📖 Code - https://github.com/SuboptimalEng/thre...

🎥 YouTube -    / suboptimaleng  
💻 GitHub - https://github.com/SuboptimalEng
🐦 Twitter -   / suboptimaleng  
🧵 Threads - https://www.threads.net/@suboptimaleng
📸 Instagram -   / suboptimaleng  

== [ Resources ] ==
Three.js - https://threejs.org
Cannon.js - https://pmndrs.github.io/cannon-es
Rigid Vehicle - https://github.com/pmndrs/cannon-es/b...

== [ Timestamps ] ==
00:00 Intro Three.js Physics
00:41 Cannon.js Setup Guide
01:56 Initialize Rigid Vehicle
03:01 Add Wheels to Car
05:04 Confirm Car Physics Works
05:37 Add Controls to Physics Body
07:52 Sync Three.js with Cannon.js

== [ Tags ] ==
#suboptimal #threejs #gamedev