1 | <?php |
||
36 | class Entity implements EntityInterface |
||
37 | { |
||
38 | |||
39 | protected $components = array(); |
||
40 | |||
41 | protected $animations = array(); |
||
42 | |||
43 | 58 | public function __construct() |
|
64 | |||
65 | 31 | public function init() |
|
67 | |||
68 | 31 | public function defaults() |
|
70 | |||
71 | /** |
||
72 | * Position component |
||
73 | * |
||
74 | * All entities inherently have the position component. |
||
75 | * |
||
76 | * @param int|float $x_axis |
||
77 | * @param int|float $y_axis |
||
78 | * @param int|float $z_axis |
||
79 | * @return \AframeVR\Core\Entity |
||
80 | */ |
||
81 | 58 | public function position(float $x_axis = 0, float $y_axis = 0, float $z_axis = 0): Entity |
|
82 | { |
||
83 | 58 | $this->component('Position')->positionX($x_axis); |
|
84 | 58 | $this->component('Position')->positionY($y_axis); |
|
85 | 58 | $this->component('Position')->positionZ($z_axis); |
|
86 | 58 | return $this; |
|
87 | } |
||
88 | |||
89 | /** |
||
90 | * Rotation component |
||
91 | * |
||
92 | * All entities inherently have the rotation component. |
||
93 | * |
||
94 | * @param int|float $roll |
||
95 | * @param int|float $pitch |
||
96 | * @param int|float $yaw |
||
97 | * @return \AframeVR\Core\Entity |
||
98 | */ |
||
99 | 58 | public function rotation(float $roll = 0, float $pitch = 0, float $yaw = 0): Entity |
|
100 | { |
||
101 | 58 | $this->component('Rotation')->roll($roll); |
|
102 | 58 | $this->component('Rotation')->pitch($pitch); |
|
103 | 58 | $this->component('Rotation')->yaw($yaw); |
|
104 | 58 | return $this; |
|
105 | } |
||
106 | |||
107 | /** |
||
108 | * Scale component |
||
109 | * |
||
110 | * All entities inherently have the scale component. |
||
111 | * |
||
112 | * @param int|float $scale_x |
||
113 | * @param int|float $scale_y |
||
114 | * @param int|float $scale_z |
||
115 | * @return \AframeVR\Core\Entity |
||
116 | */ |
||
117 | 58 | public function scale(float $scale_x = 1, float $scale_y = 1, float $scale_z = 1): Entity |
|
118 | { |
||
119 | 58 | $this->component('Scale')->scaleX($scale_x); |
|
120 | 58 | $this->component('Scale')->scaleY($scale_y); |
|
121 | 58 | $this->component('Scale')->scaleZ($scale_z); |
|
122 | 58 | return $this; |
|
123 | } |
||
124 | |||
125 | /** |
||
126 | * Animations |
||
127 | * |
||
128 | * @param string $name |
||
129 | * @return \AframeVR\Interfaces\AnimationInterface |
||
130 | */ |
||
131 | 1 | public function animation(string $name = 'untitled'): AnimationInterface |
|
135 | |||
136 | /** |
||
137 | * Load component for this entity |
||
138 | * |
||
139 | * @param string $component_name |
||
140 | * @throws \AframeVR\Core\Exceptions\BadComponentCallException |
||
141 | * @return object|null |
||
142 | */ |
||
143 | 58 | public function component(string $component_name) |
|
158 | |||
159 | /** |
||
160 | * Handle entity components |
||
161 | * |
||
162 | * Since we might need to customize these to have |
||
163 | * custom components loaded as $this->methosd aswell therefore |
||
164 | * we have these placeholder magic methods here |
||
165 | * |
||
166 | * @param string $component_name |
||
167 | * @param array $args |
||
168 | */ |
||
169 | 12 | public function __call(string $component_name, array $args) |
|
179 | |||
180 | /** |
||
181 | * Create and add DOM element of the entity |
||
182 | * |
||
183 | * @param \DOMDocument $aframe_dom |
||
184 | * @return \DOMElement |
||
185 | */ |
||
186 | 2 | public function domElement(&$aframe_dom): DOMElement |
|
199 | } |
||
200 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.