核心——Geometry,Face3

Face3

用在Geometry中。为所有的标准几何体自动创建,当你需要自定义几何体的时候需要手动创建

构造函数

Face3( a : Integer, b : Integer, c : Integer, normal : Vector3, color : Color, materialIndex : Integer )

  • a/b/c 顶点序号

  • normal — (optional) new THREE.Vector3( 0, 1, 0 ) .Face normal (Vector3) or array of vertex normals. If a single vector is passed in, this sets .normal, otherwise if an array of three vectors is passed in this sets .vertexNormals

  • color — (optional) new THREE.Color( 0xffaa00 ). Face color or array of vertex colors. If a single vector is passed in, this sets .color, otherwise if an array of three vectors is passed in this sets .vertexColors

  • materialIndex — (optional) which index of an array of materials to associate with the face.

Geometry

存储特性(定点,位置,面,颜色等)

构造函数

Geometry()

var geometry = new THREE.Geometry();

geometry.vertices.push(
    new THREE.Vector3( -10,  10, 0 ),
    new THREE.Vector3( -10, -10, 0 ),
    new THREE.Vector3(  10, -10, 0 )
);

geometry.faces.push( new THREE.Face3( 0, 1, 2 ) );

geometry.computeBoundingSphere();

特性

  • boundingBox/boundingSphere/name/uuid
  • colors: Array 定点颜色,匹配数量和顶点序
  • faces: Array 模型中每个定点如何连接形成面,还包括面,颜色,法线的信息
  • faceVertexUvs :Array 面上的UV层
  • id/isGeometry/morphTargets: Array/morphNormasl: Array
  • lineDistances: array 定点之间的距离在线性几何体
  • skinWeight: Array 作用在SkinnerMesh
  • skinIndices: Array
  • vertices: Array 模型中每个顶点的位置
  • vertices/element/uvs/normals/colors/groups/lineDistancesNeedUpdate: Boolean 只要数组内容发生变化就需要设为true

    方法

  • EventDispatcher方法可用
  • applyMatrix(matrix4)/center()/clone()/copy(geometry)/dispose()/lookAt(v3)
  • computeBoundingBox/Sphere()
  • computeFace/Morph/VertexNormals()
  • fromBufferGeometry(geometry) 将缓冲几何转换成几何体
  • merg(geometry,matrix4,materialIndexOfffset)/mergMesh(mesh)/mergVertices()
  • normalize()
  • rotateX/Y/Z(radians)
  • scale/translate(x,y,z)/toJSON()
  • setFromPoints(points: Array)
  • sortFacesByMaterialIndex ( )

相对应各个类的实例,

InstancedBufferAttribute

InstancedBufferGeometry

InstancedInterleavedBuffer

InterleavedBuffer

意味着可能具有不同类型的多个属性(例如,位置,法线,紫外线,颜色)被打包到单个阵列缓冲器中

InterleavedBufferAttribute

threejs
JSRUN前端笔记, 是针对前端工程师开放的一个笔记分享平台,是前端工程师记录重点、分享经验的一个笔记本。JSRUN前端采用的 MarkDown 语法 (极客专用语法), 这里只属于前端工程师。