1
|
|
|
<?php |
2
|
|
|
/** @formatter:off |
3
|
|
|
* ****************************************************************** |
4
|
|
|
* Created by Marko Kungla on Jul 7, 2016 - 7:46:31 PM |
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 Ring.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\Extras\Primitives; |
25
|
|
|
|
26
|
|
|
use \AframeVR\Interfaces\Extras\Primitives\RingPrimitiveIF; |
27
|
|
|
use \AframeVR\Core\Entity; |
28
|
|
|
use \AframeVR\Core\Helpers\MeshAttributes; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* <a-ring> |
32
|
|
|
* |
33
|
|
|
* The ring primitive creates a ring or disc shape. It is an entity that prescribes the geometry with its geometric |
34
|
|
|
* primitive set to ring. |
35
|
|
|
*/ |
36
|
|
|
final class Ring extends Entity implements RingPrimitiveIF |
37
|
|
|
{ |
38
|
|
|
|
39
|
|
|
use MeshAttributes; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Set defaults |
43
|
|
|
* |
44
|
|
|
* {@inheritdoc} |
45
|
|
|
* |
46
|
|
|
* @return void |
47
|
|
|
*/ |
48
|
5 |
|
public function init() |
49
|
|
|
{ |
50
|
5 |
|
$this->component('Geometry')->primitive('ring'); |
51
|
5 |
|
$this->radiusInner(); |
52
|
5 |
|
$this->radiusOuter(); |
53
|
5 |
|
$this->segmentsPhi(); |
54
|
5 |
|
$this->segmentsTheta(); |
55
|
5 |
|
$this->thetaLength(); |
56
|
5 |
|
$this->thetaStart(); |
57
|
5 |
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Radius of the inner hole of the ring. |
61
|
|
|
* |
62
|
|
|
* @param int|float $radiusInner |
63
|
|
|
* @return RingPrimitiveIF |
64
|
|
|
*/ |
65
|
5 |
|
public function radiusInner(float $radiusInner = 1): RingPrimitiveIF |
66
|
|
|
{ |
67
|
5 |
|
$this->component('Geometry')->radiusInner($radiusInner); |
68
|
5 |
|
return $this; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Radius of the outer edge of the ring. |
73
|
|
|
* |
74
|
|
|
* @param int|float $radiusOuter |
75
|
|
|
* @return RingPrimitiveIF |
76
|
|
|
*/ |
77
|
5 |
|
public function radiusOuter(float $radiusOuter = 2): RingPrimitiveIF |
78
|
|
|
{ |
79
|
5 |
|
$this->component('Geometry')->radiusOuter($radiusOuter); |
80
|
5 |
|
return $this; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Number of triangles within each face defined by segmentsTheta. |
85
|
|
|
* |
86
|
|
|
* @param int $segmentsPhi |
87
|
|
|
* @return RingPrimitiveIF |
88
|
|
|
*/ |
89
|
5 |
|
public function segmentsPhi(int $segmentsPhi = 8): RingPrimitiveIF |
90
|
|
|
{ |
91
|
5 |
|
$this->component('Geometry')->segmentsPhi($segmentsPhi); |
92
|
5 |
|
return $this; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Number of segments. |
97
|
|
|
* A higher number means the ring will be more round. |
98
|
|
|
* |
99
|
|
|
* @param int $segmentsTheta |
100
|
|
|
* @return RingPrimitiveIF |
101
|
|
|
*/ |
102
|
5 |
|
public function segmentsTheta(int $segmentsTheta = 32): RingPrimitiveIF |
103
|
|
|
{ |
104
|
5 |
|
$this->component('Geometry')->segmentsTheta($segmentsTheta); |
105
|
5 |
|
return $this; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Central angle in degrees. |
110
|
|
|
* |
111
|
|
|
* @param int|float $thetaLength |
112
|
|
|
* @return RingPrimitiveIF |
113
|
|
|
*/ |
114
|
5 |
|
public function thetaLength(float $thetaLength = 360): RingPrimitiveIF |
115
|
|
|
{ |
116
|
5 |
|
$this->component('Geometry')->thetaLength($thetaLength); |
117
|
5 |
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Starting angle in degrees. |
122
|
|
|
* |
123
|
|
|
* @param int|float $thetaStart |
124
|
|
|
* @return RingPrimitiveIF |
125
|
|
|
*/ |
126
|
5 |
|
public function thetaStart(float $thetaStart = 0): RingPrimitiveIF |
127
|
|
|
{ |
128
|
5 |
|
$this->component('Geometry')->thetaStart($thetaStart); |
129
|
5 |
|
return $this; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
} |
133
|
|
|
|