|
1
|
|
|
<?php |
|
2
|
|
|
/** @formatter:off |
|
3
|
|
|
* ****************************************************************** |
|
4
|
|
|
* Created by Marko Kungla on Jul 4, 2016 - 3:21:00 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 WASDControlsComponent.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\WASDControls; |
|
25
|
|
|
|
|
26
|
|
|
use \AframeVR\Interfaces\Core\Components\WASDControlsCMPTIF; |
|
27
|
|
|
use \AframeVR\Core\Helpers\ComponentAbstract; |
|
28
|
|
|
|
|
29
|
|
|
class WASDControlsComponent extends ComponentAbstract implements WASDControlsCMPTIF |
|
30
|
|
|
{ |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Initialize Component |
|
34
|
|
|
* |
|
35
|
|
|
* {@inheritdoc} |
|
36
|
|
|
* |
|
37
|
|
|
* @return bool |
|
38
|
|
|
*/ |
|
39
|
7 |
|
public function initializeComponent(): bool |
|
40
|
|
|
{ |
|
41
|
7 |
|
$this->setDomAttribute('wasd-controls'); |
|
42
|
7 |
|
return true; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Entity acceleration |
|
47
|
|
|
* |
|
48
|
|
|
* {@inheritdoc} |
|
49
|
|
|
* |
|
50
|
|
|
* @param int $acceleration |
|
51
|
|
|
* @return WASDControlsCMPTIF |
|
52
|
|
|
*/ |
|
53
|
2 |
|
public function acceleration(int $acceleration = 65): WASDControlsCMPTIF |
|
54
|
|
|
{ |
|
55
|
2 |
|
$this->dom_attributes['acceleration'] = $acceleration; |
|
56
|
2 |
|
return $this; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* AD Axis |
|
61
|
|
|
* |
|
62
|
|
|
* {@inheritdoc} |
|
63
|
|
|
* |
|
64
|
|
|
* @param string $axis |
|
65
|
|
|
* @return WASDControlsCMPTIF |
|
66
|
|
|
*/ |
|
67
|
1 |
|
public function adAxis(string $axis = 'x'): WASDControlsCMPTIF |
|
68
|
|
|
{ |
|
69
|
1 |
|
$this->dom_attributes['adAxis'] = $axis; |
|
70
|
1 |
|
return $this; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* AD Inverted |
|
75
|
|
|
* |
|
76
|
|
|
* {@inheritdoc} |
|
77
|
|
|
* |
|
78
|
|
|
* @param bool $inverted |
|
79
|
|
|
* @return WASDControlsCMPTIF |
|
80
|
|
|
*/ |
|
81
|
1 |
|
public function adInverted(bool $inverted = false): WASDControlsCMPTIF |
|
82
|
|
|
{ |
|
83
|
1 |
|
$this->dom_attributes['adInverted'] = $inverted; |
|
84
|
1 |
|
return $this; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Easing |
|
89
|
|
|
* |
|
90
|
|
|
* {@inheritdoc} |
|
91
|
|
|
* |
|
92
|
|
|
* @param int $easing |
|
93
|
|
|
* @return WASDControlsCMPTIF |
|
94
|
|
|
*/ |
|
95
|
1 |
|
public function easing(int $easing = 20): WASDControlsCMPTIF |
|
96
|
|
|
{ |
|
97
|
1 |
|
$this->dom_attributes['easing'] = $easing; |
|
98
|
1 |
|
return $this; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Enaled |
|
103
|
|
|
* |
|
104
|
|
|
* {@inheritdoc} |
|
105
|
|
|
* |
|
106
|
|
|
* @param bool $enabled |
|
107
|
|
|
* @return WASDControlsCMPTIF |
|
108
|
|
|
*/ |
|
109
|
4 |
|
public function enabled(bool $enabled = true): WASDControlsCMPTIF |
|
110
|
|
|
{ |
|
111
|
4 |
|
$this->dom_attributes['enabled'] = $enabled ? 'true' : 'false'; |
|
112
|
4 |
|
return $this; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* Fly |
|
117
|
|
|
* |
|
118
|
|
|
* {@inheritdoc} |
|
119
|
|
|
* |
|
120
|
|
|
* @param bool $fly |
|
121
|
|
|
* @return WASDControlsCMPTIF |
|
122
|
|
|
*/ |
|
123
|
1 |
|
public function fly(bool $fly = false): WASDControlsCMPTIF |
|
124
|
|
|
{ |
|
125
|
1 |
|
$this->dom_attributes['fly'] = $fly ? 'true' : 'false'; |
|
126
|
1 |
|
return $this; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* WS Axis |
|
131
|
|
|
* |
|
132
|
|
|
* {@inheritdoc} |
|
133
|
|
|
* |
|
134
|
|
|
* @param string $axis |
|
135
|
|
|
* @return WASDControlsCMPTIF |
|
136
|
|
|
*/ |
|
137
|
1 |
|
public function wsAxis(string $axis = 'z'): WASDControlsCMPTIF |
|
138
|
|
|
{ |
|
139
|
1 |
|
$this->dom_attributes['wsAxis'] = $axis; |
|
140
|
1 |
|
return $this; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* WS Inverted |
|
145
|
|
|
* |
|
146
|
|
|
* {@inheritdoc} |
|
147
|
|
|
* |
|
148
|
|
|
* @param bool $inverted |
|
149
|
|
|
* @return WASDControlsCMPTIF |
|
150
|
|
|
*/ |
|
151
|
1 |
|
public function wsInverted(bool $inverted = false): WASDControlsCMPTIF |
|
152
|
|
|
{ |
|
153
|
1 |
|
$this->dom_attributes['wsInverted'] = $inverted ? 'true' : 'false'; |
|
154
|
1 |
|
return $this; |
|
155
|
|
|
} |
|
156
|
|
|
} |
|
157
|
|
|
|