1
|
|
|
<?php |
2
|
|
|
/** @formatter:off |
3
|
|
|
* ****************************************************************** |
4
|
|
|
* Created by Marko Kungla on Jul 7, 2016 - 3:29:20 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 KeyboardShortcutsComponent.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\ascene\KeyboardShortcuts; |
25
|
|
|
|
26
|
|
|
use \AframeVR\Interfaces\Core\Components\ascene\KeyboardShortcutsCMPTIF; |
27
|
|
|
use \AframeVR\Core\Helpers\ComponentAbstract; |
28
|
|
|
|
29
|
|
|
class KeyboardShortcutsComponent extends ComponentAbstract implements KeyboardShortcutsCMPTIF |
30
|
|
|
{ |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Initialize Component |
36
|
|
|
* |
37
|
|
|
* {@inheritdoc} |
38
|
|
|
* |
39
|
|
|
* @return bool |
40
|
|
|
*/ |
41
|
1 |
|
public function initializeComponent(): bool |
42
|
|
|
{ |
43
|
1 |
|
$this->setDomAttribute('keyboard-shortcuts'); |
44
|
1 |
|
$this->enterVR(); |
45
|
1 |
|
$this->resetSensor(); |
46
|
1 |
|
return true; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* enterVR |
52
|
|
|
* |
53
|
|
|
* Enables the shortcut to press ‘F’ to enter VR. |
54
|
|
|
* |
55
|
|
|
* @param bool $enter_vr |
56
|
|
|
* @return KeyboardShortcutsCMPTIF |
57
|
|
|
*/ |
58
|
1 |
|
public function enterVR(bool $enter_vr = true): KeyboardShortcutsCMPTIF |
59
|
|
|
{ |
60
|
1 |
|
$this->dom_attributes['enterVR'] = $enter_vr ? 'true' : 'false'; |
61
|
1 |
|
return $this; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* resetSensor |
66
|
|
|
* |
67
|
|
|
* Enables to shortcut to press ‘Z’ to reset the sensor. |
68
|
|
|
* |
69
|
|
|
* @param bool $reset_sensor |
70
|
|
|
* @return KeyboardShortcutsCMPTIF |
71
|
|
|
*/ |
72
|
1 |
|
public function resetSensor(bool $reset_sensor = true): KeyboardShortcutsCMPTIF |
73
|
|
|
{ |
74
|
1 |
|
$this->dom_attributes['resetSensor'] = $reset_sensor ? 'true' : 'false'; |
75
|
1 |
|
return $this; |
76
|
|
|
} |
77
|
|
|
} |