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 omponent.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\Rotation; |
25
|
|
|
|
26
|
|
|
use \AframeVR\Interfaces\Core\Components\Rotation\RotationInterface; |
27
|
|
|
use \AframeVR\Core\Helpers\ComponentAbstract; |
28
|
|
|
use \AframeVR\Core\Helpers\ComponentHelper; |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* AframeVR\Core\Components\Rotation |
33
|
|
|
* |
34
|
|
|
* The rotation component defines the orientation of an entity. |
35
|
|
|
* It takes the |
36
|
|
|
* roll (x), |
37
|
|
|
* pitch (y), |
38
|
|
|
* and yaw (z) |
39
|
|
|
* as three space-delimited numbers indicating degrees of rotation. |
40
|
|
|
*/ |
41
|
|
View Code Duplication |
class Component extends ComponentAbstract implements RotationInterface |
|
|
|
|
42
|
|
|
{ |
43
|
|
|
use ComponentHelper; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Initialize Component |
47
|
|
|
* |
48
|
|
|
* {@inheritdoc} |
49
|
|
|
* |
50
|
|
|
* @return bool |
51
|
|
|
*/ |
52
|
58 |
|
public function initializeComponent(): bool |
53
|
|
|
{ |
54
|
58 |
|
$this->setDomAttributeName('rotation'); |
55
|
58 |
|
return true; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Return DOM attribute contents |
60
|
|
|
* |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
4 |
|
public function getDomAttributeString(): string |
64
|
|
|
{ |
65
|
4 |
|
$attrs = $this->getDOMAttributesArray(); |
66
|
4 |
|
return $this->createCoordinateString($attrs['x'], $attrs['y'], $attrs['z']); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Get Rotation |
71
|
|
|
* |
72
|
|
|
* {@inheritdoc} |
73
|
|
|
* |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
1 |
|
public function getRotation(): string |
77
|
|
|
{ |
78
|
1 |
|
return $this->getDomAttributeString(); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.