1
|
|
|
<?php |
2
|
|
|
/** @formatter:off |
3
|
|
|
* ****************************************************************** |
4
|
|
|
* Created by Marko Kungla on Jun 21, 2016 - 11:58:54 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 Box.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\Core\Helpers\MeshAttributes; |
28
|
|
|
use \AframeVR\Interfaces\{ |
29
|
|
|
PrimitiveInterface, |
30
|
|
|
EntityInterface |
31
|
|
|
}; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* <a-box> |
35
|
|
|
* |
36
|
|
|
* The box primitive, formerly called <a-cube>, creates shapes such as boxes, cubes, or walls. |
37
|
|
|
* It is an entity that prescribes the geometry with its geometric primitive set to box. |
38
|
|
|
*/ |
39
|
|
View Code Duplication |
class Box extends Entity implements PrimitiveInterface |
|
|
|
|
40
|
|
|
{ |
41
|
|
|
use MeshAttributes; |
42
|
|
|
|
43
|
4 |
|
public function init() |
44
|
|
|
{ |
45
|
4 |
|
$this->component('Material'); |
46
|
4 |
|
$this->component('Geometry')->primitive('box'); |
|
|
|
|
47
|
4 |
|
} |
48
|
|
|
|
49
|
4 |
|
public function depth(float $depth = 1): EntityInterface |
50
|
|
|
{ |
51
|
4 |
|
$this->component('Geometry')->depth($depth); |
|
|
|
|
52
|
4 |
|
return $this; |
53
|
|
|
} |
54
|
|
|
|
55
|
4 |
|
public function height(float $height = 1): EntityInterface |
56
|
|
|
{ |
57
|
4 |
|
$this->component('Geometry')->height($height); |
|
|
|
|
58
|
4 |
|
return $this; |
59
|
|
|
} |
60
|
|
|
|
61
|
4 |
|
public function width(float $width = 1): EntityInterface |
62
|
|
|
{ |
63
|
4 |
|
$this->component('Geometry')->width($width); |
|
|
|
|
64
|
4 |
|
return $this; |
65
|
|
|
} |
66
|
|
|
|
67
|
4 |
|
public function defaults() |
68
|
|
|
{ |
69
|
4 |
|
$this->depth(); |
70
|
4 |
|
$this->height(); |
71
|
4 |
|
$this->width(); |
72
|
4 |
|
} |
73
|
|
|
} |
74
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.