THREE.JS学习笔记三:基本几何形状

立方体

THREE.CubeGeometry(width, height, depth, widthSegments, heightSegments, depthSegments)

width 是 x 方向上的长度; height 是 y 方向上的长度; depth 是 z 方向上的长 度;后三个参数分别是在三个方向上的分段数,如 widthSegments 为 3 的话,代表 x 方 向上水平分为三份。一般情况下不需要分段的话,可以不设置后三个参数,后三个参数的 缺省值为 1 。

创建立方体直观简单,如: new THREE.CubeGeometry(1, 2, 3); 可以创建一个 x 方向长度 为 1 ,y 方向长度为 2 ,z 方向长度为 3 的立方体。

平面

THREE.PlaneGeometry(width, height, widthSegments, heightSegments)

width 是 x 方向上的长度; height 是 y 方向上的长度;后两个参数同样表示分 段。

球体

球体(SphereGeometry)的构造函数是:

THREE.SphereGeometry(radius, segmentsWidth, segmentsHeight, phiStart, phiLength, the taStart, thetaLength)

radius 是半径; segmentsWidth 表示经度上的切片数; segmentsHeight 表示纬度 上的切片数; phiStart 表示经度开始的弧度; phiLength 表示经度跨过的弧度; thetaStart 表示纬度开始的弧度; thetaLength 表示纬度跨过的弧度。

圆形

圆形(CircleGeometry)可以创建圆形或者扇形,其构造函数是:

THREE.CircleGeometry(radius, segments, thetaStart, thetaLength)

圆柱体

圆柱体(CylinderGeometry)的构造函数是:

THREE.CylinderGeometry(radiusTop, radiusBottom, height, radiusSegments, heightSegmen ts, openEnded)

radiusTop 与 radiusBottom 分别是顶面和底面的半径,由此可知,当这两个参数 设置为不同的值时,实际上创建的是一个圆台; height 是圆柱体的高度; radiusSegments 与 heightSegments 可类比球体中的分段; openEnded 是一个布尔值,表 示是否没有顶面和底面,缺省值为 false ,表示有顶面和底面。

标准圆柱体

new THREE.CylinderGeometry(2, 2, 4, 18, 3) 创建一个顶面与底面半径都为 2 ,高度为 4 的圆柱体

圆台

将底面半径设为 3 创建一个圆台: new THREE.CylinderGeometry(2, 3, 4, 18, 3) ,效果 如下:

(图片来源于three.js入门指南)

无顶面底面

new THREE.CylinderGeometry(2, 3, 4, 18, 3, true) 将创建一个没有顶面与底面的圆台, 效果如下:

(图片来源于three.js入门指南)

猜你喜欢

转载自blog.csdn.net/joyvonlee/article/details/85775042