Face3.js 724 字节
Newer Older
M
Mr.doob 已提交
1 2 3 4
/**
 * @author mr.doob / http://mrdoob.com/
 */

U
unknown 已提交
5
THREE.Face3 = function ( a, b, c, normal, color, material ) {
6

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

M
Mr.doob 已提交
11
	this.centroid = new THREE.Vector3();
U
unknown 已提交
12
    this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3();
13

M
Mr.doob 已提交
14
	this.color = color || new THREE.Color( 0xff000000 );
U
unknown 已提交
15 16 17
    
	this.vertexNormals =  normal instanceof Array ? normal : [];
    this.material = material || 0;
18

M
Mr.doob 已提交
19 20 21 22
};

THREE.Face3.prototype = {

M
Mr.doob 已提交
23 24 25 26 27 28 29 30
	// TODO: Dupe? (Geometry/computeCentroid)

	getCenter : function(){

		return this.a.clone().addSelf( this.b ).addSelf( this.c ).divideScalar( 3 );

	},

M
Mr.doob 已提交
31
	toString: function () {
32

M
Mr.doob 已提交
33
		return 'THREE.Face3 ( ' + this.a + ', ' + this.b + ', ' + this.c + ' )';
34

M
Mr.doob 已提交
35
	}
36

M
Mr.doob 已提交
37
}