Recently I took up a project to put capsules into babylon.js! After seeing them in Unity(they are the default first person character) I wanted to make a simple function to help me and others make capsules.
The playground can be found here. I’ve annotated the whole thing for your understanding! Lines 21-80 make and explain the capsule, with lines 82-92 making it spin and make a transparent sphere. The transparent sphere was used to make comparisons with the capsule to fine-tune the height and width adjustments. Feel free to mess around with the capsule values to see if you can break it! At certain values it will make a sphere, so I adjusted for that. If anybody was to ever unknowingly do so, it will only make a single sphere to spec instead of the 2 used to make the capsule. The transform node can be moved and rotated to your heart’s content after creation.
Here is a non-annotated version for easy copying. Lines 22-54 make the capsule.
Feel free to use wherever, whenever! (Credit prefered)
Hope it is useful! Givo