|
1
|
|
|
<?php |
|
2
|
|
|
/** @formatter:off |
|
3
|
|
|
* ****************************************************************** |
|
4
|
|
|
* Created by Marko Kungla on Jun 27, 2016 - 5:24:06 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 CircleMethods.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
|
|
|
class CircleMethods |
|
27
|
|
|
{ |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* The circle primitive defines two-dimensional circles, which can be complete circles or partial circles (like Pac-Man). |
|
31
|
|
|
* Note that because it is flat, only a single side of the circle will be rendered if “side: double” is not specified on the material component. |
|
32
|
|
|
*/ |
|
33
|
|
|
const DEFAULTS = array( |
|
34
|
|
|
/* Radius (in meters) of the circle. */ |
|
35
|
|
|
'radius' => 1, |
|
36
|
|
|
/* Number of triangles to construct the circle, like pizza slices. A higher number of segments means the circle will be more round. */ |
|
37
|
|
|
'segments' => 32, |
|
38
|
|
|
/* Start angle for first segment. Can be used to define a partial circle. */ |
|
39
|
|
|
'thetaStart' => 0, |
|
40
|
|
|
/* The central angle (in degrees). Defaults to 360, which makes for a complete circle. */ |
|
41
|
|
|
'thetaLength' => 360 |
|
42
|
|
|
); |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Radius (in meters) of the circle. |
|
46
|
|
|
* |
|
47
|
|
|
* @param &array $dom_attributes |
|
|
|
|
|
|
48
|
|
|
* @param float|int $radius |
|
|
|
|
|
|
49
|
|
|
* @return void |
|
50
|
|
|
*/ |
|
51
|
1 |
|
public function radius(array &$dom_attributes, float $radius) |
|
52
|
|
|
{ |
|
53
|
1 |
|
$dom_attributes['radius'] = $radius; |
|
54
|
1 |
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Segments |
|
58
|
|
|
* |
|
59
|
|
|
* CIRCLE: Number of triangles to construct the circle, like pizza slices. |
|
60
|
|
|
* A higher number of segments means the circle will be more round. |
|
61
|
|
|
* |
|
62
|
|
|
* @param &array $dom_attributes |
|
|
|
|
|
|
63
|
|
|
* @param int $segments |
|
64
|
|
|
* @return void |
|
65
|
|
|
*/ |
|
66
|
1 |
|
public function segments(array &$dom_attributes, int $segments) |
|
67
|
|
|
{ |
|
68
|
1 |
|
$dom_attributes['segments'] = $segments; |
|
69
|
1 |
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Start angle for first segment. |
|
73
|
|
|
* Can be used to define a partial circle. |
|
74
|
|
|
* |
|
75
|
|
|
* @param &array $dom_attributes |
|
|
|
|
|
|
76
|
|
|
* @param float|int $thetaStart |
|
|
|
|
|
|
77
|
|
|
* @return void |
|
78
|
|
|
*/ |
|
79
|
1 |
|
public function thetaStart(array &$dom_attributes, float $thetaStart) |
|
80
|
|
|
{ |
|
81
|
1 |
|
$dom_attributes['thetaStart'] = $thetaStart; |
|
82
|
1 |
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Defaults to 360, which makes for a complete circle. |
|
86
|
|
|
* |
|
87
|
|
|
* @param &array $dom_attributes |
|
|
|
|
|
|
88
|
|
|
* @param float|int $thetaLength |
|
|
|
|
|
|
89
|
|
|
* @return void |
|
90
|
|
|
*/ |
|
91
|
1 |
|
public function thetaLength(array &$dom_attributes, float $thetaLength) |
|
92
|
|
|
{ |
|
93
|
1 |
|
$dom_attributes['thetaLength'] = $thetaLength; |
|
94
|
1 |
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.