1
|
|
|
<?php |
2
|
|
|
/** @formatter:off |
3
|
|
|
* ****************************************************************** |
4
|
|
|
* Created by Marko Kungla on Jun 20, 2016 - 10:21:07 PM |
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 Primitives.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\Extras; |
25
|
|
|
|
26
|
|
|
use \AframeVR\Core\Entity; |
27
|
|
|
trait Primitives |
28
|
|
|
{ |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Aframe Document Object Model |
32
|
|
|
* |
33
|
|
|
* @var \AframeVR\Core\DOM\AframeDOMDocument |
34
|
|
|
*/ |
35
|
|
|
protected $aframeDomObj; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Children entities |
39
|
|
|
* |
40
|
|
|
* @var array $childrens |
41
|
|
|
*/ |
42
|
|
|
protected $childrens = array(); |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* |
46
|
|
|
* @var \AframeVR\Extras\Primitives\Sky $sky |
47
|
|
|
*/ |
48
|
|
|
protected $sky; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* |
52
|
|
|
* @var \AframeVR\Extras\Primitives\Videosphere $videosphere |
53
|
|
|
*/ |
54
|
|
|
protected $videosphere; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* A-Frame Primitive sky |
58
|
|
|
* |
59
|
|
|
* @return Entity |
60
|
|
|
*/ |
61
|
2 |
|
public function sky(string $id = 'untitled'): Entity |
62
|
|
|
{ |
63
|
2 |
|
return $this->sky = new \AframeVR\Extras\Primitives\Sky($id); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* A-Frame Primitive videosphere |
68
|
|
|
* |
69
|
|
|
* @return Entity |
70
|
|
|
*/ |
71
|
2 |
|
public function videosphere(string $id = 'untitled'): Entity |
72
|
|
|
{ |
73
|
2 |
|
return $this->videosphere = new \AframeVR\Extras\Primitives\Videosphere($id); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Add all used primitevs to the scene |
78
|
|
|
* |
79
|
|
|
* @return void |
80
|
|
|
*/ |
81
|
19 |
|
protected function preparePrimitives() |
82
|
|
|
{ |
83
|
|
|
/* Primitive collections */ |
84
|
19 |
|
$this->aframeDomObj->appendEntities($this->childrens); |
85
|
|
|
/* Primitives which only one can be present */ |
86
|
19 |
|
(! $this->sky) ?: $this->aframeDomObj->appendEntity($this->sky); |
87
|
19 |
|
(! $this->videosphere) ?: $this->aframeDomObj->appendEntity($this->videosphere); |
88
|
19 |
|
} |
89
|
|
|
} |
90
|
|
|
|