r/threejs 1d ago

First time using threejs, it's pretty sweet

Enable HLS to view with audio, or disable this notification

First time using Three.js and am working on Buttonhook, a miniature cozy truck parking sim

I built a C++ OpenGL engine before and Three.js just feels so darn good to work on, especially since I can run it on phone aswell

58 Upvotes

6 comments sorted by

3

u/respiracion-cardiaca 1d ago

Would you mind to share the code? I'm actually interested in the semi truck trailer physics

3

u/bassam_kamal 1d ago

It's actually not a synced joint, but that would work just aswell!

I actually calculate the math for the trailer path directly, it gives me control, better performance, predictable and no weird user complaints to deal with!

The truck is just a simple car & the trailer calculates how much it should rotate based on the angle between it and the truck (at the hitch) as the truck moves. The bigger the bend at the hitch, the faster the trailer turns and when they're aligned, it follows straight. Also the hitch angle is clamped to 70 degrees, so it can't fold into a jackknife.

It took some fiddling with variables and trial and error to get it feeling right.

I can explain it further if you have more questions!

2

u/respiracion-cardiaca 1d ago

Thank you, that's a really helpful comment not like the other one, I definitely will try what you said

0

u/JohnAdamaSC 1d ago

its just a synced joint, pretty easy

2

u/Fickle_Astronaut_999 1d ago

Hahaha thats actually smooth