1
|
|
|
<?php |
2
|
|
|
/** @formatter:off |
3
|
|
|
* ****************************************************************** |
4
|
|
|
* Created by Marko Kungla on Jun 21, 2016 - 2:19:19 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 Flat.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 Flat extends ShaderAbstract implements ShaderInterface |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* Shader |
33
|
|
|
* |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
protected $shader = 'flat'; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Base diffuse color. |
40
|
|
|
* |
41
|
|
|
* @var string $color |
42
|
|
|
*/ |
43
|
|
|
protected $color = '#fff'; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Whether or not material is affected by fog. |
47
|
|
|
* |
48
|
|
|
* @var string $fog |
49
|
|
|
*/ |
50
|
|
|
protected $fog = 'true'; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Height of video (in pixels), if defining a video texture. |
54
|
|
|
* |
55
|
|
|
* @var int $height |
56
|
|
|
*/ |
57
|
|
|
protected $height = 360; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Image or video texture map. |
61
|
|
|
* Can either be a selector to an <img> or <video>, or an inline URL. |
62
|
|
|
* |
63
|
|
|
* @var string|null $src |
64
|
|
|
*/ |
65
|
|
|
protected $src = null; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Width of video (in pixels), if defining a video texture. |
69
|
|
|
* |
70
|
|
|
* @var int $width |
71
|
|
|
*/ |
72
|
|
|
protected $width = 640; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Set shader defaults |
76
|
|
|
* |
77
|
|
|
* @return void |
78
|
|
|
*/ |
79
|
1 |
|
public function defaults() |
80
|
|
|
{ |
81
|
1 |
|
$this->color('#fff'); |
82
|
1 |
|
$this->fog(true); |
83
|
1 |
|
$this->height(360); |
84
|
1 |
|
$this->src(); |
85
|
1 |
|
$this->width(640); |
86
|
1 |
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Base diffuse color |
90
|
|
|
* |
91
|
|
|
* @param string $color |
92
|
|
|
*/ |
93
|
7 |
|
public function color(string $color) |
94
|
|
|
{ |
95
|
7 |
|
$this->color = $color; |
96
|
7 |
|
return $this; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Whether or not material is affected by fog. |
101
|
|
|
* |
102
|
|
|
* @param bool $fog |
103
|
|
|
*/ |
104
|
1 |
|
public function fog(bool $fog) |
105
|
|
|
{ |
106
|
1 |
|
$this->fog = $fog ? 'true' : 'false'; |
107
|
1 |
|
return $this; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Height of video (in pixels), if defining a video texture. |
112
|
|
|
* |
113
|
|
|
* @param int $height |
114
|
|
|
*/ |
115
|
1 |
|
public function height(int $height) |
116
|
|
|
{ |
117
|
1 |
|
$this->height = $height; |
118
|
1 |
|
return $this; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* How many times a texture (defined by src) repeats in the X and Y direction. |
123
|
|
|
* |
124
|
|
|
* @param null|string $src |
125
|
|
|
*/ |
126
|
1 |
|
public function src(string $src = null) |
127
|
|
|
{ |
128
|
1 |
|
$this->src = $src; |
129
|
1 |
|
return $this; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Width of video (in pixels), if defining a video texture. |
134
|
|
|
* |
135
|
|
|
* @param int $width |
136
|
|
|
*/ |
137
|
1 |
|
public function width(int $width) |
138
|
|
|
{ |
139
|
1 |
|
$this->width = $width; |
140
|
1 |
|
return $this; |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
|