# Code coverage report for src/particle/Particle.js

# all files / src/particle/ Particle.js

18.75% Statements 3/16
0% Branches 0/4
0% Functions 0/2
18.75% Lines 3/16

    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

    1×

    1×

    1×

     import Vector3 from '../math/Vector3';
    import glMatrix from '../dep/glmatrix';
    var vec3 = glMatrix.vec3;

    /**
     * @constructor
     * @alias clay.particle.Particle
     */
    var Particle = function() {
        /**
         * @type {clay.Vector3}
         */
        this.position = new Vector3();

        /**
         * Use euler angle to represent particle rotation
         * @type {clay.Vector3}
         */
        this.rotation = new Vector3();

        /**
         * @type {?clay.Vector3}
         */
        this.velocity = null;

        /**
         * @type {?clay.Vector3}
         */
        this.angularVelocity = null;

        /**
         * @type {number}
         */
        this.life = 1;

        /**
         * @type {number}
         */
        this.age = 0;

        /**
         * @type {number}
         */
        this.spriteSize = 1;

        /**
         * @type {number}
         */
        this.weight = 1;

        /**
         * @type {clay.particle.Emitter}
         */
        this.emitter = null;
    };

    /**
     * Update particle position
     * @param  {number} deltaTime
     */
    Particle.prototype.update = function(deltaTime) {
        if (this.velocity) {
            vec3.scaleAndAdd(this.position.array, this.position.array, this.velocity.array, deltaTime);
        }
        if (this.angularVelocity) {
            vec3.scaleAndAdd(this.rotation.array, this.rotation.array, this.angularVelocity.array, deltaTime);
        }
    };

    export default Particle;