Code Duplication    Length = 86-87 lines in 2 locations

src/Core/Components/Raycaster/RaycasterComponent.php 1 location

@@ 29-115 (lines=87) @@
26
use \AframeVR\Interfaces\Core\Components\RaycasterCMPTIF;
27
use \AframeVR\Core\Helpers\ComponentAbstract;
28
29
class RaycasterComponent extends ComponentAbstract implements RaycasterCMPTIF
30
{
31
32
    /**
33
     * Initialize Component
34
     *
35
     * {@inheritdoc}
36
     *
37
     * @return bool
38
     */
39
    public function initializeComponent(): bool
40
    {
41
        $this->setDomAttribute('raycaster');
42
        return true;
43
    }
44
45
    /**
46
     * Maximum distance
47
     *
48
     * Maximum distance under which resulting entities are returned. Cannot be lower then near.
49
     *
50
     * @param string $distance            
51
     * @return RaycasterCMPTIF
52
     */
53
    public function far(string $distance = 'Infinity'): RaycasterCMPTIF
54
    {
55
        $this->dom_attributes['far'] = $distance;
56
        return $this;
57
    }
58
59
    /**
60
     * Number of milliseconds
61
     *
62
     * Number of milliseconds to wait in between each intersection test. Lower number is better for faster updates.
63
     * Higher number is better for performance.
64
     *
65
     * @param int $ms            
66
     * @return RaycasterCMPTIF
67
     */
68
    public function interval(int $ms = 100): RaycasterCMPTIF
69
    {
70
        $this->dom_attributes['interval'] = $ms;
71
        return $this;
72
    }
73
74
    /**
75
     * Minimum distance
76
     *
77
     * Minimum distance over which resuilting entities are returned. Cannot be lower than 0.
78
     *
79
     * @param int $distance            
80
     * @return RaycasterCMPTIF
81
     */
82
    public function near(int $distance = 0): RaycasterCMPTIF
83
    {
84
        $this->dom_attributes['near'] = $distance;
85
        return $this;
86
    }
87
88
    /**
89
     * Query selector
90
     *
91
     * Query selector to pick which objects to test for intersection. If not specified, all entities will be tested.
92
     *
93
     * @param null|string $selector            
94
     * @return RaycasterCMPTIF
95
     */
96
    public function objects(string $selector = null): RaycasterCMPTIF
97
    {
98
        $this->dom_attributes['objects'] = $selector;
99
        return $this;
100
    }
101
102
    /**
103
     * Recursive
104
     *
105
     * Checks all children of objects if set. Else only checks intersections with root objects.
106
     *
107
     * @param bool $r            
108
     * @return RaycasterCMPTIF
109
     */
110
    public function recursive(bool $r = true): RaycasterCMPTIF
111
    {
112
        $this->dom_attributes['recursive'] = $r ? 'true' : 'false';
113
        return $this;
114
    }
115
}
116

src/Core/Components/Sound/SoundComponent.php 1 location

@@ 29-114 (lines=86) @@
26
use \AframeVR\Interfaces\Core\Components\SoundCMPTIF;
27
use \AframeVR\Core\Helpers\ComponentAbstract;
28
29
class SoundComponent extends ComponentAbstract implements SoundCMPTIF
30
{
31
32
    /**
33
     * Initialize Component
34
     *
35
     * {@inheritdoc}
36
     *
37
     * @return bool
38
     */
39
    public function initializeComponent(): bool
40
    {
41
        $this->setDomAttribute('sound');
42
        return true;
43
    }
44
45
    /**
46
     * Autoplay sound
47
     *
48
     * Whether to automatically play sound once set.
49
     *
50
     * @param bool $autoplay            
51
     * @return SoundCMPTIF
52
     */
53
    public function autoplay(bool $autoplay = false): SoundCMPTIF
54
    {
55
        $this->dom_attributes['autoplay'] = $autoplay ? 'true' : 'false';
56
        return $this;
57
    }
58
59
    /**
60
     * Play event
61
     *
62
     * An event for the entity to listen to before playing sound.
63
     *
64
     * @param string $event            
65
     * @return SoundCMPTIF
66
     */
67
    public function on(string $event = 'click'): SoundCMPTIF
68
    {
69
        $this->dom_attributes['on'] = $event;
70
        return $this;
71
    }
72
73
    /**
74
     * Loop sound
75
     *
76
     * Whether to loop the sound once the sound finishes playing.
77
     *
78
     * @param bool $loop            
79
     * @return SoundCMPTIF
80
     */
81
    public function loop(bool $loop = false): SoundCMPTIF
82
    {
83
        $this->dom_attributes['loop'] = $loop ? 'true' : 'false';
84
        return $this;
85
    }
86
87
    /**
88
     * Audio source
89
     *
90
     * Path to sound file.
91
     *
92
     * @param null|string $src            
93
     * @return SoundCMPTIF
94
     */
95
    public function src(string $src = null): SoundCMPTIF
96
    {
97
        $this->dom_attributes['src'] = $src;
98
        return $this;
99
    }
100
101
    /**
102
     * Volume
103
     *
104
     * How loud to play the sound.
105
     *
106
     * @param int|float $vol            
107
     * @return SoundCMPTIF
108
     */
109
    public function volume(float $vol = 1): SoundCMPTIF
110
    {
111
        $this->dom_attributes['volume'] = $vol;
112
        return $this;
113
    }
114
}