参考 cylinder()

cylinder()

绘制一个圆柱体。

圆柱体是一个具有连接平底和平顶的三角形面的 3D 形状。面数较少的圆柱体看起来像箱子。面数较多的圆柱体具有光滑的表面。

第一个参数 radius 是可选的。如果传递一个 Number,如 cylinder(20),它设置圆柱体底部的半径。默认情况下,radius 是 50。

第二个参数 height 也是可选的。如果传递一个 Number,如 cylinder(20, 30),它设置圆柱体的高度。默认情况下,height 设置为圆柱体的 radius

第三个参数 detailX 也是可选的。如果传递一个 Number ,如 cylinder(20, 30, 5),它设置用于形成圆柱体顶部和底部的边的数量。使用更多的边使顶部和底部看起来更像圆。默认情况下,detailX 是 24。

第四个参数 detailY 也是可选的。如果传递一个 Number,如 cylinder(20, 30, 5, 2),它设置沿 y 轴使用的三角形细分数,位于圆柱体顶部和底部之间。所有 3D 形状都是通过连接三角形来形成其表面的。默认情况下,detailY 是 1。

第五个参数 bottomCap 也是可选的。如果传递一个 false ,如 cylinder(20, 30, 5, 2, false),则不会绘制圆柱体的底部。默认情况下,bottomCaptrue

第六个参数 topCap 也是可选的。如果传递一个 false,如 cylinder(20, 30, 5, 2, false, false),则不会绘制圆柱体的顶部。默认情况下,topCaptrue

注意:cylinder() 只能在 WebGL 模式下使用。

示例

语法

cylinder([radius], [height], [detailX], [detailY], [bottomCap], [topCap])

参数

radius

radius of the cylinder. Defaults to 50.

height

height of the cylinder. Defaults to the value of radius.

detailX

number of edges along the top and bottom. Defaults to 24.

detailY

number of triangle subdivisions along the y-axis. Defaults to 1.

bottomCap

whether to draw the cylinder's bottom. Defaults to true.

topCap

whether to draw the cylinder's top. Defaults to true.

Notice any errors or typos? Please let us know. Please feel free to edit src/webgl/3d_primitives.js and open a pull request!

相关参考