|
1
|
|
|
<?php |
|
2
|
|
|
/** @formatter:off |
|
3
|
|
|
* ****************************************************************** |
|
4
|
|
|
* Created by Marko Kungla on Jul 6, 2016 - 9:12:58 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 LightComponent.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\Core\Components\Light; |
|
25
|
|
|
|
|
26
|
|
|
use \AframeVR\Interfaces\Core\Components\LightCMPTIF; |
|
27
|
|
|
use \AframeVR\Core\Helpers\ComponentAbstract; |
|
28
|
|
|
|
|
29
|
|
|
class LightComponent extends ComponentAbstract implements LightCMPTIF |
|
30
|
|
|
{ |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Initialize Component |
|
34
|
|
|
* |
|
35
|
|
|
* {@inheritdoc} |
|
36
|
|
|
* |
|
37
|
|
|
* @return bool |
|
38
|
|
|
*/ |
|
39
|
6 |
|
public function initializeComponent(): bool |
|
40
|
|
|
{ |
|
41
|
6 |
|
$this->setDomAttribute('light'); |
|
42
|
6 |
|
return true; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Light type |
|
47
|
|
|
* |
|
48
|
|
|
* One of ambient, directional, hemisphere, point, spot. |
|
49
|
|
|
* |
|
50
|
|
|
* @param string $type |
|
51
|
|
|
* @return LightCMPTIF |
|
52
|
|
|
*/ |
|
53
|
4 |
|
public function type(string $type = 'directional'): LightCMPTIF |
|
54
|
|
|
{ |
|
55
|
4 |
|
$this->dom_attributes['type'] = $type; |
|
56
|
4 |
|
return $this; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Light color |
|
61
|
|
|
* |
|
62
|
|
|
* @param string $color |
|
63
|
|
|
* @return void |
|
|
|
|
|
|
64
|
|
|
*/ |
|
65
|
4 |
|
public function color(string $color = '#fff'): LightCMPTIF |
|
66
|
|
|
{ |
|
67
|
4 |
|
$this->dom_attributes['color'] = $color; |
|
68
|
4 |
|
return $this; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Light angle |
|
73
|
|
|
* |
|
74
|
|
|
* Maximum extent of spot light from its direction (in degrees). |
|
75
|
|
|
* |
|
76
|
|
|
* @param float $angle |
|
|
|
|
|
|
77
|
|
|
* @return LightPrimitiveIF |
|
|
|
|
|
|
78
|
|
|
*/ |
|
79
|
1 |
|
public function angle(float $angle = 60): LightCMPTIF |
|
80
|
|
|
{ |
|
81
|
1 |
|
$this->dom_attributes['angle'] = $angle; |
|
82
|
1 |
|
return $this; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Amount the light dims along the distance of the light. |
|
87
|
|
|
* |
|
88
|
|
|
* @param int $decay |
|
89
|
|
|
* @return LightPrimitiveIF |
|
|
|
|
|
|
90
|
|
|
*/ |
|
91
|
1 |
|
public function decay(int $decay = 1): LightCMPTIF |
|
92
|
|
|
{ |
|
93
|
1 |
|
$this->dom_attributes['decay'] = $decay; |
|
94
|
1 |
|
return $this; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Light distance |
|
99
|
|
|
* |
|
100
|
|
|
* Distance where intensity becomes 0. If distance is 0, then the point light does not decay with distance. |
|
101
|
|
|
* |
|
102
|
|
|
* @param float $distance |
|
103
|
|
|
* @return LightPrimitiveIF |
|
|
|
|
|
|
104
|
|
|
*/ |
|
105
|
4 |
|
public function distance(float $distance = 0.0): LightCMPTIF |
|
106
|
|
|
{ |
|
107
|
4 |
|
$this->dom_attributes['distance'] = $distance; |
|
108
|
4 |
|
return $this; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* falloff |
|
113
|
|
|
* |
|
114
|
|
|
* Rapidity of falloff of light from its target direction. |
|
115
|
|
|
* |
|
116
|
|
|
* @param float $exponent |
|
117
|
|
|
* @return LightPrimitiveIF |
|
|
|
|
|
|
118
|
|
|
*/ |
|
119
|
1 |
|
public function exponent(float $exponent = 10.0): LightCMPTIF |
|
120
|
|
|
{ |
|
121
|
1 |
|
$this->dom_attributes['exponent'] = $exponent; |
|
122
|
1 |
|
return $this; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* Light color from below. |
|
127
|
|
|
* |
|
128
|
|
|
* @param string $ground_color |
|
129
|
|
|
* @return LightPrimitiveIF |
|
|
|
|
|
|
130
|
|
|
*/ |
|
131
|
1 |
|
public function groundColor(string $ground_color = '#fff'): LightCMPTIF |
|
132
|
|
|
{ |
|
133
|
1 |
|
$this->dom_attributes['groundColor'] = $ground_color; |
|
134
|
1 |
|
return $this; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* Light strength. |
|
139
|
|
|
* |
|
140
|
|
|
* @param float $intensity |
|
141
|
|
|
* @return LightPrimitiveIF |
|
|
|
|
|
|
142
|
|
|
*/ |
|
143
|
1 |
|
public function intensity(float $intensity = 1.0): LightCMPTIF |
|
144
|
|
|
{ |
|
145
|
1 |
|
$this->dom_attributes['intensity'] = $intensity; |
|
146
|
1 |
|
return $this; |
|
147
|
|
|
} |
|
148
|
|
|
} |
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.