Completed
Push — master ( 507e84...e8c35c )
by Marko
03:03
created

MeshAttributes::src()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 1
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jun 21, 2016 - 2:56:57 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         MeshAttributes.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\Helpers;
25
26
use \AframeVR\Interfaces\EntityInterface;
27
28
/**
29
 * Many of the primitives are entities that compose a geometric mesh, meaning they
30
 * primarily prescribe the geometry and material components.
31
 * Most of the mesh
32
 * primitives share common attributes, especially for mapping to the material component.
33
 * These common attributes won’t be described in individual
34
 * documentation pages for each primitive so they will be listed here
35
 */
36
trait MeshAttributes
37
{
38
39
    /**
40
     * Load component for this entity
41
     *
42
     * @param string $component_name            
43
     * @throws \AframeVR\Core\Exceptions\BadComponentCallException
44
     * @return object|null
45
     */
46
    abstract public function component(string $component_name);
47
48
    /**
49
     * material.color
50
     *
51
     * @param string $color            
52
     * @return EntityInterface
53
     */
54 8
    public function color(string $color): EntityInterface
55
    {
56 8
        $this->component('Material')
57 8
            ->shader()
58 8
            ->color($color);
59 8
        return $this;
60
    }
61
62
    /**
63
     * material.metalness
64
     *
65
     * @param int|float $metalness            
0 ignored issues
show
Documentation introduced by
Consider making the type for parameter $metalness a bit more specific; maybe use double.
Loading history...
66
     * @return EntityInterface
67
     */
68 2
    public function metalness(float $metalness): EntityInterface
69
    {
70 2
        $this->component('Material')
71 2
            ->shader()
72 2
            ->metalness($metalness);
73 2
        return $this;
74
    }
75
76
    /**
77
     * material.opacity
78
     *
79
     * @param float $opacity
80
     * @return EntityInterface
81
     */
82 2
    public function opacity(float $opacity): EntityInterface
83
    {
84 2
        $this->component('Material')->opacity($opacity);
85 2
        return $this;
86
    }
87
    
88
    /**
89
     * material.repeat
90
     * 
91
     * @param float $x
92
     * @param float $y
93
     * 
94
     * @return EntityInterface
95
     */
96 2
    public function repeat(float $x, float $y): EntityInterface
97
    {
98 2
        $this->component('Material')->repeat($x, $y);
99 2
        return $this;
100
    }
101
    
102
    /**
103
     * material.roughness
104
     *
105
     * @param float $roughness            
106
     * @return EntityInterface
107
     */
108 2
    public function roughness(float $roughness): EntityInterface
109
    {
110 2
        $this->component('Material')
111 2
            ->shader()
112 2
            ->roughness($roughness);
113 2
        return $this;
114
    }
115
116
    /**
117
     * material.shader
118
     *
119
     * @param string $shader
120
     * @return EntityInterface
121
     */
122 2
    public function shader($shader): EntityInterface
123
    {
124 2
        $this->component('Material')->shader($shader);
125 2
        return $this;
126
    }
127
    
128
    
129
    /**
130
     * material.src
131
     *
132
     * @param null|string $src            
133
     * @return EntityInterface
134
     */
135 2
    public function src(string $src = null): EntityInterface
136
    {
137 2
        $this->component('Material')
138 2
            ->shader()
139 2
            ->src($src);
140 2
        return $this;
141
    }
142
143
    /**
144
     * material.transparent
145
     *
146
     * @param bool $transparent            
147
     * @return EntityInterface
148
     */
149 4
    public function transparent(bool $transparent = false): EntityInterface
150
    {
151 4
        $this->component('Material')->transparent($transparent);
152 4
        return $this;
153
    }
154
}
155