forked from MattStultz/extrusiongen
-
Notifications
You must be signed in to change notification settings - Fork 1
/
IKRS.OvalShapeFactory.js
51 lines (38 loc) · 1.2 KB
/
IKRS.OvalShapeFactory.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
/**
* This is the shape factory for making ovals.
*
* @author Ikaros Kappler
* @date 2014-07-03
* @version 1.0.0
**/
IKRS.OvalShapeFactory = function( radiusX,
radiusY,
startAngle,
arc
) {
IKRS.ShapeFactory.call( this, "Oval" );
this.radiusX = radiusX;
this.radiusY = radiusY;
this.startAngle = startAngle;
this.arc = arc;
};
IKRS.OvalShapeFactory.prototype = new IKRS.Object();
IKRS.OvalShapeFactory.prototype.constructor = IKRS.ShapeFactory;
/**
* This function creates the points for a circle shape (with the given segment count).
**/
IKRS.OvalShapeFactory.prototype.createShapePoints = function( segmentCount ) {
var shapePoints = [];
// If the mesh is split, the shape will be split into two halfs.
// -> eventually divide the shape's segment count by two.
for( i = 0; i <= segmentCount; i++ ) {
var pct = i * (1.0/segmentCount);
var angle = this.startAngle + this.arc * pct;
shapePoints.push( new THREE.Vector3( Math.sin( angle ) * this.radiusX,
Math.cos( angle ) * this.radiusY,
0
)
);
}
return shapePoints;
};