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