1
|
|
|
<?php |
2
|
|
|
/** @formatter:off |
3
|
|
|
* ****************************************************************** |
4
|
|
|
* Created by Marko Kungla on Jun 27, 2016 - 4:04:42 AM |
5
|
|
|
* Contact [email protected] |
6
|
|
|
* @copyright 2016 Marko Kungla - https://github.com/mkungla |
7
|
|
|
* @license The MIT License (MIT) |
8
|
|
|
* |
9
|
|
|
* @category AframeVR |
10
|
|
|
* @package aframe-php |
11
|
|
|
* |
12
|
|
|
* Lang PHP (php version >= 7) |
13
|
|
|
* Encoding UTF-8 |
14
|
|
|
* File SphereMethods.php |
15
|
|
|
* Code format PSR-2 and 12 |
16
|
|
|
* @link https://github.com/mkungla/aframe-php |
17
|
|
|
^ @issues https://github.com/mkungla/aframe-php/issues |
18
|
|
|
* ******************************************************************** |
19
|
|
|
* Contributors: |
20
|
|
|
* @author Marko Kungla <[email protected]> |
21
|
|
|
* ******************************************************************** |
22
|
|
|
* Comments: |
23
|
|
|
* @formatter:on */ |
24
|
|
|
namespace AframeVR\Core\Components\Geometry\Methods; |
25
|
|
|
|
26
|
|
View Code Duplication |
class SphereMethods |
|
|
|
|
27
|
|
|
{ |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* The sphere primitive can define spheres in the traditional sense like a basketball. |
31
|
|
|
* |
32
|
|
|
* But it can also define various polyhedrons and abstract shapes given that it can specify |
33
|
|
|
* the number of horizontal and vertical angles and faces. |
34
|
|
|
* |
35
|
|
|
* Sticking with a basic sphere, the default number of segments is high enough to make the sphere appear round. |
36
|
|
|
*/ |
37
|
|
|
const DEFAULTS = array( |
38
|
|
|
/* Radius of the sphere. */ |
39
|
|
|
'radius' => 1, |
40
|
|
|
/* Number of horizontal segments. */ |
41
|
|
|
'segmentsWidth' => 18, |
42
|
|
|
/* Number of vertical segments. */ |
43
|
|
|
'segmentsHeight' => 36, |
44
|
|
|
/* Horizontal starting angle. */ |
45
|
|
|
'phiStart' => 0, |
46
|
|
|
/* Horizontal sweep angle size. */ |
47
|
|
|
'phiLength' => 360, |
48
|
|
|
/* Vertical starting angle. */ |
49
|
|
|
'thetaStart' => 0, |
50
|
|
|
/* Vertical sweep angle size. */ |
51
|
|
|
'thetaLength' => 360 |
52
|
|
|
); |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Radius of the sphere. |
56
|
|
|
* |
57
|
|
|
* @param &array $dom_attributes |
|
|
|
|
58
|
|
|
* @param float|int $radius |
|
|
|
|
59
|
|
|
* @return void |
60
|
|
|
*/ |
61
|
10 |
|
public function radius(array &$dom_attributes, float $radius) |
62
|
|
|
{ |
63
|
10 |
|
$dom_attributes['radius'] = $radius; |
64
|
10 |
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Number of vertical segments. |
68
|
|
|
* |
69
|
|
|
* @param &array $dom_attributes |
|
|
|
|
70
|
|
|
* @param int $segmentsHeight |
71
|
|
|
* @return void |
72
|
|
|
*/ |
73
|
10 |
|
public function segmentsHeight(array &$dom_attributes, int $segmentsHeight) |
74
|
|
|
{ |
75
|
10 |
|
$dom_attributes['segmentsHeight'] = $segmentsHeight; |
76
|
10 |
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Number of horizontal segments. |
80
|
|
|
* |
81
|
|
|
* @param &array $dom_attributes |
|
|
|
|
82
|
|
|
* @param int $segmentsWidth |
83
|
|
|
* @return void |
84
|
|
|
*/ |
85
|
10 |
|
public function segmentsWidth(array &$dom_attributes, int $segmentsWidth) |
86
|
|
|
{ |
87
|
10 |
|
$dom_attributes['segmentsWidth'] = $segmentsWidth; |
88
|
10 |
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Horizontal starting angle. |
92
|
|
|
* |
93
|
|
|
* @param &array $dom_attributes |
|
|
|
|
94
|
|
|
* @param float|int $phiStart |
|
|
|
|
95
|
|
|
* @return void |
96
|
|
|
*/ |
97
|
1 |
|
public function phiStart(array &$dom_attributes, float $phiStart) |
98
|
|
|
{ |
99
|
1 |
|
$dom_attributes['phiStart'] = $phiStart; |
100
|
1 |
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Horizontal sweep angle size. |
104
|
|
|
* |
105
|
|
|
* @param &array $dom_attributes |
|
|
|
|
106
|
|
|
* @param float|int $phiLength |
|
|
|
|
107
|
|
|
* @return void |
108
|
|
|
*/ |
109
|
1 |
|
public function phiLength(array &$dom_attributes, float $phiLength = null) |
110
|
|
|
{ |
111
|
1 |
|
$dom_attributes['phiLength'] = $phiLength; |
112
|
1 |
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Vertical starting angle. |
116
|
|
|
* |
117
|
|
|
* @param &array $dom_attributes |
|
|
|
|
118
|
|
|
* @param float|int $thetaStart |
|
|
|
|
119
|
|
|
* @return void |
120
|
|
|
*/ |
121
|
1 |
|
public function thetaStart(array &$dom_attributes, float $thetaStart) |
122
|
|
|
{ |
123
|
1 |
|
$dom_attributes['thetaStart'] = $thetaStart; |
124
|
1 |
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Vertical sweep angle size. |
128
|
|
|
* |
129
|
|
|
* @param &array $dom_attributes |
|
|
|
|
130
|
|
|
* @param float|int $thetaLength |
|
|
|
|
131
|
|
|
* @return void |
132
|
|
|
*/ |
133
|
1 |
|
public function thetaLength(array &$dom_attributes, float $thetaLength) |
134
|
|
|
{ |
135
|
1 |
|
$dom_attributes['thetaLength'] = $thetaLength; |
136
|
1 |
|
} |
137
|
|
|
} |
138
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.