Code Duplication    Length = 35-38 lines in 2 locations

src/Extras/Primitives/Sphere.php 1 location

@@ 36-73 (lines=38) @@
33
 * The sphere primitive creates a spherical or polyhedron shapes.
34
 * It wraps an entity that prescribes the geometry component with its geometric primitive set to sphere.
35
 */
36
class Sphere extends Entity implements PrimitiveInterface
37
{
38
    use MeshAttributes;
39
40
    public function init()
41
    {
42
        $this->component('Material');
43
        $this->component('Geometry')->primitive('sphere');
44
        
45
        /* Load defaults */
46
        $this->defaults();
47
    }
48
49
    public function radius(float $radius = 0.85): Entity
50
    {
51
        $this->component('Geometry')->radius($radius);
52
        return $this;
53
    }
54
55
    public function segmentsHeight($segmentsHeigh = 18)
56
    {
57
        $this->component('Geometry')->segmentsHeight($segmentsHeigh);
58
        return $this;
59
    }
60
61
    public function segmentsWidth($segmentsWidth = 36)
62
    {
63
        $this->component('Geometry')->segmentsWidth($segmentsWidth);
64
        return $this;
65
    }
66
67
    public function defaults()
68
    {
69
        $this->radius();
70
        $this->segmentsHeight();
71
        $this->segmentsWidth();
72
    }
73
}
74
 

src/Extras/Primitives/Box.php 1 location

@@ 39-73 (lines=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
class Box extends Entity implements PrimitiveInterface
40
{
41
    use MeshAttributes;
42
43
    public function init()
44
    {
45
        $this->component('Material');
46
        $this->component('Geometry')->primitive('box');
47
    }
48
49
    public function depth(float $depth = 1): EntityInterface
50
    {
51
        $this->component('Geometry')->depth($depth);
52
        return $this;
53
    }
54
55
    public function height(float $height = 1): EntityInterface
56
    {
57
        $this->component('Geometry')->height($height);
58
        return $this;
59
    }
60
61
    public function width(float $width = 1): EntityInterface
62
    {
63
        $this->component('Geometry')->width($width);
64
        return $this;
65
    }
66
67
    public function defaults()
68
    {
69
        $this->depth();
70
        $this->height();
71
        $this->width();
72
    }
73
}
74