three.js 之旅 (三)

创建模型:

 1.长方体:

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

  width是x方向上的长度;

height是y方向上的长度;

  depth是z方向上的长度;

后三个参数分别是在三个方向上的分段数,如widthSegments3的话,代表x方向上水平分为三份。一般情况下不需要分段的话,可以不设置后三个参数,后三个参数的缺省值为1.

2:长方形:
  THREE.PlaneGeometry(width, height, widthSegments, heightSegments)

width是x方向上的长度;

height是y方向上的长度;

后两个参数同样表示分段。
3.球形:

  THREE.SphereGeometry(radius, segmentsWidth, segmentsHeight, phiStart, phiLength, thetaStart, thetaLength)
  
  radius是半径;

  segmentsWidth表示经度上的切片数;

  segmentsHeight表示纬度上的切片数;

  phiStart表示经度开始的弧度;

  phiLength表示经度跨过的弧度;

  thetaStart表示纬度开始的弧度;

  thetaLength表示纬度跨过的弧度;

4.圆形或者扇形:

  THREE.CircleGeometry(radius, segments, thetaStart, thetaLength)
  
  new THREE.CircleGeometry(3, 18, Math.PI / 3, Math.PI / 3 * 4)可以创建一个在x轴和y轴所在平面的三分之二圆的扇形:

5.圆柱体:

  THREE.CylinderGeometry(radiusTop, radiusBottom, height, radiusSegments, heightSegments, openEnded)

  radiusTop:顶面半径
  radiusBottom:底面半径
  当这两个参数设置为不同的值时,实际上创建的是一个圆台;
  height是圆柱体的高度;

  radiusSegmentsheightSegments可类比球体中的分段;

  openEnded是一个布尔值,表示是否没有顶面和底面,缺省值为false,表示有顶面和底面
6.标准圆柱体:

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

7.正四面体、正八面体、正二十面体:

  正四面体(TetrahedronGeometry)、正八面体(OctahedronGeometry)、正二十面体(IcosahedronGeometry)的构造函数较为类似,分别为:
  THREE.TetrahedronGeometry(radius, detail)

  THREE.OctahedronGeometry(radius, detail)
  THREE.IcosahedronGeometry(radius, detail)

   radius是半径;

   detail是细节层次(Level of Detail)的层数,

    对于大面片数模型,可以控制在视角靠近物体时,显示面片数多的精细模型,而在离物体较远时,显示面片数较少的粗略模型。这里我们不对detail多作展开,一般可以对这个值缺省。

8.圆环面(圆环面(TorusGeometry)就是甜甜圈的形状)

 
THREE.TorusGeometry(radius, tube, radialSegments, tubularSegments, arc)

  radius是圆环半径;

  tube是管道半径;

  radialSegmentstubularSegments分别是两个分段数;

  arc是圆环面的弧度;

  缺省值为Math.PI * 2;
9.圆环结(如果说圆环面是甜甜圈,那么圆环结(TorusKnotGeometry)就是打了结的甜甜圈):
  
  THREE.TorusKnotGeometry(radius, tube, radialSegments, tubularSegments, p, q, heightScale)


 
原文地址:https://www.cnblogs.com/ssrsblogs/p/5611332.html