Completed
Push — master ( 3cba45...aa7888 )
by Marko
02:18
created

Standard::src()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 2
b 1
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jun 21, 2016 - 1:53:21 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         Standard.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\Shaders;
25
26
use \AframeVR\Interfaces\ShaderInterface;
27
use \AframeVR\Core\Helpers\ShaderAbstract;
28
29
class Standard extends ShaderAbstract implements ShaderInterface
30
{
31
32
    /**
33
     * Base diffuse color.
34
     *
35
     * @var string $color
36
     */
37
    public $color = '#fff';
38
39
    /**
40
     * Height of video (in pixels), if defining a video texture.
41
     *
42
     * @var int $height
43
     */
44
    public $height = 360;
45
46
    /**
47
     * Environment cubemap texture for reflections.
48
     *
49
     * Can be a selector to or a comma-separated list of URLs.
50
     *
51
     * @var string|null $envMap
52
     */
53
    public $envMap = null;
54
55
    /**
56
     * Whether or not material is affected by fog.
57
     *
58
     * @var string $fog
59
     */
60
    public $fog = 'true';
61
62
    /**
63
     * How metallic the material is from 0 to 1.
64
     *
65
     * @var float $metalness
66
     */
67
    public $metalness = 0.5;
68
69
    /**
70
     * How many times a texture (defined by src) repeats in the X and Y direction.
71
     *
72
     * @var string $repeat
73
     */
74
    public $repeat = '1 1';
75
76
    /**
77
     * How rough the material is from 0 to 1.
78
     * A rougher material will scatter
79
     * reflected light in more directions than a smooth material.
80
     *
81
     * @var float $roughness
82
     */
83
    public $roughness = 0.5;
84
85
    /**
86
     * Image or video texture map.
87
     * Can either be a selector to an <img> or <video>, or an inline URL.
88
     *
89
     * @var string|null $src
90
     */
91
    public $src = null;
92
93
    /**
94
     * Width of video (in pixels), if defining a video texture.
95
     *
96
     * @var int $width
97
     */
98
    public $width = 640;
99
100
    /**
101
     * Construct and set shader defaults
102
     */
103 13
    public function __construct()
104
    {
105 13
        $this->color('#fff');
106 13
        $this->height(360);
107 13
        $this->envMap();
108 13
        $this->fog(true);
109 13
        $this->metalness(0.5);
110 13
        $this->repeat(1, 1);
111 13
        $this->roughness(0.5);
112 13
        $this->src();
113 13
        $this->width(640);
114 13
    }
115
116
    /**
117
     * Base diffuse color
118
     *
119
     * @param string $color            
120
     */
121 13
    public function color(string $color)
122
    {
123 13
        $this->color = $color;
124 13
    }
125
126
    /**
127
     * Height of video (in pixels), if defining a video texture.
128
     *
129
     * @param int $height            
130
     */
131 13
    public function height($height)
132
    {
133 13
        $this->height = $height;
134 13
    }
135
136
    /**
137
     * envMap
138
     *
139
     * Environment cubemap texture for reflections.
140
     * Can be a selector to or a comma-separated list of URLs.
141
     *
142
     * @param string|null $envMap            
143
     */
144 13
    public function envMap(string $envMap = null)
145
    {
146 13
        $this->envMap = $envMap;
147 13
    }
148
149
    /**
150
     * Whether or not material is affected by fog.
151
     *
152
     * @param bool $fog            
153
     */
154 13
    public function fog($fog)
155
    {
156 13
        $this->fog = $fog ? 'true' : 'false';
157 13
    }
158
159
    /**
160
     * How metallic the material is from 0 to 1.
161
     *
162
     * @param float $metalness            
163
     */
164 13
    public function metalness($metalness)
165
    {
166 13
        $this->metalness = $metalness;
167 13
    }
168
169
    /**
170
     * repeat
171
     *
172
     * @param int|float $x            
0 ignored issues
show
Documentation introduced by
Consider making the type for parameter $x a bit more specific; maybe use double.
Loading history...
173
     * @param int|float $y            
0 ignored issues
show
Documentation introduced by
Consider making the type for parameter $y a bit more specific; maybe use double.
Loading history...
174
     */
175 13
    public function repeat(float $x, float $y)
176
    {
177 13
        $this->repeat = sprintf('%d %d', $x, $y);
178 13
    }
179
180
    /**
181
     * How rough the material is from 0 to 1
182
     *
183
     * A rougher material will scatter reflected light in more directions than a smooth material.
184
     *
185
     * @param float $roughness            
186
     */
187 13
    public function roughness(float $roughness)
188
    {
189 13
        $this->roughness = $roughness;
190 13
    }
191
192
    /**
193
     * How many times a texture (defined by src) repeats in the X and Y direction.
194
     *
195
     * @param string|null $src            
196
     */
197 13
    public function src(string $src = null)
198
    {
199 13
        $this->src = $src;
200 13
    }
201
202
    /**
203
     * Width of video (in pixels), if defining a video texture.
204
     *
205
     * @param int $width            
206
     */
207 13
    public function width(int $width)
208
    {
209 13
        $this->width = $width;
210 13
    }
211
}
212