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 | * Scene constructor |
||
91 | * |
||
92 | * @param string $keyword |
||
93 | * @param Config $config |
||
94 | */ |
||
95 | 98 | public function __construct(string $keyword, Config $config) |
|
103 | |||
104 | /** |
||
105 | * Aframe Document Object Model |
||
106 | * |
||
107 | * @api |
||
108 | * |
||
109 | * @return \AframeVR\Core\DOM\AframeDOMDocument |
||
110 | */ |
||
111 | 2 | public function dom() |
|
115 | |||
116 | /** |
||
117 | * Assets |
||
118 | * |
||
119 | * @api |
||
120 | * |
||
121 | * @param null|Config $config |
||
122 | * @return \AframeVR\Core\Assets |
||
123 | */ |
||
124 | 98 | public function asset(Config $config = null): Assets |
|
128 | |||
129 | /** |
||
130 | * Child entity / primitive |
||
131 | * |
||
132 | * @return \AframeVR\Core\Helpers\EntityChildrenFactory |
||
133 | */ |
||
134 | 77 | public function child(): EntityChildrenFactory |
|
138 | |||
139 | /** |
||
140 | * Render the A-Frame scene and return the HTML |
||
141 | * |
||
142 | * @api |
||
143 | * |
||
144 | * @param bool $only_scene |
||
145 | * @return string |
||
146 | */ |
||
147 | 19 | public function save($only_scene = false, string $file = null): string |
|
157 | |||
158 | /** |
||
159 | * Render the A-Frame scene and passthru HTML |
||
160 | * |
||
161 | * @api |
||
162 | * |
||
163 | * @param bool $only_scene |
||
164 | * @return void |
||
165 | */ |
||
166 | 1 | public function render($only_scene = false) |
|
170 | |||
171 | /** |
||
172 | * Alias of AframeDOMDocument::setTitle(string) |
||
173 | * |
||
174 | * Set <title> tag |
||
175 | * $this->dom()->setTitle(string); |
||
176 | * |
||
177 | * @api |
||
178 | * |
||
179 | * @param string $title |
||
180 | */ |
||
181 | 1 | public function title(string $title) |
|
185 | |||
186 | /** |
||
187 | * Alias of AframeDOMDocument::setDescription(string) |
||
188 | * |
||
189 | * Set <meta name="description"> tag |
||
190 | * $this->dom()->setDescription(string); |
||
191 | * |
||
192 | * @api |
||
193 | * |
||
194 | * @param string $description |
||
195 | */ |
||
196 | 1 | public function description(string $description) |
|
200 | |||
201 | /** |
||
202 | * Get scenes keyword |
||
203 | * |
||
204 | * @return string |
||
205 | */ |
||
206 | 1 | public function getKeyword() |
|
210 | |||
211 | /** |
||
212 | * Load component for this scene or set it's attr |
||
213 | * |
||
214 | * @param string $component_name |
||
215 | * @param null|string $attr_data |
||
216 | * @throws \AframeVR\Core\Exceptions\BadComponentCallException |
||
217 | * @return object|null |
||
218 | */ |
||
219 | 2 | public function attr(string $component_name, string $attr_data = null) |
|
237 | |||
238 | /** |
||
239 | * Add scripts like components and shaders |
||
240 | * |
||
241 | * @param string $path |
||
242 | * @return void |
||
243 | */ |
||
244 | public function addScript(string $path) |
||
248 | |||
249 | /** |
||
250 | * Map calls to scene entities and components |
||
251 | * |
||
252 | * Since we might need to customize these to have |
||
253 | * custom components loaded as $this->methosd aswell therefore |
||
254 | * we have these placeholder magic methods here |
||
255 | * |
||
256 | * @param string $method |
||
257 | * @param array $args |
||
258 | * @throws BadShaderCallException |
||
259 | * @return Entity|\AframeVR\Interfaces\ComponentInterface |
||
260 | */ |
||
261 | 79 | public function __call(string $method, array $args) |
|
272 | |||
273 | /** |
||
274 | * Add everyting to DOM |
||
275 | * |
||
276 | * @return void |
||
277 | */ |
||
278 | 19 | protected function prepare() |
|
298 | |||
299 | /** |
||
300 | * Append all assets |
||
301 | * |
||
302 | * @return void |
||
303 | */ |
||
304 | 19 | protected function prepareAssets() |
|
309 | |||
310 | /** |
||
311 | * Append extra scripts |
||
312 | * |
||
313 | * like extra components and shaders used in scene |
||
314 | * |
||
315 | * @return void |
||
316 | */ |
||
317 | 19 | protected function prepareScripts() |
|
321 | } |
||
322 |
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):