-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFinGeometry.js
More file actions
70 lines (53 loc) · 1.87 KB
/
FinGeometry.js
File metadata and controls
70 lines (53 loc) · 1.87 KB
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
60
61
62
63
64
65
66
67
68
69
70
RocketClubs.FinGeometry = function ( rootChord, tipChord, semiSpan, sweepLength, thickness ) {
THREE.Geometry.call( this );
var scope = this;
var halfDepth = thickness / 2;
var frontRootTop = new THREE.Vector3();
frontRootTop.z = -halfDepth;
frontRootTop.x = 0;
frontRootTop.y = rootChord / 2;
var frontRootBottom = new THREE.Vector3();
frontRootBottom.z = -halfDepth;
frontRootBottom.x = 0;
frontRootBottom.y = frontRootTop.y - rootChord;
var frontTipTop = new THREE.Vector3();
frontTipTop.z = -halfDepth;
frontTipTop.x = semiSpan;
frontTipTop.y = frontRootTop.y - sweepLength;
var frontTipBottom = new THREE.Vector3();
frontTipBottom.z = -halfDepth;
frontTipBottom.x = semiSpan;
frontTipBottom.y = frontTipTop.y - tipChord;
var backRootTop = frontRootTop.clone();
backRootTop.z = -backRootTop.z;
var backRootBottom = frontRootBottom.clone();
backRootBottom.z = -backRootBottom.z;
var backTipTop = frontTipTop.clone();
backTipTop.z = -backTipTop.z;
var backTipBottom = frontTipBottom.clone();
backTipBottom.z = -backTipBottom.z;
scope.vertices.push(frontRootTop);
scope.vertices.push(frontRootBottom);
scope.vertices.push(frontTipTop);
scope.vertices.push(frontTipBottom);
scope.vertices.push(backRootTop);
scope.vertices.push(backRootBottom);
scope.vertices.push(backTipTop);
scope.vertices.push(backTipBottom);
buildPlane( 0, 2, 3, 1, 0 );
buildPlane( 0, 4, 6, 2, 1 );
buildPlane( 4, 0, 1, 5, 2 );
buildPlane( 2, 6, 7, 3, 3 );
buildPlane( 3, 7, 5, 1, 4 );
buildPlane( 6, 4, 5, 7, 5 );
function buildPlane( v1, v2, v3, v4, normal, materialIndex ) {
var face = new THREE.Face4( v1, v2, v3, v4 );
face.materialIndex = materialIndex;
scope.faces.push( face );
}
this.computeFaceNormals();
this.computeVertexNormals();
this.computeCentroids();
this.mergeVertices();
};
RocketClubs.FinGeometry.prototype = Object.create( THREE.Geometry.prototype );