Face3.js 1.2 KB
Newer Older
M
Mr.doob 已提交
1
/**
M
Mr.doob 已提交
2
 * @author mrdoob / http://mrdoob.com/
3
 * @author alteredq / http://alteredqualia.com/
M
Mr.doob 已提交
4 5
 */

6
THREE.Face3 = function ( a, b, c, normal, color, materialIndex ) {
7

8
	this.a = a;
M
Mr.doob 已提交
9 10
	this.b = b;
	this.c = c;
11

12
	this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3();
A
alteredq 已提交
13
	this.vertexNormals = normal instanceof Array ? normal : [ ];
14

15 16
	this.color = color instanceof THREE.Color ? color : new THREE.Color();
	this.vertexColors = color instanceof Array ? color : [];
17

18
	this.vertexTangents = [];
19

20
	this.materialIndex = materialIndex;
21

22
	this.centroid = new THREE.Vector3();
23

M
Mr.doob 已提交
24
};
25 26 27 28 29 30 31

THREE.Face3.prototype = {

	constructor: THREE.Face3,

	clone: function () {

32
		var face = new THREE.Face3( this.a, this.b, this.c );
33

34 35 36
		face.normal.copy( this.normal );
		face.color.copy( this.color );
		face.centroid.copy( this.centroid );
37

38
		face.materialIndex = this.materialIndex;
39 40

		var i, il;
41 42 43
		for ( i = 0, il = this.vertexNormals.length; i < il; i ++ ) face.vertexNormals[ i ] = this.vertexNormals[ i ].clone();
		for ( i = 0, il = this.vertexColors.length; i < il; i ++ ) face.vertexColors[ i ] = this.vertexColors[ i ].clone();
		for ( i = 0, il = this.vertexTangents.length; i < il; i ++ ) face.vertexTangents[ i ] = this.vertexTangents[ i ].clone();
44

45
		return face;
46 47 48 49

	}

};