CameraComponent::zoom()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jul 4, 2016 - 1:16:14 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         CameraComponent.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\Camera;
25
26
use \AframeVR\Interfaces\Core\Components\CameraCMPTIF;
27
use \AframeVR\Core\Helpers\ComponentAbstract;
28
29
class CameraComponent extends ComponentAbstract implements CameraCMPTIF
30
{
31
32
    /**
33
     * Initialize Component
34
     *
35
     * {@inheritdoc}
36
     *
37
     * @return bool
38
     */
39 4
    public function initializeComponent(): bool
40
    {
41 4
        $this->setDomAttribute('camera');
42 4
        $this->active(true);
43 4
        $this->far(10000);
44 4
        $this->fov(80);
45 4
        $this->near(0.5);
46 4
        $this->zoom(1);
47 4
        return true;
48
    }
49
50
    /**
51
     * Camera active
52
     *
53
     * {@inheritdoc}
54
     *
55
     * @param bool $active
56
     * @return CameraCMPTIF
57
     */
58 4
    public function active(bool $active = false): CameraCMPTIF
59
    {
60 4
        $this->dom_attributes['active'] = $active ? 'true' : 'false';
61 4
        return $this;
62
    }
63
64
    /**
65
     * Camera frustum far clipping plane.
66
     *
67
     * {@inheritdoc}
68
     *
69
     * @param float $far
70
     * @return CameraCMPTIF
71
     */
72 4
    public function far(float $far): CameraCMPTIF
73
    {
74 4
        $this->dom_attributes['far'] = $far;
75 4
        return $this;
76
    }
77
78
    /**
79
     * Field of view (in degrees).
80
     *
81
     * {@inheritdoc}
82
     *
83
     * @param float $fov
84
     * @return CameraCMPTIF
85
     */
86 4
    public function fov(float $fov): CameraCMPTIF
87
    {
88 4
        $this->dom_attributes['fov'] = $fov;
89 4
        return $this;
90
    }
91
92
    /**
93
     * Camera frustum near clipping plane.
94
     *
95
     * {@inheritdoc}
96
     *
97
     * @param float $near
98
     * @return CameraCMPTIF
99
     */
100 4
    public function near(float $near): CameraCMPTIF
101
    {
102 4
        $this->dom_attributes['near'] = $near;
103 4
        return $this;
104
    }
105
106
    /**
107
     * Camera zoom
108
     *
109
     * {@inheritdoc}
110
     *
111
     * @param float $zoom
112
     * @return CameraCMPTIF
113
     */
114 4
    public function zoom(float $zoom): CameraCMPTIF
115
    {
116 4
        $this->dom_attributes['zoom'] = $zoom;
117 4
        return $this;
118
    }
119
}