1
|
|
|
<?php |
2
|
|
|
/** @formatter:off |
3
|
|
|
* ****************************************************************** |
4
|
|
|
* Created by Marko Kungla on Jun 20, 2016 - 10:28:02 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 Primitive.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
|
|
|
class Sphere extends Entity implements EntityInterface |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* Init <a-sphere> |
33
|
|
|
* |
34
|
|
|
* The sphere primitive creates a spherical or polyhedron shapes. |
35
|
|
|
* It wraps an entity that prescribes the geometry component with its geometric primitive set to sphere. |
36
|
|
|
* |
37
|
|
|
* @return void |
38
|
|
|
*/ |
39
|
4 |
|
public function reset() |
40
|
|
|
{ |
41
|
4 |
|
$this->component('Material'); |
42
|
4 |
|
$this->component('Geometry')->primitive('sphere'); |
43
|
|
|
|
44
|
4 |
|
$this->radius(); |
45
|
4 |
|
$this->segmentsHeight(); |
46
|
4 |
|
$this->segmentsWidth(); |
47
|
4 |
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* geometry.radius |
51
|
|
|
* |
52
|
|
|
* @param float $radius |
53
|
|
|
* @return \AframeVR\Interfaces\Extras\Primitives\SpherePrimitiveIF |
|
|
|
|
54
|
|
|
*/ |
55
|
4 |
|
public function radius(float $radius = 0.85): self |
56
|
|
|
{ |
57
|
4 |
|
$this->component('Geometry')->radius($radius); |
58
|
4 |
|
return $this; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* geometry.segmentsHeight |
63
|
|
|
* |
64
|
|
|
* @param int $segmentsHeigh |
65
|
|
|
* @return self |
|
|
|
|
66
|
|
|
*/ |
67
|
4 |
|
public function segmentsHeight($segmentsHeigh = 18): self |
68
|
|
|
{ |
69
|
4 |
|
$this->component('Geometry')->segmentsHeight($segmentsHeigh); |
70
|
4 |
|
return $this; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* geometry.segmentsWidth |
75
|
|
|
* |
76
|
|
|
* @param int $segmentsWidth |
77
|
|
|
* @return self |
|
|
|
|
78
|
|
|
*/ |
79
|
4 |
|
public function segmentsWidth($segmentsWidth = 36): self |
80
|
|
|
{ |
81
|
4 |
|
$this->component('Geometry')->segmentsWidth($segmentsWidth); |
82
|
4 |
|
return $this; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
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.