@@ -6,109 +6,110 @@ import { Vector2 } from '../math/Vector2.js';
6
6
7
7
// CircleGeometry
8
8
9
- function CircleGeometry ( radius , segments , thetaStart , thetaLength ) {
9
+ class CircleGeometry extends Geometry {
10
10
11
- Geometry . call ( this ) ;
11
+ constructor ( radius , segments , thetaStart , thetaLength ) {
12
12
13
- this . type = 'CircleGeometry' ;
13
+ super ( ) ;
14
+ this . type = 'CircleGeometry' ;
14
15
15
- this . parameters = {
16
- radius : radius ,
17
- segments : segments ,
18
- thetaStart : thetaStart ,
19
- thetaLength : thetaLength
20
- } ;
16
+ this . parameters = {
17
+ radius : radius ,
18
+ segments : segments ,
19
+ thetaStart : thetaStart ,
20
+ thetaLength : thetaLength
21
+ } ;
21
22
22
- this . fromBufferGeometry ( new CircleBufferGeometry ( radius , segments , thetaStart , thetaLength ) ) ;
23
- this . mergeVertices ( ) ;
23
+ this . fromBufferGeometry ( new CircleBufferGeometry ( radius , segments , thetaStart , thetaLength ) ) ;
24
+ this . mergeVertices ( ) ;
24
25
25
- }
26
+ }
26
27
27
- CircleGeometry . prototype = Object . create ( Geometry . prototype ) ;
28
- CircleGeometry . prototype . constructor = CircleGeometry ;
28
+ }
29
29
30
30
// CircleBufferGeometry
31
31
32
- function CircleBufferGeometry ( radius , segments , thetaStart , thetaLength ) {
32
+ class CircleBufferGeometry extends BufferGeometry {
33
33
34
- BufferGeometry . call ( this ) ;
34
+ constructor ( radius , segments , thetaStart , thetaLength ) {
35
35
36
- this . type = 'CircleBufferGeometry' ;
36
+ super ( ) ;
37
37
38
- this . parameters = {
39
- radius : radius ,
40
- segments : segments ,
41
- thetaStart : thetaStart ,
42
- thetaLength : thetaLength
43
- } ;
38
+ this . type = 'CircleBufferGeometry' ;
44
39
45
- radius = radius || 1 ;
46
- segments = segments !== undefined ? Math . max ( 3 , segments ) : 8 ;
40
+ this . parameters = {
41
+ radius : radius ,
42
+ segments : segments ,
43
+ thetaStart : thetaStart ,
44
+ thetaLength : thetaLength
45
+ } ;
47
46
48
- thetaStart = thetaStart !== undefined ? thetaStart : 0 ;
49
- thetaLength = thetaLength !== undefined ? thetaLength : Math . PI * 2 ;
47
+ radius = radius || 1 ;
48
+ segments = segments !== undefined ? Math . max ( 3 , segments ) : 8 ;
50
49
51
- // buffers
50
+ thetaStart = thetaStart !== undefined ? thetaStart : 0 ;
51
+ thetaLength = thetaLength !== undefined ? thetaLength : Math . PI * 2 ;
52
52
53
- const indices = [ ] ;
54
- const vertices = [ ] ;
55
- const normals = [ ] ;
56
- const uvs = [ ] ;
53
+ // buffers
57
54
58
- // helper variables
55
+ const indices = [ ] ;
56
+ const vertices = [ ] ;
57
+ const normals = [ ] ;
58
+ const uvs = [ ] ;
59
59
60
- const vertex = new Vector3 ( ) ;
61
- const uv = new Vector2 ( ) ;
60
+ // helper variables
62
61
63
- // center point
62
+ const vertex = new Vector3 ( ) ;
63
+ const uv = new Vector2 ( ) ;
64
64
65
- vertices . push ( 0 , 0 , 0 ) ;
66
- normals . push ( 0 , 0 , 1 ) ;
67
- uvs . push ( 0.5 , 0.5 ) ;
65
+ // center point
68
66
69
- for ( let s = 0 , i = 3 ; s <= segments ; s ++ , i += 3 ) {
67
+ vertices . push ( 0 , 0 , 0 ) ;
68
+ normals . push ( 0 , 0 , 1 ) ;
69
+ uvs . push ( 0.5 , 0.5 ) ;
70
70
71
- const segment = thetaStart + s / segments * thetaLength ;
71
+ for ( let s = 0 , i = 3 ; s <= segments ; s ++ , i += 3 ) {
72
72
73
- // vertex
73
+ const segment = thetaStart + s / segments * thetaLength ;
74
74
75
- vertex . x = radius * Math . cos ( segment ) ;
76
- vertex . y = radius * Math . sin ( segment ) ;
75
+ // vertex
77
76
78
- vertices . push ( vertex . x , vertex . y , vertex . z ) ;
77
+ vertex . x = radius * Math . cos ( segment ) ;
78
+ vertex . y = radius * Math . sin ( segment ) ;
79
79
80
- // normal
80
+ vertices . push ( vertex . x , vertex . y , vertex . z ) ;
81
81
82
- normals . push ( 0 , 0 , 1 ) ;
82
+ // normal
83
83
84
- // uvs
84
+ normals . push ( 0 , 0 , 1 ) ;
85
85
86
- uv . x = ( vertices [ i ] / radius + 1 ) / 2 ;
87
- uv . y = ( vertices [ i + 1 ] / radius + 1 ) / 2 ;
86
+ // uvs
88
87
89
- uvs . push ( uv . x , uv . y ) ;
88
+ uv . x = ( vertices [ i ] / radius + 1 ) / 2 ;
89
+ uv . y = ( vertices [ i + 1 ] / radius + 1 ) / 2 ;
90
90
91
- }
91
+ uvs . push ( uv . x , uv . y ) ;
92
92
93
- // indices
93
+ }
94
94
95
- for ( let i = 1 ; i <= segments ; i ++ ) {
95
+ // indices
96
96
97
- indices . push ( i , i + 1 , 0 ) ;
97
+ for ( let i = 1 ; i <= segments ; i ++ ) {
98
98
99
- }
99
+ indices . push ( i , i + 1 , 0 ) ;
100
100
101
- // build geometry
101
+ }
102
102
103
- this . setIndex ( indices ) ;
104
- this . setAttribute ( 'position' , new Float32BufferAttribute ( vertices , 3 ) ) ;
105
- this . setAttribute ( 'normal' , new Float32BufferAttribute ( normals , 3 ) ) ;
106
- this . setAttribute ( 'uv' , new Float32BufferAttribute ( uvs , 2 ) ) ;
103
+ // build geometry
107
104
108
- }
105
+ this . setIndex ( indices ) ;
106
+ this . setAttribute ( 'position' , new Float32BufferAttribute ( vertices , 3 ) ) ;
107
+ this . setAttribute ( 'normal' , new Float32BufferAttribute ( normals , 3 ) ) ;
108
+ this . setAttribute ( 'uv' , new Float32BufferAttribute ( uvs , 2 ) ) ;
109
109
110
- CircleBufferGeometry . prototype = Object . create ( BufferGeometry . prototype ) ;
111
- CircleBufferGeometry . prototype . constructor = CircleBufferGeometry ;
110
+ }
111
+
112
+ }
112
113
113
114
114
115
export { CircleGeometry , CircleBufferGeometry } ;
0 commit comments