# Code coverage report for src/geometry/Cylinder.js

# all files / src/geometry/ Cylinder.js

100% Statements 8/8
100% Branches 0/0
100% Functions 2/2
100% Lines 8/8

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63

    1×

    5×

    5×

    5×
    5×
    5×
    5×

    5×

     import Geometry from '../Geometry';
    import ConeGeometry from './Cone';

    /**
     * @constructor clay.geometry.Cylinder
     * @extends clay.Geometry
     * @param {Object} [opt]
     * @param {number} [opt.radius]
     * @param {number} [opt.height]
     * @param {number} [opt.capSegments]
     * @param {number} [opt.heightSegments]
     */
    var Cylinder = Geometry.extend(
    /** @lends clay.geometry.Cylinder# */
    {
        dynamic: false,
        /**
         * @type {number}
         */
        radius: 1,

        /**
         * @type {number}
         */
        height: 2,

        /**
         * @type {number}
         */
        capSegments: 50,

        /**
         * @type {number}
         */
        heightSegments: 1
    }, function() {
        this.build();
    },
    /** @lends clay.geometry.Cylinder.prototype */
    {
        /**
         * Build cylinder geometry
         */
        build: function() {
            var cone = new ConeGeometry({
                topRadius: this.radius,
                bottomRadius: this.radius,
                capSegments: this.capSegments,
                heightSegments: this.heightSegments,
                height: this.height
            });

            this.attributes.position.value = cone.attributes.position.value;
            this.attributes.normal.value = cone.attributes.normal.value;
            this.attributes.texcoord0.value = cone.attributes.texcoord0.value;
            this.indices = cone.indices;

            this.boundingBox = cone.boundingBox;
        }
    });

    export default Cylinder;