1
|
|
|
<?php |
2
|
|
|
/** @formatter:off |
3
|
|
|
* ****************************************************************** |
4
|
|
|
* Created by Marko Kungla on Jul 5, 2016 - 3:05:38 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 EntityChildrenFactory.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\Core\Entity; |
27
|
|
|
use \AframeVR\Extras\Primitives\{ |
28
|
|
|
Sphere, |
29
|
|
|
Box, |
30
|
|
|
Cylinder, |
31
|
|
|
Image, |
32
|
|
|
Plane, |
33
|
|
|
Sky, |
34
|
|
|
Camera, |
35
|
|
|
ColladaModel, |
36
|
|
|
Videosphere, |
37
|
|
|
Video, |
38
|
|
|
Torus, |
39
|
|
|
Ring, |
40
|
|
|
ObjModel, |
41
|
|
|
Curvedimage, |
42
|
|
|
Cursor, |
43
|
|
|
Light, |
44
|
|
|
Cone |
45
|
|
|
}; |
46
|
|
|
|
47
|
|
|
class EntityChildrenFactory |
48
|
|
|
{ |
49
|
|
|
/** |
50
|
|
|
* Child entities |
51
|
|
|
* |
52
|
|
|
* @var array |
53
|
|
|
*/ |
54
|
|
|
protected $childrens = array(); |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Entity |
58
|
|
|
* |
59
|
|
|
* @api |
60
|
|
|
* |
61
|
|
|
* @param string $id |
62
|
|
|
* @return \AframeVR\Core\Entity |
63
|
|
|
*/ |
64
|
7 |
|
public function entity(string $id = 'untitled'): Entity |
65
|
|
|
{ |
66
|
7 |
|
return $this->childrens[$id] ?? $this->childrens[$id] = new Entity($id); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* A-Frame Primitive box |
71
|
|
|
* |
72
|
|
|
* @param string $id |
73
|
|
|
* @return Entity |
74
|
|
|
*/ |
75
|
1 |
|
public function box(string $id = 'untitled'): Entity |
76
|
|
|
{ |
77
|
1 |
|
return $this->childrens[$id] ?? $this->childrens[$id] = new Box($id); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* A-Frame Primitive sphere |
82
|
|
|
* |
83
|
|
|
* @param string $id |
84
|
|
|
* @return Entity |
85
|
|
|
*/ |
86
|
1 |
|
public function sphere(string $id = 'untitled'): Entity |
87
|
|
|
{ |
88
|
1 |
|
return $this->childrens[$id] ?? $this->childrens[$id] = new Sphere($id); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* A-Frame Primitive cylinder |
93
|
|
|
* |
94
|
|
|
* @param string $id |
95
|
|
|
* @return Entity |
96
|
|
|
*/ |
97
|
1 |
|
public function cylinder(string $id = 'untitled'): Entity |
98
|
|
|
{ |
99
|
1 |
|
return $this->childrens[$id] ?? $this->childrens[$id] = new Cylinder($id); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* A-Frame Primitive plane |
104
|
|
|
* |
105
|
|
|
* @param string $id |
106
|
|
|
* @return Entity |
107
|
|
|
*/ |
108
|
4 |
|
public function plane(string $id = 'untitled'): Entity |
109
|
|
|
{ |
110
|
4 |
|
return $this->childrens[$id] ?? $this->childrens[$id] = new Plane($id); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* A-Frame Primitive camera |
115
|
|
|
* |
116
|
|
|
* @param string $id |
117
|
|
|
* @return Entity |
118
|
|
|
*/ |
119
|
1 |
|
public function camera(string $id = 'untitled'): Entity |
120
|
|
|
{ |
121
|
1 |
|
return $this->childrens[$id] ?? $this->childrens[$id] = new Camera($id); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* A-Frame Primitive collada-model |
126
|
|
|
* |
127
|
|
|
* @param string $id |
128
|
|
|
* @return Entity |
129
|
|
|
*/ |
130
|
1 |
|
public function colladaModel(string $id = 'untitled'): Entity |
131
|
|
|
{ |
132
|
1 |
|
return $this->childrens[$id] ?? $this->childrens[$id] = new ColladaModel($id); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* A-Frame Primitive image |
137
|
|
|
* |
138
|
|
|
* @param string $id |
139
|
|
|
* @return Entity |
140
|
|
|
*/ |
141
|
4 |
|
public function image(string $id = 'untitled'): Entity |
142
|
|
|
{ |
143
|
4 |
|
return $this->childrens[$id] ?? $this->childrens[$id] = new Image($id); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* A-Frame Primitive light |
148
|
|
|
* |
149
|
|
|
* @param string $id |
150
|
|
|
* @return Entity |
151
|
|
|
*/ |
152
|
1 |
|
public function light(string $id = 'untitled'): Entity |
153
|
|
|
{ |
154
|
1 |
|
return $this->childrens[$id] ?? $this->childrens[$id] = new Light($id); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* A-Frame Primitive video |
159
|
|
|
* |
160
|
|
|
* @param string $id |
161
|
|
|
* @return Entity |
162
|
|
|
*/ |
163
|
1 |
|
public function video(string $id = 'untitled'): Entity |
164
|
|
|
{ |
165
|
1 |
|
return $this->childrens[$id] ?? $this->childrens[$id] = new Video($id); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* A-Frame Primitive torus |
170
|
|
|
* |
171
|
|
|
* @param string $id |
172
|
|
|
* @return Entity |
173
|
|
|
*/ |
174
|
1 |
|
public function torus(string $id = 'untitled'): Entity |
175
|
|
|
{ |
176
|
1 |
|
return $this->childrens[$id] ?? $this->childrens[$id] = new Torus($id); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* A-Frame Primitive ring |
181
|
|
|
* |
182
|
|
|
* @param string $id |
183
|
|
|
* @return Entity |
184
|
|
|
*/ |
185
|
1 |
|
public function ring(string $id = 'untitled'): Entity |
186
|
|
|
{ |
187
|
1 |
|
return $this->childrens[$id] ?? $this->childrens[$id] = new Ring($id); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* A-Frame Primitive obj model |
193
|
|
|
* |
194
|
|
|
* @return Entity |
195
|
|
|
*/ |
196
|
1 |
|
public function objmodel(string $id = 'untitled'): Entity |
197
|
|
|
{ |
198
|
1 |
|
return $this->childrens[$id] ?? $this->childrens[$id] = new ObjModel($id); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* A-Frame Primitive curvedimage |
203
|
|
|
* |
204
|
|
|
* @return Entity |
205
|
|
|
*/ |
206
|
1 |
|
public function curvedimage(string $id = 'untitled'): Entity |
207
|
|
|
{ |
208
|
1 |
|
return $this->childrens[$id] ?? $this->childrens[$id] = new Curvedimage($id); |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* A-Frame Primitive curvedimage |
213
|
|
|
* |
214
|
|
|
* @return Entity |
215
|
|
|
*/ |
216
|
1 |
|
public function cursor(string $id = 'untitled'): Entity |
217
|
|
|
{ |
218
|
1 |
|
return $this->childrens[$id] ?? $this->childrens[$id] = new Cursor($id); |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* A-Frame Primitive cone |
223
|
|
|
* |
224
|
|
|
* @return Entity |
225
|
|
|
*/ |
226
|
1 |
|
public function cone(string $id = 'untitled'): Entity |
227
|
|
|
{ |
228
|
1 |
|
return $this->childrens[$id] ?? $this->childrens[$id] = new Cone($id); |
229
|
|
|
} |
230
|
|
|
|
231
|
2 |
|
public function getChildern() |
232
|
|
|
{ |
233
|
2 |
|
return $this->childrens; |
234
|
|
|
} |
235
|
|
|
} |