| 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\Interfaces\Extras\Primitives\CameraPrimitiveIF; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use \AframeVR\Core\Entity; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | class Camera extends Entity implements CameraPrimitiveIF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * Init <a-box> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * The box primitive, formerly called <a-cube>, creates shapes such as boxes, cubes, or walls. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      * It is an entity that prescribes the geometry with its geometric primitive set to box. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 | 7 |  |     public function init() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 7 |  |         $this->child()->entity()->component('Camera'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 | 7 |  |         $this->far(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 | 7 |  |         $this->fov(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 | 7 |  |         $this->lookControls(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 7 |  |         $this->wasdControls(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 7 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * Set defaults | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 7 |  |     public function defaults() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 7 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * camera.active | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      * @param bool $active             | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      * @return CameraPrimitiveIF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 | 1 |  |     public function active(bool $active = false): CameraPrimitiveIF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 | 1 |  |         $this->child() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 1 |  |             ->entity() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 1 |  |             ->component('Camera') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 1 |  |             ->active($active); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 1 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      * camera.far | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * @param int|float $far             | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * @return CameraPrimitiveIF | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 86 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 87 | 7 |  |     public function far(float $far = 10000): CameraPrimitiveIF | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 89 | 7 |  |         $this->child() | 
            
                                                                        
                            
            
                                    
            
            
                | 90 | 7 |  |             ->entity() | 
            
                                                                        
                            
            
                                    
            
            
                | 91 | 7 |  |             ->component('Camera') | 
            
                                                                        
                            
            
                                    
            
            
                | 92 | 7 |  |             ->far($far); | 
            
                                                                        
                            
            
                                    
            
            
                | 93 | 7 |  |         return $this; | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      * camera.fov | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |      * @param int|float $fov             | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |      * @return CameraPrimitiveIF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 | 7 |  |     public function fov(float $fov = 80): CameraPrimitiveIF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 | 7 |  |         $this->child() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 | 7 |  |             ->entity() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 | 7 |  |             ->component('Camera') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 | 7 |  |             ->fov($fov); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 | 7 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |      * look-controls.enabled | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |      * @param bool $look_controls             | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |      * @return CameraPrimitiveIF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 | 7 |  |     public function lookControls(bool $look_controls = true): CameraPrimitiveIF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 | 7 |  |         $this->child() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 | 7 |  |             ->entity() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 | 7 |  |             ->component('LookControls') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 | 7 |  |             ->enabled($look_controls); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 | 7 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |      * camera.near | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      * @param float $near             | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |      * @return CameraPrimitiveIF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 | 4 |  |     public function near(float $near = 0.5): CameraPrimitiveIF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 | 4 |  |         $this->child() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 | 4 |  |             ->entity() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 | 4 |  |             ->component('Camera') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 | 4 |  |             ->near($near); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 | 4 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |      * wasd-controls.enabled | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |      * @param bool $wasd_controls             | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |      * @return CameraPrimitiveIF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 | 7 |  |     public function wasdControls(bool $wasd_controls = true): CameraPrimitiveIF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 | 7 |  |         $this->child() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 | 7 |  |             ->entity() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 | 7 |  |             ->component('WASDControls') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 | 7 |  |             ->enabled($wasd_controls); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 | 7 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |      * camera.zoom | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |      * @param int|float $zoom             | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |      * @return CameraPrimitiveIF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 | 1 |  |     public function zoom(float $zoom = 1): CameraPrimitiveIF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 | 1 |  |         $this->child() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 | 1 |  |             ->entity() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 | 1 |  |             ->component('Camera') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 | 1 |  |             ->zoom($zoom); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 | 1 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |      * Camera child cursor entity | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |      *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |      * @return \AframeVR\Interfaces\Core\Components\CursorCMPTIF | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 | 1 |  |     public function cursor() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 | 1 |  |         return $this->child() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 | 1 |  |             ->entity() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 | 1 |  |             ->child() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 | 1 |  |             ->cursor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 194 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 195 |  |  |   | 
            
                        
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.