|
1
|
|
|
<?php |
|
2
|
|
|
/** @formatter:off |
|
3
|
|
|
* ****************************************************************** |
|
4
|
|
|
* Created by Marko Kungla on Jul 7, 2016 - 4:51:28 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 Videosphere.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\VideospherePrimitiveIF; |
|
27
|
|
|
use \AframeVR\Core\Entity; |
|
28
|
|
|
use \AframeVR\Core\Helpers\MeshAttributes; |
|
29
|
|
|
|
|
30
|
|
|
class Videosphere extends Entity implements VideospherePrimitiveIF |
|
31
|
|
|
{ |
|
32
|
|
|
use MeshAttributes; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Init <a-sphere> |
|
36
|
|
|
* |
|
37
|
|
|
* The sphere primitive creates a spherical or polyhedron shapes. |
|
38
|
|
|
* It wraps an entity that prescribes the geometry component with its geometric primitive set to sphere. |
|
39
|
|
|
* |
|
40
|
|
|
* {@inheritdoc} |
|
41
|
|
|
* |
|
42
|
|
|
* @return void |
|
43
|
|
|
*/ |
|
44
|
3 |
|
public function init() |
|
45
|
|
|
{ |
|
46
|
|
|
/* Load defaults */ |
|
47
|
3 |
|
$this->defaults(); |
|
48
|
3 |
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Set defaults |
|
52
|
|
|
* |
|
53
|
|
|
* {@inheritdoc} |
|
54
|
|
|
* |
|
55
|
|
|
* @return void |
|
56
|
|
|
*/ |
|
57
|
3 |
|
public function defaults() |
|
58
|
|
|
{ |
|
59
|
3 |
|
$this->component('Material')->shader('flat'); |
|
60
|
3 |
|
$this->color('#FFF'); |
|
61
|
|
|
|
|
62
|
3 |
|
$this->component('Geometry')->primitive('sphere'); |
|
63
|
3 |
|
$this->component('Geometry')->radius(5000); |
|
64
|
3 |
|
$this->component('Geometry')->segmentsWidth(64); |
|
65
|
3 |
|
$this->component('Geometry')->segmentsWidth(20); |
|
66
|
|
|
|
|
67
|
3 |
|
$this->scale(-1, 1, 1); |
|
68
|
3 |
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* geometry.radius |
|
72
|
|
|
* |
|
73
|
|
|
* {@inheritdoc} |
|
74
|
|
|
* |
|
75
|
|
|
* @param float $radius |
|
|
|
|
|
|
76
|
|
|
* @return VideospherePrimitiveIF |
|
77
|
|
|
*/ |
|
78
|
1 |
|
public function radius(float $radius = 100): VideospherePrimitiveIF |
|
79
|
|
|
{ |
|
80
|
1 |
|
$this->component('Geometry')->radius($radius); |
|
81
|
1 |
|
return $this; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Autoplay video |
|
86
|
|
|
* |
|
87
|
|
|
* @param bool $autoplay |
|
88
|
|
|
* @return AssetVideoInterface |
|
|
|
|
|
|
89
|
|
|
*/ |
|
90
|
1 |
|
public function autoplay(bool $autoplay = true): VideospherePrimitiveIF |
|
91
|
|
|
{ |
|
92
|
1 |
|
$this->attrs['autoplay'] = $autoplay ? 'true' : 'false'; |
|
93
|
1 |
|
return $this; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* geometry.segmentsHeight |
|
98
|
|
|
* |
|
99
|
|
|
* {@inheritdoc} |
|
100
|
|
|
* |
|
101
|
|
|
* @param int $segmentsHeigh |
|
102
|
|
|
* @return VideospherePrimitiveIF |
|
103
|
|
|
*/ |
|
104
|
1 |
|
public function segmentsHeight($segmentsHeigh = 64): VideospherePrimitiveIF |
|
105
|
|
|
{ |
|
106
|
1 |
|
$this->component('Geometry')->segmentsHeight($segmentsHeigh); |
|
107
|
1 |
|
return $this; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* geometry.segmentsWidth |
|
112
|
|
|
* |
|
113
|
|
|
* {@inheritdoc} |
|
114
|
|
|
* |
|
115
|
|
|
* @param int $segmentsWidth |
|
116
|
|
|
* @return VideospherePrimitiveIF |
|
117
|
|
|
*/ |
|
118
|
1 |
|
public function segmentsWidth($segmentsWidth = 64): VideospherePrimitiveIF |
|
119
|
|
|
{ |
|
120
|
1 |
|
$this->component('Geometry')->segmentsWidth($segmentsWidth); |
|
121
|
1 |
|
return $this; |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
|
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.