Code Duplication    Length = 112-116 lines in 2 locations

src/Core/Components/Geometry/Methods/CylinderMethods.php 1 location

@@ 26-141 (lines=116) @@
23
 * @formatter:on */
24
namespace AframeVR\Core\Components\Geometry\Methods;
25
26
class CylinderMethods
27
{
28
29
    /**
30
     * The cylinder primitive can define cylinders in the traditional sense like a Coca-Cola™ can,
31
     * but it can also define shapes such as tubes and curved surfaces.
32
     * We’ll go over some of these cylinder recipes below.
33
     * 1. Traditional cylinders can be defined by using only a height and a radius:
34
     * 2. Tubes can be defined by making the cylinder open-ended, which removes the top and bottom surfaces of the cylinder such that the inside is visible.
35
     * A double-sided material will be needed to render properly:
36
     * 3. Curved surfaces can be defined by specifying the angle via thetaLength such that the cylinder doesn’t curve all the way around,
37
     * making the cylinder open-ended, and then making the material double-sided.
38
     * 4. Other types of prisms can be defined by varying the number of radial segments (i.e., sides). For example, to make a hexagonal prism:
39
     */
40
    const DEFAULTS = array(
41
        /* Radius of the cylinder. */
42
        'height' => 3,
43
        /* Height of the cylinder. */
44
        'radius' => 2,
45
        /* Number of segmented faces around the circumference of the cylinder. */
46
        'segmentsRadial' => 36,
47
        /* Number of rows of faces along the height of the cylinder. */
48
        'segmentsHeight' => 18,
49
        /* Whether the ends of the cylinder are open (true) or capped ('false'). */
50
        'openEnded' => 'false',
51
        /* Starting angle in degrees. */
52
        'thetaStart' => 0,
53
        /* Central angle in degrees. */
54
        'thetaLength' => 360
55
    );
56
57
    /**
58
     * Height of the cylinder.
59
     *
60
     * @param &array $dom_attributes            
61
     * @param float|int $height            
62
     * @return void
63
     */
64
    public function height(array &$dom_attributes, float $height)
65
    {
66
        $dom_attributes['height'] = $height;
67
    }
68
69
    /**
70
     * Whether the ends of the cylinder are open (true) or capped (false).
71
     *
72
     * @param &array $dom_attributes            
73
     * @param bool|false $openEnded            
74
     * @return void
75
     */
76
    public function openEnded(array &$dom_attributes, bool $openEnded = false)
77
    {
78
        $dom_attributes['openEnded'] = $openEnded ? 'true' : 'false';
79
        ;
80
    }
81
82
    /**
83
     * Radius of the cylinder.
84
     *
85
     * @param &array $dom_attributes            
86
     * @param float|int $radius            
87
     * @return void
88
     */
89
    public function radius(array &$dom_attributes, float $radius)
90
    {
91
        $dom_attributes['radius'] = $radius;
92
    }
93
94
    /**
95
     * Number of rows of faces along the height of the cylinder.
96
     *
97
     * @param &array $dom_attributes            
98
     * @param int $segmentsHeight            
99
     * @return void
100
     */
101
    public function segmentsHeight(array &$dom_attributes, int $segmentsHeight)
102
    {
103
        $dom_attributes['segmentsHeight'] = $segmentsHeight;
104
    }
105
106
    /**
107
     * Central angle in degrees.
108
     *
109
     * @param &array $dom_attributes            
110
     * @param float|int $thetaLength            
111
     * @return void
112
     */
113
    public function thetaLength(array &$dom_attributes, float $thetaLength)
114
    {
115
        $dom_attributes['thetaLength'] = $thetaLength;
116
    }
117
118
    /**
119
     * Starting angle in degrees.
120
     *
121
     * @param &array $dom_attributes            
122
     * @param float|int $thetaStart            
123
     * @return void
124
     */
125
    public function thetaStart(array &$dom_attributes, float $thetaStart)
126
    {
127
        $dom_attributes['thetaStart'] = $thetaStart;
128
    }
129
130
    /**
131
     * Number of segmented faces around the circumference of the cylinder.
132
     *
133
     * @param &array $dom_attributes            
134
     * @param int $segmentsRadial            
135
     * @return void
136
     */
137
    public function segmentsRadial(array &$dom_attributes, int $segmentsRadial)
138
    {
139
        $dom_attributes['segmentsRadial'] = $segmentsRadial;
140
    }
141
}
142

