<commit_before>/*global Material */
import ShaderProgram from './gl/shader_program';
import shaderSources from './gl/shader_sources'; // built-in shaders
import GLSL from './gl/glsl';

export default class Material {
    constructor (config = {}) {
        this.emission = config.emission && config.emission.map(parseFloat);
        this.ambient = config.ambient && config.ambient.map(parseFloat);
        this.diffuse = config.diffuse ? config.diffuse.map(parseFloat) : [1,1,1];
        this.specular = config.specular && config.specular.map(parseFloat);
        this.shininess = config.shininess ? parseFloat(config.shininess) : 0.2;

        this.emission = GLSL.expandVec4(this.emission);
        this.ambient = GLSL.expandVec4(this.ambient);
        this.diffuse = GLSL.expandVec4(this.diffuse);
        this.specular = GLSL.expandVec4(this.specular);
    }

    inject (style) {
        if (this.emission) {
            style.defines['TANGRAM_MATERIAL_EMISSION'] = true;
        }
        if (this.ambient) {
            style.defines['TANGRAM_MATERIAL_AMBIENT'] = true;
        }
        if (this.diffuse) {
            style.defines['TANGRAM_MATERIAL_DIFFUSE'] = true;
        }
        if (this.specular) {
            style.defines['TANGRAM_MATERIAL_SPECULAR'] = true;
        }

        style.addShaderTransform(Material.transform, shaderSources['gl/shaders/material']);
    }

    setupProgram (_program) {
        if (this.emission) {
            _program.uniform('4fv', 'u_material.emission', this.emission);
        }
        if (this.ambient) {<commit_msg>material: default ambient on, use replace syntax<commit_after>/*global Material */
import ShaderProgram from './gl/shader_program';
import shaderSources from './gl/shader_sources'; // built-in shaders
import GLSL from './gl/glsl';

export default class Material {
    constructor (config) {
        config = config || {};
        this.emission = config.emission && config.emission.map(parseFloat);
        this.ambient = config.ambient ? config.ambient.map(parseFloat) : [1,1,1];
        this.diffuse = config.diffuse ? config.diffuse.map(parseFloat) : [1,1,1];
        this.specular = config.specular && config.specular.map(parseFloat);
        this.shininess = config.shininess ? parseFloat(config.shininess) : 0.2;

        this.emission = GLSL.expandVec4(this.emission);
        this.ambient = GLSL.expandVec4(this.ambient);
        this.diffuse = GLSL.expandVec4(this.diffuse);
        this.specular = GLSL.expandVec4(this.specular);
    }

    inject (style) {
        if (this.emission) {
            style.defines['TANGRAM_MATERIAL_EMISSION'] = true;
        }
        if (this.ambient) {
            style.defines['TANGRAM_MATERIAL_AMBIENT'] = true;
        }
        if (this.diffuse) {
            style.defines['TANGRAM_MATERIAL_DIFFUSE'] = true;
        }
        if (this.specular) {
            style.defines['TANGRAM_MATERIAL_SPECULAR'] = true;
        }

        style.replaceShaderTransform(Material.transform, shaderSources['gl/shaders/material']);
    }

    setupProgram (_program) {
        if (this.emission) {
            _program.uniform('4fv', 'u_material.emission', this.emission);
        }
        if (this.ambient) {
{'fraction_non_alphanumeric': 0.13082660037290242, 'fraction_numerical': 0.007147296457426973, 'mean_word_length': 2.6414027149321266, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '756141', 'n_tokens_mistral': 1044, 'n_tokens_neox': 995, 'n_words': 161}