1
|
|
|
<?php |
2
|
|
|
/** @formatter:off |
3
|
|
|
* ****************************************************************** |
4
|
|
|
* Created by Marko Kungla on Jul 7, 2016 - 7:27:20 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 Torus.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\Core\Entity; |
27
|
|
|
use \AframeVR\Interfaces\EntityInterface; |
28
|
|
|
|
29
|
|
|
final class Torus extends Entity implements EntityInterface |
30
|
|
|
{ |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Init <a-torus> |
34
|
|
|
* |
35
|
|
|
* The torus primitive creates a donut or circular tube shape. It is an entity that prescribes the geometry with |
36
|
|
|
* its |
37
|
|
|
* geometric primitive set to torus. |
38
|
|
|
* |
39
|
|
|
* @return void |
40
|
|
|
*/ |
41
|
1 |
|
public function reset() |
42
|
|
|
{ |
43
|
1 |
|
parent::reset(); |
44
|
|
|
/* Load defaults */ |
45
|
1 |
|
$this->component('Geometry')->primitive('torus'); |
46
|
|
|
|
47
|
1 |
|
$this->radius(); |
48
|
1 |
|
$this->radiusTubular(); |
49
|
1 |
|
$this->segmentsRadial(); |
50
|
1 |
|
$this->segmentsTubular(); |
51
|
1 |
|
$this->arc(); |
52
|
1 |
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Radius of the outer edge of the torus. |
56
|
|
|
* |
57
|
|
|
* @param int|float $radius |
58
|
|
|
* @return TorusPrimitiveIF |
|
|
|
|
59
|
|
|
*/ |
60
|
1 |
|
public function radius(float $radius = 1): self |
61
|
|
|
{ |
62
|
1 |
|
$this->component('Geometry')->radius($radius); |
63
|
1 |
|
return $this; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Radius of the tube. |
68
|
|
|
* |
69
|
|
|
* @param float $radiusTubular |
70
|
|
|
* @return self |
|
|
|
|
71
|
|
|
*/ |
72
|
1 |
|
public function radiusTubular(float $radiusTubular = 0.2): self |
73
|
|
|
{ |
74
|
1 |
|
$this->component('Geometry')->radiusTubular($radiusTubular); |
75
|
1 |
|
return $this; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Number of segments along the circumference of the tube ends. |
80
|
|
|
* A higher number means the tube will be more round. |
81
|
|
|
* |
82
|
|
|
* @param int $segmentsRadial |
83
|
|
|
* @return self |
|
|
|
|
84
|
|
|
*/ |
85
|
1 |
|
public function segmentsRadial(int $segmentsRadial = 36): self |
86
|
|
|
{ |
87
|
1 |
|
$this->component('Geometry')->segmentsRadial($segmentsRadial); |
88
|
1 |
|
return $this; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Number of segments along the circumference of the tube face. |
93
|
|
|
* A higher number means the tube will be more round. |
94
|
|
|
* |
95
|
|
|
* @param int $segmentsTubular |
96
|
|
|
* @return self |
|
|
|
|
97
|
|
|
*/ |
98
|
1 |
|
public function segmentsTubular(int $segmentsTubular = 32): self |
99
|
|
|
{ |
100
|
1 |
|
$this->component('Geometry')->segmentsTubular($segmentsTubular); |
101
|
1 |
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Central angle. |
106
|
|
|
* |
107
|
|
|
* @param int|float $arc |
108
|
|
|
* @return self |
|
|
|
|
109
|
|
|
*/ |
110
|
1 |
|
public function arc(float $arc = 360): self |
111
|
|
|
{ |
112
|
1 |
|
$this->component('Geometry')->arc($arc); |
113
|
1 |
|
return $this; |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.