1
|
|
|
<?php |
2
|
|
|
/** @formatter:off |
3
|
|
|
* ****************************************************************** |
4
|
|
|
* Created by Marko Kungla on Jul 7, 2016 - 4:51:28 AM |
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 Videosphere.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\Primitives; |
25
|
|
|
|
26
|
|
|
use \AframeVR\Core\Entity; |
27
|
|
|
use \AframeVR\Interfaces\EntityInterface; |
28
|
|
|
|
29
|
|
|
class Videosphere extends Entity implements EntityInterface |
30
|
|
|
{ |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Init <a-video> |
34
|
|
|
* |
35
|
|
|
* The video primitive displays a video on a flat plane as a texture. It is an entity that prescribes the geometry |
36
|
|
|
* with its geometric primitive set to plane. |
37
|
|
|
* |
38
|
|
|
* @return void |
39
|
|
|
*/ |
40
|
2 |
|
public function reset() |
41
|
|
|
{ |
42
|
2 |
|
$this->attr('Material')->shader('flat'); |
43
|
2 |
|
$this->color('#FFF'); |
44
|
|
|
|
45
|
2 |
|
$this->attr('Geometry')->primitive('sphere'); |
46
|
2 |
|
$this->radius(5000); |
47
|
2 |
|
$this->segmentsHeight(64); |
48
|
2 |
|
$this->segmentsWidth(20); |
49
|
|
|
|
50
|
2 |
|
$this->scale(- 1, 1, 1); |
51
|
2 |
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* geometry.radius |
55
|
|
|
* |
56
|
|
|
* @param float $radius |
57
|
|
|
* @return Videosphere |
58
|
|
|
*/ |
59
|
2 |
|
public function radius(float $radius) |
60
|
|
|
{ |
61
|
2 |
|
$this->attr('Geometry')->radius($radius); |
62
|
2 |
|
return $this; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Autoplay video |
67
|
|
|
* |
68
|
|
|
* @param bool $autoplay |
69
|
|
|
* @return Videosphere |
70
|
|
|
*/ |
71
|
2 |
|
public function autoplay(bool $autoplay = true) |
72
|
|
|
{ |
73
|
2 |
|
$this->attrs['autoplay'] = $autoplay ? 'true' : 'false'; |
74
|
2 |
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* geometry.segmentsHeight |
79
|
|
|
* |
80
|
|
|
* @param int $segmentsHeigh |
81
|
|
|
* @return Videosphere |
82
|
|
|
*/ |
83
|
2 |
|
public function segmentsHeight(int $segmentsHeigh) |
84
|
|
|
{ |
85
|
2 |
|
$this->attr('Geometry')->segmentsHeight($segmentsHeigh); |
86
|
2 |
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* geometry.segmentsWidth |
91
|
|
|
* |
92
|
|
|
* @param int $segmentsWidth |
93
|
|
|
* @return Videosphere |
94
|
|
|
*/ |
95
|
2 |
|
public function segmentsWidth(int $segmentsWidth) |
96
|
|
|
{ |
97
|
2 |
|
$this->attr('Geometry')->segmentsWidth($segmentsWidth); |
98
|
2 |
|
return $this; |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|