Capsule Maker v1.0 and v1.1


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! :upside_down_face: 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


This is cool! It could even become a PR to add the capsule to the MeshBuilder!

1 Like

Thanks! I’m gonna work on getting textures and materials to show up correctly now. :slightly_smiling_face:

1 Like

Quick update: has an updated system, as it uses an array instead of a transform node to allow for an easier application materials. has the crate texture applied to the capsule, but it is messed up. In short, textures are not recommended but with creativity cool designs could be made. is officially version 1.1!


Here we go.

Playground versions #8 and #9 broke the movement and rotation.

In #10 I fixed it. The meshes are still merged but a transform node is still necessary for movement and rotation outside of the function!

#10 is v1.1

Right now only 1 capsule can be made and moved at a time. If you make more than 1 they will have the same position and rotation. Any ideas welcome, working on it now.



Bonus points if you are able to make it as a custom geometry buffer, and have a clean uv for the cylinder and both caps in the same space and arguments like cap subdivisions.

And these should get the creative juices going!

I’ve been thinking of doing that. This function is just a way for lazy people (like myself) to make capsules (or at the moment capsulE (no “s” if you want them to have different positions and rotations)) You have to copy it and add a number to the end of the variables to use it multiple times. As of now, I’ll work on that geometry buffer(would you like it or something?:face_with_raised_eyebrow: if so please see the second-too-last sentence in my first post :wink:). Shouldn’t be too hard, right?:wink:

Naw u got this, ezpz! just look at the create cylinder and the create sphere methods then tailor/combine the two.

If you can get a single island uv with no distortion Ill be really proud.

It should honestly have been done days ago, I’ll let you get at it and if you hit a road block or struggle with it hit me up and we will get through it.

Sure no problem. I was gonna make a stick figure rag doll and was like “why der be no capsuls?.” I wanted to mess around with physics and after this is done many people can use it. I’ll make a website with the code and a whole explanation of it.

Thanks for the idea!