参考 box()

box()

绘制一个长方体(矩形棱柱)。

长方体是一个具有六个面的 3D 形状。每个面与四个相邻的面都形成 90˚ 的角度。

第一个参数 width 是可选的。如果传递一个 Number,如 box(20), 它设置长方体的宽度和高度。默认情况下,width 是 50。

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

第三个参数 depth 也是可选的。如果传递一个 Number,如 box(20, 30, 40), 它设置长方体的深度。默认情况下,depth 设置为长方体的 height

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

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

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

示例

语法

box([width], [height], [depth], [detailX], [detailY])

参数

width

width of the box.

height

height of the box.

depth

depth of the box.

detailX

number of triangle subdivisions along the x-axis.

detailY

number of triangle subdivisions along the y-axis.

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

相关参考