|
1
|
|
|
<?php |
|
2
|
|
|
/** @formatter:off |
|
3
|
|
|
* ****************************************************************** |
|
4
|
|
|
* Created by Marko Kungla on Jul 4, 2016 - 1:31:08 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 Camera.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 Camera extends Entity implements EntityInterface |
|
30
|
|
|
{ |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Init <a-camera> |
|
34
|
|
|
* |
|
35
|
|
|
* The camera primitive places the user somewhere within the scene. It is an entity that prescribes the camera |
|
36
|
|
|
* component with mappings to controls-related components. |
|
37
|
|
|
* |
|
38
|
|
|
* @return void |
|
39
|
|
|
*/ |
|
40
|
3 |
|
public function reset() |
|
41
|
|
|
{ |
|
42
|
3 |
|
parent::reset(); |
|
43
|
3 |
|
$this->child()->entity()->component('Camera'); |
|
44
|
3 |
|
$this->active(false); |
|
45
|
3 |
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* camera.active |
|
49
|
|
|
* |
|
50
|
|
|
* @param bool $active |
|
51
|
|
|
* @return \AframeVR\Extras\Primitives\Camera |
|
52
|
|
|
*/ |
|
53
|
3 |
|
public function active(bool $active) |
|
54
|
|
|
{ |
|
55
|
3 |
|
$this->child() |
|
56
|
3 |
|
->entity() |
|
57
|
3 |
|
->component('Camera') |
|
58
|
3 |
|
->active($active); |
|
59
|
3 |
|
return $this; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* camera.far |
|
64
|
|
|
* |
|
65
|
|
|
* @param float $far |
|
66
|
|
|
* @return \AframeVR\Extras\Primitives\Camera |
|
67
|
|
|
*/ |
|
68
|
2 |
|
public function far(float $far) |
|
69
|
|
|
{ |
|
70
|
2 |
|
$this->child() |
|
71
|
2 |
|
->entity() |
|
72
|
2 |
|
->component('Camera') |
|
73
|
2 |
|
->far($far); |
|
74
|
2 |
|
return $this; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* camera.fov |
|
79
|
|
|
* |
|
80
|
|
|
* @param float $fov |
|
81
|
|
|
* @return \AframeVR\Extras\Primitives\Camera |
|
82
|
|
|
*/ |
|
83
|
2 |
|
public function fov(float $fov) |
|
84
|
|
|
{ |
|
85
|
2 |
|
$this->child() |
|
86
|
2 |
|
->entity() |
|
87
|
2 |
|
->component('Camera') |
|
88
|
2 |
|
->fov($fov); |
|
89
|
2 |
|
return $this; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* look-controls.enabled |
|
94
|
|
|
* |
|
95
|
|
|
* @param bool $look_controls |
|
96
|
|
|
* @return \AframeVR\Extras\Primitives\Camera |
|
97
|
|
|
*/ |
|
98
|
2 |
|
public function lookControls(bool $look_controls) |
|
99
|
|
|
{ |
|
100
|
2 |
|
$this->child() |
|
101
|
2 |
|
->entity() |
|
102
|
2 |
|
->component('LookControls') |
|
103
|
2 |
|
->enabled($look_controls); |
|
104
|
2 |
|
return $this; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* camera.near |
|
109
|
|
|
* |
|
110
|
|
|
* @param float $near |
|
111
|
|
|
* @return \AframeVR\Extras\Primitives\Camera |
|
112
|
|
|
*/ |
|
113
|
2 |
|
public function near(float $near) |
|
114
|
|
|
{ |
|
115
|
2 |
|
$this->child() |
|
116
|
2 |
|
->entity() |
|
117
|
2 |
|
->component('Camera') |
|
118
|
2 |
|
->near($near); |
|
119
|
2 |
|
return $this; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* wasd-controls.enabled |
|
124
|
|
|
* |
|
125
|
|
|
* @param bool $wasd_controls |
|
126
|
|
|
* @return \AframeVR\Extras\Primitives\Camera |
|
127
|
|
|
*/ |
|
128
|
2 |
|
public function wasdControls(bool $wasd_controls = true) |
|
129
|
|
|
{ |
|
130
|
2 |
|
$this->child() |
|
131
|
2 |
|
->entity() |
|
132
|
2 |
|
->component('WASDControls') |
|
133
|
2 |
|
->enabled($wasd_controls); |
|
134
|
2 |
|
return $this; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* camera.zoom |
|
139
|
|
|
* |
|
140
|
|
|
* @param int|float $zoom |
|
|
|
|
|
|
141
|
|
|
* @return \AframeVR\Extras\Primitives\Camera |
|
142
|
|
|
*/ |
|
143
|
2 |
|
public function zoom(float $zoom) |
|
144
|
|
|
{ |
|
145
|
2 |
|
$this->child() |
|
146
|
2 |
|
->entity() |
|
147
|
2 |
|
->component('Camera') |
|
148
|
2 |
|
->zoom($zoom); |
|
149
|
2 |
|
return $this; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* Activate cursor |
|
154
|
|
|
* |
|
155
|
|
|
* @return \AframeVR\Extras\Primitives\Camera |
|
156
|
|
|
*/ |
|
157
|
2 |
|
public function cursor() |
|
158
|
|
|
{ |
|
159
|
2 |
|
$this->child() |
|
160
|
2 |
|
->entity() |
|
161
|
2 |
|
->child() |
|
162
|
2 |
|
->cursor(); |
|
163
|
2 |
|
return $this; |
|
164
|
|
|
} |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
|