src/Core/Components/Geometry/Methods/SphereMethods.php 1 location

@@ 26-137 (lines=112) @@
23
 * @formatter:on */
24
namespace AframeVR\Core\Components\Geometry\Methods;
25
26
class SphereMethods
27
{
28
29
    /**
30
     * The sphere primitive can define spheres in the traditional sense like a basketball.
31
     *
32
     * But it can also define various polyhedrons and abstract shapes given that it can specify
33
     * the number of horizontal and vertical angles and faces.
34
     *
35
     * Sticking with a basic sphere, the default number of segments is high enough to make the sphere appear round.
36
     */
37
    const DEFAULTS = array(
38
        /* Radius of the sphere. */
39
        'radius' => 1,
40
        /* Number of horizontal segments. */
41
        'segmentsWidth' => 18,
42
        /* Number of vertical segments. */
43
        'segmentsHeight' => 36,
44
        /* Horizontal starting angle. */
45
        'phiStart' => 0,
46
        /* Horizontal sweep angle size. */
47
        'phiLength' => 360,
48
        /* Vertical starting angle. */
49
        'thetaStart' => 0,
50
        /* Vertical sweep angle size. */
51
        'thetaLength' => 360
52
    );
53
54
    /**
55
     * Radius of the sphere.
56
     *
57
     * @param &array $dom_attributes            
58
     * @param float|int $radius            
59
     * @return void
60
     */
61
    public function radius(array &$dom_attributes, float $radius)
62
    {
63
        $dom_attributes['radius'] = $radius;
64
    }
65
66
    /**
67
     * Number of vertical segments.
68
     *
69
     * @param &array $dom_attributes            
70
     * @param int $segmentsHeight            
71
     * @return void
72
     */
73
    public function segmentsHeight(array &$dom_attributes, int $segmentsHeight)
74
    {
75
        $dom_attributes['segmentsHeight'] = $segmentsHeight;
76
    }
77
78
    /**
79
     * Number of horizontal segments.
80
     *
81
     * @param &array $dom_attributes            
82
     * @param int $segmentsWidth            
83
     * @return void
84
     */
85
    public function segmentsWidth(array &$dom_attributes, int $segmentsWidth)
86
    {
87
        $dom_attributes['segmentsWidth'] = $segmentsWidth;
88
    }
89
90
    /**
91
     * Horizontal starting angle.
92
     *
93
     * @param &array $dom_attributes            
94
     * @param float|int $phiStart            
95
     * @return void
96
     */
97
    public function phiStart(array &$dom_attributes, float $phiStart)
98
    {
99
        $dom_attributes['phiStart'] = $phiStart;
100
    }
101
102
    /**
103
     * Horizontal sweep angle size.
104
     *
105
     * @param &array $dom_attributes            
106
     * @param float|int $phiLength            
107
     * @return void
108
     */
109
    public function phiLength(array &$dom_attributes, float $phiLength = null)
110
    {
111
        $dom_attributes['phiLength'] = $phiLength;
112
    }
113
114
    /**
115
     * Vertical starting angle.
116
     *
117
     * @param &array $dom_attributes            
118
     * @param float|int $thetaStart            
119
     * @return void
120
     */
121
    public function thetaStart(array &$dom_attributes, float $thetaStart)
122
    {
123
        $dom_attributes['thetaStart'] = $thetaStart;
124
    }
125
126
    /**
127
     * Vertical sweep angle size.
128
     *
129
     * @param &array $dom_attributes            
130
     * @param float|int $thetaLength            
131
     * @return void
132
     */
133
    public function thetaLength(array &$dom_attributes, float $thetaLength)
134
    {
135
        $dom_attributes['thetaLength'] = $thetaLength;
136
    }
137
}
138