PDA

View Full Version : Help make a cylinder WebGL



Mousto
12-15-2010, 09: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.

SteveBaker
12-15-2010, 07: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:

https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/demos/webkit/SpinningBox.html

...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:

https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/demos/webkit/resources/J3DI.js

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

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