|
1
|
|
|
<?php |
|
2
|
|
|
/** @formatter:off |
|
3
|
|
|
* ****************************************************************** |
|
4
|
|
|
* Created by Marko Kungla on Jun 25, 2016 - 7:51:42 PM |
|
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 PositionComponent.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\Material; |
|
25
|
|
|
|
|
26
|
|
|
use \AframeVR\Core\Helpers\ComponentAbstract; |
|
27
|
|
|
use \AframeVR\Interfaces\ComponentInterface; |
|
28
|
|
|
use \AframeVR\Interfaces\Core\Components\Material\MaterialInterface; |
|
29
|
|
|
use \AframeVR\Core\Exceptions\BadShaderCallException; |
|
30
|
|
|
use \AframeVR\Interfaces\ShaderInterface; |
|
31
|
|
|
|
|
32
|
|
|
class Component extends ComponentAbstract implements ComponentInterface, MaterialInterface |
|
33
|
|
|
{ |
|
34
|
|
|
|
|
35
|
|
|
private $shaderObj; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Initialize Component |
|
39
|
|
|
* |
|
40
|
|
|
* {@inheritdoc} |
|
41
|
|
|
* |
|
42
|
|
|
* @return bool |
|
43
|
|
|
*/ |
|
44
|
32 |
|
public function initializeComponent(): bool |
|
45
|
|
|
{ |
|
46
|
32 |
|
$this->setDomAttributeName('material'); |
|
47
|
32 |
|
return true; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Return DOM attribute contents |
|
52
|
|
|
* |
|
53
|
|
|
* @return string |
|
54
|
|
|
*/ |
|
55
|
1 |
|
public function getDomAttributeString(): string |
|
56
|
|
|
{ |
|
57
|
1 |
|
$attrs = $this->getDOMAttributesArray(); |
|
|
|
|
|
|
58
|
1 |
|
return ''; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Material Shader |
|
63
|
|
|
* |
|
64
|
|
|
* {@inheritdoc} |
|
65
|
|
|
* |
|
66
|
|
|
* @param string $shader |
|
67
|
|
|
* @throws BadShaderCallException |
|
68
|
|
|
* @return object|null |
|
69
|
|
|
*/ |
|
70
|
12 |
|
public function shader(string $shader = 'standard') |
|
71
|
|
|
{ |
|
72
|
12 |
|
if ($this->shaderObj instanceof ShaderInterface) |
|
73
|
2 |
|
return $this->shaderObj; |
|
74
|
|
|
|
|
75
|
12 |
|
$shader = sprintf('\AframeVR\Core\Shaders\%s', ucfirst($shader)); |
|
76
|
12 |
|
if (class_exists($shader)) { |
|
77
|
11 |
|
$this->shaderObj = new $shader(); |
|
78
|
|
|
} else { |
|
79
|
1 |
|
throw new BadShaderCallException($shader); |
|
80
|
|
|
} |
|
81
|
11 |
|
return $this->shaderObj ?? null; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.