View Full Version : Help make a cylinder WebGL

12-15-2010, 08:26 AM
hello I am French student currently carrying out our project of molecule modeling in 3D WebGL we need a method to display a cylinder.
Thank you enlighten us on this issue.

12-15-2010, 06:02 PM
WebGL doesn't have functions for generating cylinders - or any other specific geometric shape for that matter. You have to generate the vertices yourself...either in a modelling program (blender or 3DStudio or whatever) - or you generate the vertices using math. Probably, you'll want to do it with math.

I suggest you start with one of the simple WebGL demos:


...if you look at the code carefully, you'll see that it calls a JavaScript function called "makeBox" to make the cube. That code is in a library here:


There is also a "makeSphere" function. With a little creativity, I think you can figure out how to make a cylinder.

12-15-2010, 10:20 PM
look at
http://www.ibiblio.org/e-notes/webgl/mo ... inder.html (http://www.ibiblio.org/e-notes/webgl/models/cylinder.html)