1 | <?php |
||
31 | final class Scene |
||
32 | { |
||
33 | /* All scenes can use primitives */ |
||
34 | use Primitives; |
||
35 | |||
36 | /** |
||
37 | * Name with what you can retrieve this scene while working with multiple scenes |
||
38 | * |
||
39 | * @var string $name |
||
40 | */ |
||
41 | private $name; |
||
42 | |||
43 | protected $assets = array(); |
||
44 | |||
45 | /** |
||
46 | * Aframe Document Object Model |
||
47 | * |
||
48 | * @var \AframeVR\Core\DOM\AframeDOMDocument |
||
49 | */ |
||
50 | protected $aframeDomObj; |
||
51 | |||
52 | /** |
||
53 | * A-Frame scene entities |
||
54 | * |
||
55 | * @var array $entities |
||
56 | */ |
||
57 | protected $entities = array(); |
||
58 | |||
59 | /** |
||
60 | * Scene constructor |
||
61 | * |
||
62 | * @param string $name |
||
63 | * @param Config $config |
||
64 | */ |
||
65 | 59 | public function __construct(string $name, Config $config) |
|
70 | |||
71 | /** |
||
72 | * Aframe Document Object Model |
||
73 | * |
||
74 | * @api |
||
75 | * |
||
76 | * @return \AframeVR\Core\DOM\AframeDOMDocument |
||
77 | */ |
||
78 | 4 | public function dom() |
|
82 | |||
83 | /** |
||
84 | * Entity |
||
85 | * |
||
86 | * @api |
||
87 | * |
||
88 | * @param string $name |
||
89 | * @return Entity |
||
90 | */ |
||
91 | 27 | public function entity(string $name = 'untitled'): Entity |
|
95 | |||
96 | /** |
||
97 | * Assets |
||
98 | * |
||
99 | * @api |
||
100 | * |
||
101 | * @param string $name |
||
102 | * @return \AframeVR\Interfaces\AssetsInterface |
||
103 | */ |
||
104 | 2 | public function asset(string $name = 'untitled'): AssetsInterface |
|
108 | |||
109 | /** |
||
110 | * Render the A-Frame scene and return the HTML |
||
111 | * |
||
112 | * @api |
||
113 | * |
||
114 | * @param bool $only_scene |
||
115 | * @return string |
||
116 | */ |
||
117 | 3 | public function save($only_scene = false): string |
|
122 | |||
123 | /** |
||
124 | * Render the A-Frame scene and passthru HTML |
||
125 | * |
||
126 | * @api |
||
127 | * |
||
128 | * @param bool $only_scene |
||
129 | * @return void |
||
130 | */ |
||
131 | 1 | public function render($only_scene = false) |
|
136 | |||
137 | /** |
||
138 | * Alias of AframeDOMDocument::setTitle(string) |
||
139 | * |
||
140 | * Set <title> tag |
||
141 | * $this->dom()->setTitle(string); |
||
142 | * |
||
143 | * @api |
||
144 | * |
||
145 | * @param string $title |
||
146 | */ |
||
147 | 2 | public function title(string $title) |
|
151 | |||
152 | /** |
||
153 | * Alias of AframeDOMDocument::setDescription(string) |
||
154 | * |
||
155 | * Set <meta name="description"> tag |
||
156 | * $this->dom()->setDescription(string); |
||
157 | * |
||
158 | * @api |
||
159 | * |
||
160 | * @param string $description |
||
161 | */ |
||
162 | 2 | public function description(string $description) |
|
166 | |||
167 | /** |
||
168 | * Add everyting to DOM |
||
169 | * |
||
170 | * @return void |
||
171 | */ |
||
172 | 3 | protected function prepare() |
|
178 | } |
||
179 |