# all files / src/ Mesh.js

91.3% Statements 21/23
33.33% Branches 3/9
75% Functions 3/4
91.3% Lines 21/23

    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
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75

    1×

    32×
    32×

    249×

    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×

     import Renderable from './Renderable';
    import glenum from './core/glenum';
    import Texture2D from './Texture2D';

    /**
     * @constructor clay.Mesh
     * @extends clay.Renderable
     */
    var Mesh = Renderable.extend(/** @lends clay.Mesh# */ {
        /**
         * Used when it is a skinned mesh
         * @type {clay.Skeleton}
         */
        skeleton: null,
        /**
         * Joints indices Meshes can share the one skeleton instance and each mesh can use one part of joints. Joints indices indicate the index of joint in the skeleton instance
         * @type {number[]}
         */
        joints: null,

        /**
         * If store the skin matrices in vertex texture
         * @type {bool}
         */
        useSkinMatricesTexture: false

    }, function () {
        Eif (!this.joints) {
            this.joints = [];
        }
    }, {

        isSkinnedMesh: function () {
            return !!(this.skeleton && this.joints && this.joints.length > 0);
        },

        getSkinMatricesTexture: function () {
            this._skinMatricesTexture = this._skinMatricesTexture || new Texture2D({
                type: glenum.FLOAT,
                minFilter: glenum.NEAREST,
                magFilter: glenum.NEAREST,
                useMipmap: false,
                flipY: false
            });

            return this._skinMatricesTexture;
        },

        clone: function () {
            var mesh = Renderable.prototype.clone.call(this);
            mesh.skeleton = this.skeleton;
            Eif (this.joints) {
                mesh.joints = this.joints.slice();
            }
            return mesh;
        }
    });

    // Enums
    Mesh.POINTS = glenum.POINTS;
    Mesh.LINES = glenum.LINES;
    Mesh.LINE_LOOP = glenum.LINE_LOOP;
    Mesh.LINE_STRIP = glenum.LINE_STRIP;
    Mesh.TRIANGLES = glenum.TRIANGLES;
    Mesh.TRIANGLE_STRIP = glenum.TRIANGLE_STRIP;
    Mesh.TRIANGLE_FAN = glenum.TRIANGLE_FAN;

    Mesh.BACK = glenum.BACK;
    Mesh.FRONT = glenum.FRONT;
    Mesh.FRONT_AND_BACK = glenum.FRONT_AND_BACK;
    Mesh.CW = glenum.CW;
    Mesh.CCW = glenum.CCW;

    export default Mesh;