Completed
Pull Request — master (#63)
by Marko
03:19
created

Camera::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
crap 1
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 1
    public function reset()
41
    {
42 1
        parent::reset();
43 1
        $this->child()->entity()->component('Camera');
44 1
        $this->active(false);
45 1
        $this->far(10000);
46 1
        $this->fov(80);
47 1
        $this->lookControls(true);
48 1
        $this->wasdControls(true);
49 1
        $this->near(0.5);
50 1
        $this->zoom(1);
51 1
    }
52
53
    /**
54
     * camera.active
55
     *
56
     * @param bool $active            
57
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

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.

Loading history...
58
     */
59 1
    public function active(bool $active): self
60
    {
61 1
        $this->child()
62 1
            ->entity()
63 1
            ->component('Camera')
64 1
            ->active($active);
65 1
        return $this;
66
    }
67
68
    /**
69
     * camera.far
70
     *
71
     * @param float $far            
72
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

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.

Loading history...
73
     */
74 1
    public function far(float $far): self
75
    {
76 1
        $this->child()
77 1
            ->entity()
78 1
            ->component('Camera')
79 1
            ->far($far);
80 1
        return $this;
81
    }
82
83
    /**
84
     * camera.fov
85
     *
86
     * @param float $fov            
87
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

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.

Loading history...
88
     */
89 1
    public function fov(float $fov): self
90
    {
91 1
        $this->child()
92 1
            ->entity()
93 1
            ->component('Camera')
94 1
            ->fov($fov);
95 1
        return $this;
96
    }
97
98
    /**
99
     * look-controls.enabled
100
     *
101
     * @param bool $look_controls            
102
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

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.

Loading history...
103
     */
104 1
    public function lookControls(bool $look_controls): self
105
    {
106 1
        $this->child()
107 1
            ->entity()
108 1
            ->component('LookControls')
109 1
            ->enabled($look_controls);
110 1
        return $this;
111
    }
112
113
    /**
114
     * camera.near
115
     *
116
     * @param float $near            
117
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

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.

Loading history...
118
     */
119 1
    public function near(float $near): self
120
    {
121 1
        $this->child()
122 1
            ->entity()
123 1
            ->component('Camera')
124 1
            ->near($near);
125 1
        return $this;
126
    }
127
128
    /**
129
     * wasd-controls.enabled
130
     *
131
     * {@inheritdoc}
132
     *
133
     * @param bool $wasd_controls            
134
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

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.

Loading history...
135
     */
136 1
    public function wasdControls(bool $wasd_controls = true): self
137
    {
138 1
        $this->child()
139 1
            ->entity()
140 1
            ->component('WASDControls')
141 1
            ->enabled($wasd_controls);
142 1
        return $this;
143
    }
144
145
    /**
146
     * camera.zoom
147
     *
148
     * {@inheritdoc}
149
     *
150
     * @param int|float $zoom            
0 ignored issues
show
Documentation introduced by
Consider making the type for parameter $zoom a bit more specific; maybe use double.
Loading history...
151
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

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.

Loading history...
152
     */
153 1
    public function zoom(float $zoom): self
154
    {
155 1
        $this->child()
156 1
            ->entity()
157 1
            ->component('Camera')
158 1
            ->zoom($zoom);
159 1
        return $this;
160
    }
161
162
    /**
163
     * Camera child cursor entity
164
     *
165
     * @return \AframeVR\Interfaces\Core\Components\CursorCMPTIF
0 ignored issues
show
Documentation introduced by
Should the return type not be Entity?

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.

Loading history...
166
     */
167
    public function cursor()
168
    {
169
        return $this->child()
170
            ->entity()
171
            ->child()
172
            ->cursor();
173
    }
174
}
175
176