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
|
|
|
public function init() |
42
|
|
|
{ |
43
|
|
|
/* Load defaults */ |
44
|
|
|
$this->component('Geometry')->primitive('torus'); |
45
|
|
|
|
46
|
|
|
$this->radius(); |
47
|
|
|
$this->radiusTubular(); |
48
|
|
|
$this->segmentsRadial(); |
49
|
|
|
$this->segmentsTubular(); |
50
|
|
|
$this->arc(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Radius of the outer edge of the torus. |
55
|
|
|
* |
56
|
|
|
* @param int|float $radius |
57
|
|
|
* @return TorusPrimitiveIF |
|
|
|
|
58
|
|
|
*/ |
59
|
|
|
public function radius(float $radius = 1): self |
60
|
|
|
{ |
61
|
|
|
$this->component('Geometry')->radius($radius); |
62
|
|
|
return $this; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Radius of the tube. |
67
|
|
|
* |
68
|
|
|
* @param float $radiusTubular |
69
|
|
|
* @return self |
|
|
|
|
70
|
|
|
*/ |
71
|
|
|
public function radiusTubular(float $radiusTubular = 0.2): self |
72
|
|
|
{ |
73
|
|
|
$this->component('Geometry')->radiusTubular($radiusTubular); |
74
|
|
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Number of segments along the circumference of the tube ends. |
79
|
|
|
* A higher number means the tube will be more round. |
80
|
|
|
* |
81
|
|
|
* @param int $segmentsRadial |
82
|
|
|
* @return self |
|
|
|
|
83
|
|
|
*/ |
84
|
|
|
public function segmentsRadial(int $segmentsRadial = 36): self |
85
|
|
|
{ |
86
|
|
|
$this->component('Geometry')->segmentsRadial($segmentsRadial); |
87
|
|
|
return $this; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Number of segments along the circumference of the tube face. |
92
|
|
|
* A higher number means the tube will be more round. |
93
|
|
|
* |
94
|
|
|
* @param int $segmentsTubular |
95
|
|
|
* @return self |
|
|
|
|
96
|
|
|
*/ |
97
|
|
|
public function segmentsTubular(int $segmentsTubular = 8): self |
98
|
|
|
{ |
99
|
|
|
$this->component('Geometry')->segmentsTubular($segmentsTubular); |
100
|
|
|
return $this; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Central angle. |
105
|
|
|
* |
106
|
|
|
* @param int|float $arc |
107
|
|
|
* @return TorusPrimitiveIF |
108
|
|
|
*/ |
109
|
|
|
public function arc(float $arc = 360): TorusPrimitiveIF |
110
|
|
|
{ |
111
|
|
|
$this->component('Geometry')->arc($arc); |
112
|
|
|
return $this; |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|
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.