-
Notifications
You must be signed in to change notification settings - Fork 12
/
IKRS.CircleShapeFactory.js
53 lines (36 loc) · 1.19 KB
/
IKRS.CircleShapeFactory.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
/**
* This is the default shape factory, making circles.
*
* @author Ikaros Kappler
* @date 2014-07-03
* @version 1.0.0
**/
IKRS.CircleShapeFactory = function( circleRadius,
startAngle,
arc
) {
IKRS.ShapeFactory.call( this, "Circle" );
this.circleRadius = circleRadius;
this.startAngle = startAngle;
this.arc = arc;
};
IKRS.CircleShapeFactory.prototype = new IKRS.Object();
IKRS.CircleShapeFactory.prototype.constructor = IKRS.ShapeFactory;
/**
* This function creates the points for a circle shape (with the given segment count).
**/
IKRS.CircleShapeFactory.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.circleRadius,
Math.cos( angle ) * this.circleRadius,
0
)
);
}
return shapePoints;
};