# all files / src/light/ AmbientSH.js

11.11% Statements 1/9
100% Branches 0/0
0% Functions 0/3
11.11% Lines 1/9

    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

    1×

     import Light from '../Light';
    import vendor from '../core/vendor';

    /**
     * Spherical Harmonic Ambient Light
     * @constructor clay.light.AmbientSH
     * @extends clay.Light
     */
    var AmbientSHLight = Light.extend({

        castShadow: false,

        /**
         * Spherical Harmonic Coefficients
         * @type {Array.<number>}
         * @memberOf clay.light.AmbientSH#
         */
        coefficients: [],

    }, function () {
        this._coefficientsTmpArr = new vendor.Float32Array(9 * 3);
    }, {

        type: 'AMBIENT_SH_LIGHT',

        uniformTemplates: {
            ambientSHLightColor: {
                type: '3f',
                value: function (instance) {
                    var color = instance.color;
                    var intensity = instance.intensity;
                    return [color[0] * intensity, color[1] * intensity, color[2] * intensity];
                }
            },

            ambientSHLightCoefficients: {
                type: '3f',
                value: function (instance) {
                    var coefficientsTmpArr = instance._coefficientsTmpArr;
                    for (var i = 0; i < instance.coefficients.length; i++) {
                        coefficientsTmpArr[i] = instance.coefficients[i];
                    }
                    return coefficientsTmpArr;
                }
            }
        }
        /**
         * @function
         * @name clone
         * @return {clay.light.Ambient}
         * @memberOf clay.light.Ambient.prototype
         */
    });

    export default AmbientSHLight;