forked from mrdoob/three.js
/
Face3.js
59 lines (34 loc) · 1.23 KB
/
Face3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* @author mrdoob / http://mrdoob.com/
* @author alteredq / http://alteredqualia.com/
*/
THREE.Face3 = function ( a, b, c, normal, color, materialIndex ) {
this.a = a;
this.b = b;
this.c = c;
this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3();
this.vertexNormals = normal instanceof Array ? normal : [];
this.color = color instanceof THREE.Color ? color : new THREE.Color();
this.vertexColors = color instanceof Array ? color : [];
this.vertexTangents = [];
this.materialIndex = materialIndex !== undefined ? materialIndex : 0;
};
THREE.Face3.prototype = {
constructor: THREE.Face3,
clone: function () {
var face = new THREE.Face3( this.a, this.b, this.c );
face.normal.copy( this.normal );
face.color.copy( this.color );
face.materialIndex = this.materialIndex;
for ( var i = 0, il = this.vertexNormals.length; i < il; i ++ ) {
face.vertexNormals[ i ] = this.vertexNormals[ i ].clone();
}
for ( var i = 0, il = this.vertexColors.length; i < il; i ++ ) {
face.vertexColors[ i ] = this.vertexColors[ i ].clone();
}
for ( var i = 0, il = this.vertexTangents.length; i < il; i ++ ) {
face.vertexTangents[ i ] = this.vertexTangents[ i ].clone();
}
return face;
}
};