参考 cone()

cone()

绘制一个圆锥体。

圆锥体是具有多个三角形面的 3D 形状,这些侧面将平底连接到单一顶点。面数较少的圆锥体看起来像金字塔。面数较多的圆锥体具有光滑的表面。

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

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

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

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

第五个参数 cap 也是可选的。如果传递一个 false,如 cone(20, 30, 5, 7, false), 则不会绘制圆锥体的底部。默认情况下,captrue

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

示例

语法

cone([radius], [height], [detailX], [detailY], [cap])

参数

radius

radius of the cone's base. Defaults to 50.

height

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

detailX

number of edges used to draw the base. Defaults to 24.

detailY

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

cap

whether to draw the cone's base. 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!

相关参考