1 | <?php |
||
33 | final class Scene |
||
34 | { |
||
35 | /* All scenes can use primitives */ |
||
36 | use Primitives; |
||
37 | |||
38 | /** |
||
39 | * Name with what you can retrieve this scene while working with multiple scenes |
||
40 | * |
||
41 | * @var string $name |
||
42 | */ |
||
43 | private $keyword; |
||
44 | |||
45 | /** |
||
46 | * Is scene prepared for rendering |
||
47 | * |
||
48 | * @var bool |
||
49 | */ |
||
50 | private $prepared; |
||
51 | |||
52 | /** |
||
53 | * Assets |
||
54 | * |
||
55 | * @var \AframeVR\Core\Assets |
||
56 | */ |
||
57 | protected $assets; |
||
58 | |||
59 | /** |
||
60 | * Aframe Document Object Model |
||
61 | * |
||
62 | * @var \AframeVR\Core\DOM\AframeDOMDocument |
||
63 | */ |
||
64 | protected $aframeDomObj; |
||
65 | |||
66 | /** |
||
67 | * Scene components |
||
68 | * |
||
69 | * @var array $components |
||
70 | */ |
||
71 | protected $components = array(); |
||
72 | |||
73 | /** |
||
74 | * Children Factory |
||
75 | * |
||
76 | * @var \AframeVR\Core\Helpers\EntityChildrenFactory |
||
77 | */ |
||
78 | protected $childrenFactory; |
||
79 | |||
80 | /** |
||
81 | * Extra scrits to add into head |
||
82 | * |
||
83 | * Like components and shaders |
||
84 | * |
||
85 | * @var array $scripts |
||
86 | */ |
||
87 | protected $scripts = array(); |
||
88 | |||
89 | /** |
||
90 | * Dom element attributes |
||
91 | * |
||
92 | * @var unknown |
||
93 | */ |
||
94 | protected $attrs = array(); |
||
95 | |||
96 | /** |
||
97 | * Scene constructor |
||
98 | * |
||
99 | * @param string $keyword |
||
100 | * @param Config $config |
||
101 | */ |
||
102 | 103 | public function __construct(string $keyword, Config $config) |
|
110 | |||
111 | /** |
||
112 | * Aframe Document Object Model |
||
113 | * |
||
114 | * @api |
||
115 | * |
||
116 | * @return \AframeVR\Core\DOM\AframeDOMDocument |
||
117 | */ |
||
118 | 2 | public function dom() |
|
122 | |||
123 | /** |
||
124 | * Assets |
||
125 | * |
||
126 | * @api |
||
127 | * |
||
128 | * @param null|Config $config |
||
129 | * @return \AframeVR\Core\Assets |
||
130 | */ |
||
131 | 103 | public function asset(Config $config = null): Assets |
|
135 | |||
136 | /** |
||
137 | * Child entity / primitive |
||
138 | * |
||
139 | * @return \AframeVR\Core\Helpers\EntityChildrenFactory |
||
140 | */ |
||
141 | 78 | public function el(): EntityChildrenFactory |
|
142 | { |
||
143 | 78 | return $this->childrenFactory; |
|
144 | } |
||
145 | |||
146 | /** |
||
147 | * Render the A-Frame scene and return the HTML |
||
148 | * |
||
149 | * @api |
||
150 | * |
||
151 | * @param bool $only_scene |
||
152 | * @return string |
||
153 | */ |
||
154 | 24 | public function save($only_scene = false, string $file = null): string |
|
164 | |||
165 | /** |
||
166 | * Render the A-Frame scene and passthru HTML |
||
167 | * |
||
168 | * @api |
||
169 | * |
||
170 | * @param bool $only_scene |
||
171 | * @return void |
||
172 | */ |
||
173 | 1 | public function render($only_scene = false) |
|
177 | |||
178 | /** |
||
179 | * Alias of AframeDOMDocument::setTitle(string) |
||
180 | * |
||
181 | * Set <title> tag |
||
182 | * $this->dom()->setTitle(string); |
||
183 | * |
||
184 | * @api |
||
185 | * |
||
186 | * @param string $title |
||
187 | */ |
||
188 | 1 | public function title(string $title) |
|
192 | |||
193 | /** |
||
194 | * Alias of AframeDOMDocument::setDescription(string) |
||
195 | * |
||
196 | * Set <meta name="description"> tag |
||
197 | * $this->dom()->setDescription(string); |
||
198 | * |
||
199 | * @api |
||
200 | * |
||
201 | * @param string $description |
||
202 | */ |
||
203 | 1 | public function description(string $description) |
|
207 | |||
208 | /** |
||
209 | * Get scenes keyword |
||
210 | * |
||
211 | * @return string |
||
212 | */ |
||
213 | 1 | public function getKeyword() |
|
217 | |||
218 | /** |
||
219 | * Load component for this scene or set it's attr |
||
220 | * |
||
221 | * @param string $component_name |
||
222 | * @param null|mixed $attr_data |
||
223 | * @throws \AframeVR\Core\Exceptions\BadComponentCallException |
||
224 | * @return object|null |
||
225 | */ |
||
226 | 3 | public function attr(string $component_name, $attr_data = null) |
|
244 | |||
245 | /** |
||
246 | * Add scripts like components and shaders |
||
247 | * |
||
248 | * @param string $path |
||
249 | * @return void |
||
250 | */ |
||
251 | 2 | public function addScript(string $path) |
|
255 | |||
256 | /** |
||
257 | * Map calls to scene entities and components |
||
258 | * |
||
259 | * Since we might need to customize these to have |
||
260 | * custom components loaded as $this->methosd aswell therefore |
||
261 | * we have these placeholder magic methods here |
||
262 | * |
||
263 | * @param string $method |
||
264 | * @param array $args |
||
265 | * @throws BadShaderCallException |
||
266 | * @return Entity|\AframeVR\Interfaces\ComponentInterface |
||
267 | */ |
||
268 | 80 | public function __call(string $method, array $args) |
|
279 | |||
280 | /** |
||
281 | * Add everyting to DOM |
||
282 | * |
||
283 | * @return void |
||
284 | */ |
||
285 | 24 | protected function prepare() |
|
307 | |||
308 | /** |
||
309 | * Append all assets |
||
310 | * |
||
311 | * @return void |
||
312 | */ |
||
313 | 24 | protected function prepareAssets() |
|
318 | |||
319 | /** |
||
320 | * Append extra scripts |
||
321 | * |
||
322 | * like extra components and shaders used in scene |
||
323 | * |
||
324 | * @return void |
||
325 | */ |
||
326 | 24 | protected function prepareScripts() |
|
330 | } |
||
331 |
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.
We recommend to add an additional type check (or disallow null for the parameter):