1 | <?php |
||
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 | 2 | public function color(string $color = 'gray'): EntityInterface |
|
61 | |||
62 | /** |
||
63 | * material.metalness |
||
64 | * |
||
65 | * @param int|float $metalness |
||
66 | * @return EntityInterface |
||
67 | */ |
||
68 | public function metalness(float $metalness = 0): EntityInterface |
||
69 | { |
||
70 | $this->component('Material') |
||
71 | ->shader() |
||
72 | ->metalness($metalness); |
||
73 | return $this; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * material.roughness |
||
78 | * |
||
79 | * @param float $roughness |
||
80 | * @return EntityInterface |
||
81 | */ |
||
82 | public function roughness(float $roughness = 0.5): EntityInterface |
||
83 | { |
||
84 | $this->component('Material') |
||
85 | ->shader() |
||
86 | ->roughness($roughness); |
||
87 | return $this; |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * material.src |
||
92 | * |
||
93 | * @param null|string $src |
||
94 | * @return EntityInterface |
||
95 | */ |
||
96 | public function src(string $src = null): EntityInterface |
||
97 | { |
||
98 | $this->component('Material') |
||
99 | ->shader() |
||
100 | ->src($src); |
||
101 | return $this; |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * geometry.translate |
||
106 | * |
||
107 | * @param int|float $x |
||
108 | * @param int|float $y |
||
109 | * @param int|float $z |
||
110 | * @return EntityInterface |
||
111 | */ |
||
112 | public function translate(float $x = 0, float $y = 0, float $z = 0): EntityInterface |
||
113 | { |
||
114 | $this->component('Geometry')->translate($x, $y, $z); |
||
115 | return $this; |
||
116 | } |
||
117 | |||
118 | /** |
||
119 | * material.shader |
||
120 | * |
||
121 | * @param string $shader |
||
122 | * @return EntityInterface |
||
123 | */ |
||
124 | public function shader($shader = 'standard'): EntityInterface |
||
125 | { |
||
126 | $this->component('Material')->shader($shader); |
||
127 | return $this; |
||
128 | } |
||
129 | |||
130 | /** |
||
131 | * material.opacity |
||
132 | * |
||
133 | * @param float $opacity |
||
134 | * @return EntityInterface |
||
135 | */ |
||
136 | public function opacity(float $opacity = 1.0): EntityInterface |
||
137 | { |
||
138 | $this->component('Material')->opacity($opacity); |
||
139 | return $this; |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * material.transparent |
||
144 | * |
||
145 | * @param bool $transparent |
||
146 | * @return EntityInterface |
||
147 | */ |
||
148 | 2 | public function transparent(bool $transparent = false): EntityInterface |
|
153 | } |
||
154 |